问题
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). Withnone
, pandoc will not wrap lines at all. Withpreserve
, 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