3
votes

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
Can you add an example of the code that's not being highlighted? I don't know enough about wordpress, but others might be able to help.tarleb
When i use Pandoc to export to HTML and copy-paste it to wordpress.com, no codeblock is highlighted, because Pandoc creates incompatible HTML div tags: Pandoc creates <div class="sourceCode" id="cb7"><pre class="sourceCode Can Pandoc somehow set bash"><code class="sourceCode bash">..., whereas wordpress.com expects <div id="highlighter_592305" class="syntaxhighlighter bash".... Is there some way to modify the HTML output or the class attributes that Pandoc creates?manews
Please add both, example input and expected output for code blocks, directly into your question.tarleb

1 Answers

4
votes

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.