mfenner / jekyll-pandoc

Jekyll Pandoc markdown converter as Ruby gem
MIT License
82 stars 10 forks source link

Extensions with underscores not parsing correctly #10

Open inhaledesign opened 7 years ago

inhaledesign commented 7 years ago

I'm trying to use the 'markdown_in_html_blocks' extension. When I add it in _config,yml and try to build with Jekyll, I get the following error:

Conversion error: Jekyll::Converters::Markdown encountered an error while converting '_posts/2014-08-20-another-post.md': pandoc: unrecognized option `--markdown-in-html-blocks' Try pandoc --help for more information.

Notice that the error shows the option as having hyphens instead of underscores. I tested this out with a few other extensions that have underscores and saw the same pattern. Random extensions that do not have underscores did not result in an error.

_config.yml:

# Markdown config
gems: [ jekyll-pandoc ]
markdown: Pandoc
pandoc:
  extensions:
    - markdown_in_html_blocks
gwerbin commented 7 years ago

This is because that isn't the correct way to pass an extension to Pandoc. The actual invocation would be

pandoc --from markdown+markdown_in_html_blocks

rather than

pandoc --from markdown --markdown_in_html_blocks

So it seems all extensions would be handled incorrectly here.

dawaltconley commented 7 years ago

Similar issue: I'm trying to remove the implicit_figures extension. I'd imagine this should work:

pandoc:
  extensions:
    - "from=markdown-implicit_figures"

But I'm getting jekyll 3.4.3 | Error: pandoc: Unknown extension: implicit

My guess is that @radixdiaboli is right, and the underscores are being converted to hyphens, which is causing pandoc to try and subtract the extension called "implicit" as well as the extension called "figures".

svlauer commented 7 years ago

@dawaltconley : I was struggling with a similar problem. Not sure if works in all cases, but in your case, the problem can be solved by taking advantage of the fact that the underscore appears in the option VALUE, not in the option name. So that should be:

pandoc:
  extensions:
    - from: "markdown-implicit_figures"

With this, there will be no conversion of underscores in the value.

stalegjelsten commented 7 years ago

I think I have experienced the same bug. Pandoc extensions like smart are working, but I cannot get the table_captions extension to work.

Anyone have any suggestions for a (temporary at least) solution?

mauromorales commented 6 years ago

It seems that's not the case anymore:

jekyll 3.8.3 | Error:  --smart/-S has been removed.  Use +smart or -smart extension instead.
For example: pandoc -f markdown+smart -t markdown-smart.
Try pandoc --help for more information.

But the issue seems to come from the underlying pandoc wrapper gem pandoc-ruby as you can see here:

https://github.com/mfenner/jekyll-pandoc/blob/9143c2071f3d62d5e678d8622afe90af06bdac73/lib/jekyll-pandoc.rb#L17