How to export Pandoc markdown to Worpress.com compatible PHP Markdown Extra?

♀尐吖头ヾ 提交于 2019-12-11 02:54:32

问题


I have markdown documents in Pandoc's standard markdown format, which i would like to publish on a free wordpress.com blog ("free" implies that i cannot install plugins or modify Wordpress PHP files).

Officially, wordpress.com supports the PHP Markdown Extra variant that it converts into HTML, so theoretically i could just use Pandoc to convert my files into this markdown_phpextra format (which Pandoc does flawlessly).

However, as described in this SO question i noticed that my paragraphs appear wrong on the blog, because wordpress.com takes markdown-linebreaks literally when converting to HTML and does not reflow/rewrap paragraphs according to the "markdown_phpextra" spec.

For example, this markdown_phpextra text

This is a sentence.
This is a another sentence.

should become

<p>This is a sentence.
This is a another sentence.</p>

in HTML, but is actually converted by wordpress.com to

<p>This is a sentence.<br>
This is a another sentence.</p>

How can i convert my markdown files into some format that is compatible with wordpress.com?

  • Is it possible to make Pandoc export every paragraph on a single line? This would immediately work around/solve my problem.
  • Can i directly export with Pandoc into wordpress.com-syntax-highlight-compatible HTML? I have a lot of code snippets that aren't hightlighted when i use Pandoc to convert directly into HTML.

回答1:


Pandoc has an option wrap:

--wrap=auto|none|preserve

Determine how text is wrapped in the output (the source code, not the rendered version). With auto (the default), pandoc will attempt to wrap lines to the column width specified by --columns (default 72). With none, pandoc will not wrap lines at all. With preserve, pandoc will attempt to preserve the wrapping from the source document (that is, where there are nonsemantic newlines in the source, there will be nonsemantic newlines in the output as well). Automatic wrapping does not currently work in HTML output.

Thus calling pandoc with --wrap=none will put paragraphs in one line, as desired.



来源:https://stackoverflow.com/questions/52915101/how-to-export-pandoc-markdown-to-worpress-com-compatible-php-markdown-extra

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!