Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

wrong language parsing case #29

Open
ghost opened this issue Feb 20, 2021 · 2 comments
Open

wrong language parsing case #29

ghost opened this issue Feb 20, 2021 · 2 comments

Comments

@ghost
Copy link

ghost commented Feb 20, 2021

If you have an header with just the language and no spaces or other arguments, like #+begin_src python, when point is inside a polymode managed buffer (so a src block) org parses the language wrongly, it includes the subsequent line...the regex used by org to parse the language uses \S so any includes non white-space...and indeed \n is not a whitespace..but why does it happen only inside polymode? Parsing the point is at the header line works fine...

My current workaround is to just append a space to the end of the line if there isn't one

@vspinu
Copy link
Contributor

vspinu commented Feb 20, 2021

org parses the language wrongly, i

I don't quite follow. Can you provide a simple org mode example with the location of the pointer and explain what the above "parses wrongly" means?

Thanks!

@ghost
Copy link
Author

ghost commented Feb 21, 2021

We have:

#+begin_src python
import os
#+end_src

If (point) is on #+begin_src or #+end_src, I get:

(print (first (org-babel-get-src-block-info))

output is:
"python"

If (point) is inside...that is

#+begin_src python
import os # <-- HERE
#+end_src

I get...

(print (first (org-babel-get-src-block-info))

output is:

"python
import"

Note the new line, and it doesn't have os because there is a space between import and os,
indeed the function org-element-src-block-parser defined in org-element.el matches against \S that is any non whitespace; since the org regex is loose about new lines I guess this is a problem with narrowing? since probably that org function only matches against 1 line, but when inside an innermode it matches against multi lines.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant