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

Problem with fenced_code_attributes with commonmark #7097

Closed
wch opened this issue Feb 13, 2021 · 1 comment
Closed

Problem with fenced_code_attributes with commonmark #7097

wch opened this issue Feb 13, 2021 · 1 comment

Comments

@wch
Copy link

wch commented Feb 13, 2021

I was trying to use commonmark+fenced_code_attributes and gfm+fenced_code_attributes with one of the examples from the manual, but it didn't work -- the attributes like .haskell would get lost in the output:

cat << EOF | pandoc -f commonmark+fenced_code_attributes -t native
~~~~ {#mycode .haskell .numberLines startFrom="100"}
qsort []     = []
qsort (x:xs) = qsort (filter (< x) xs) ++ [x] ++
               qsort (filter (>= x) xs)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
EOF

The result:

[CodeBlock ("",["{#mycode"],[]) "qsort []     = []\nqsort (x:xs) = qsort (filter (< x) xs) ++ [x] ++\n               qsort (filter (>= x) xs)"]

I ended up spending an embarrassingly long time trying to figure out what was wrong, and finally discovered that it was because commonmark and gfm have -fenced_code_attributes:

$ pandoc --list-extensions=commonmark
-ascii_identifiers
-autolink_bare_uris
-bracketed_spans
-definition_lists
-east_asian_line_breaks
-emoji
-fancy_lists
-fenced_code_attributes
-fenced_divs
-footnotes
-gfm_auto_identifiers
-hard_line_breaks
-implicit_figures
-implicit_header_references
-pipe_tables
-raw_attribute
+raw_html
-raw_tex
-smart
-strikeout
-subscript
-superscript
-task_lists
-tex_math_dollars
-attributes
-sourcepos

So when I used +fenced_code_attributes, it was silently being ignored. It would be much friendlier behavior to either print an error message in this situation, or allow +fenced_code_attributes to override the setting in commonmark.

@jgm
Copy link
Owner

jgm commented Feb 13, 2021

When this prints -fenced_code_attributes, it means that this extension will affect the format, and that it is set to disabled by default. So +fenced_code_attributes should work.
Looks like +fenced_code_attributes+attributes does work.
(And also +attributes by itself). I need to look into this.

@jgm jgm changed the title Request: print a message when extension conflicts with a format, or allow extension to override Problem with fenced_code_attributes with commonmark Feb 13, 2021
@jgm jgm closed this as completed in 25b7df7 Feb 13, 2021
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

2 participants