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

org source block header arguments break syntax highlighting #2269

Closed
jo-tham opened this issue Jul 3, 2015 · 6 comments · Fixed by #2477
Closed

org source block header arguments break syntax highlighting #2269

jo-tham opened this issue Jul 3, 2015 · 6 comments · Fixed by #2477

Comments

@jo-tham
Copy link

jo-tham commented Jul 3, 2015

Hi,

I searched and haven't seen this reported in other open/closed issues. Let me know if I missing something here.

I am running pandoc as follows

pandoc test.org --from=org --to=html5 --standalone --highlight-style=espresso > test.html

test.org contains:

#+begin_src python :noeval
a = [i for i in range(10)]
print(a) 
#+end_src

#+begin_src python
a = [i for i in range(10)]
print(a)
#+end_src

Code highlighting works only if no header arguments are specified after language identifier. Otherwise the result has syntax highlighting.

here's a veiw of the html conversion on similar test.org
example

Is this known? What is the cause?

@jgm
Copy link
Owner

jgm commented Jul 4, 2015

The code has:

  opts <- option [] $ enclosedByPair '[' ']' inlineBlockOption

So, it's expecting the options to be enclosed in square brackets. I don't know anything about Org-mode, so maybe this is wrong, but that's why this is happening. @tarleb may be able to help.

@jo-tham
Copy link
Author

jo-tham commented Jul 4, 2015

Thank you for that info - this clears some things up. I should add
pandoc 1.14.0.4
Compiled with texmath 0.8.2, highlighting-kate 0.6.

Indeed with inline code blocks in org mode, the 'header' arguments are enclosed in square brackets

src_haskell[:exports both]{fac 5}

I have not seen it anywhere in the docs before, but arguments in code blocks can be enclosed in square brackets. I can evaluate the below example in org successfully.

#+begin_src sh [:results verbatim drawer replace output]
date
#+end_src

However, it doesn't seem to resolve this bug. E.g., the following code blocks, which include cases with and without [], do not get syntax highlighting

#+begin_src sh :noeval
echo "$HOME"
#+end_src

#+begin_src sh [:noeval]
echo "$HOME"
#+end_src

While these ones do convert with syntax highlighting

#+begin_src sh :var data1=1
echo "$data1"
#+end_src

#+NAME: test
#+HEADERS: :noeval
#+begin_src sh
echo "$HOME"
#+end_src

This is quite inconsistent.

Chances are, using the #+HEADERS option is the viable workaround and probably good practice for org users, but it would be nice to have this be more accurate in general.

I think I will try #+HEADERS for a while, and if I find it cumbersome, well... maybe there is a fix by then. Otherwise I can try to grok some haskell...

@jgm
Copy link
Owner

jgm commented Oct 21, 2015

I don't know anything about org mode.
But the current Org reader code assumes that an "org arg key" (like :var) will have some data after it.
That's why it runs aground on :noeval with nothing following.
@tarleb can you comment?

@tarleb
Copy link
Collaborator

tarleb commented Oct 21, 2015

As @jgm pointed out, the code was written under the faulty assumption that each header argument is followed by a value. I'll patch things up (might need a week or two).

@jo-tham
Copy link
Author

jo-tham commented Oct 21, 2015

Thanks, @tarleb!

tarleb added a commit to tarleb/pandoc that referenced this issue Oct 24, 2015
Org-mode allows to skip the argument of a code block header argument if
it's toggling a value.

This fixes jgm#2269.
tarleb added a commit to tarleb/pandoc that referenced this issue Oct 24, 2015
Org-mode allows to skip the argument of a code block header argument if
it's toggling a value.

This fixes jgm#2269.
tarleb added a commit to tarleb/pandoc that referenced this issue Oct 24, 2015
Org-mode allows to skip the argument of a code block header argument if
it's toggling a value.

This fixes jgm#2269.
tarleb added a commit to tarleb/pandoc that referenced this issue Oct 25, 2015
Org-mode allows to skip the argument of a code block header argument if
it's toggling a value.

This fixes jgm#2269.
tarleb added a commit to tarleb/pandoc that referenced this issue Oct 25, 2015
Org-mode allows to skip the argument of a code block header argument if
it's toggling a value.  Argument-less headers are now recognized,
avoiding weird parsing errors.

The fixes are not exactly pretty, but neither is the code that was
fixed.  So I guess it's about par for the course.  However, a rewrite of
the header parsing code wouldn't hurt in the long run.

This fixes jgm#2269.
tarleb added a commit to tarleb/pandoc that referenced this issue Oct 25, 2015
Org-mode allows to skip the argument of a code block header argument if
it's toggling a value.  Argument-less headers are now recognized,
avoiding weird parsing errors.

The fixes are not exactly pretty, but neither is the code that was
fixed.  So I guess it's about par for the course.  However, a rewrite of
the header parsing code wouldn't hurt in the long run.

This fixes jgm#2269.
tarleb added a commit to tarleb/pandoc that referenced this issue Oct 25, 2015
Org-mode allows to skip the argument of a code block header argument if
it's toggling a value.  Argument-less headers are now recognized,
avoiding weird parsing errors.

The fixes are not exactly pretty, but neither is the code that was
fixed.  So I guess it's about par for the course.  However, a rewrite of
the header parsing code wouldn't hurt in the long run.

Thanks to @jo-tham for filing the bug report.

This fixes jgm#2269.
@jgm jgm closed this as completed in #2477 Oct 25, 2015
@jo-tham
Copy link
Author

jo-tham commented Oct 26, 2015

👍

thanks!

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

Successfully merging a pull request may close this issue.

3 participants