如何将Pandoc markdown导出到与Worpress.com兼容的PHP Markdown Extra? [英] How to export Pandoc markdown to Worpress.com compatible PHP Markdown Extra?

查看:105
本文介绍了如何将Pandoc markdown导出到与Worpress.com兼容的PHP Markdown Extra?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有Pandoc标准markdown格式的降价文件,我想以免费的 wordpress.com 发布博客(免费"表示我无法安装插件或修改Wordpress PHP文件).

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).

正式地说,wordpress.com支持将 PHP Markdown Extra 变体HTML,因此从理论上讲,我可以仅使用Pandoc将文件转换为这种markdown_phpextra格式(Pandoc会完美地做到这一点).

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).

但是,正如此SO问题中所述,我注意到我的段落在博客上似乎是错误的,因为wordpress.com转换为HTML时,实际上需要markdown-换行符,并且不会根据"markdown_phpextra"规范对段落进行重排/重新包装.

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.

例如,此markdown_phpextra文本

This is a sentence.
This is a another sentence.

应该成为

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

在HTML中,但实际上是由wordpress.com转换为

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

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

如何将markdown文件转换为与wordpress.com兼容的某种格式?

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

  • 是否可以使Pandoc在一行中导出每个段落?这样可以立即解决/解决我的问题.
  • 我可以使用Pandoc直接将其导出到wordpress.com-syntax-highlight-compatible HTML吗?当我使用Pandoc直接将其转换为HTML时,我看不到很多代码片段.

推荐答案

Pandoc有一个选项wrap:

Pandoc has an option wrap:

--wrap=auto | none | preserve

确定文本在输出中的换行方式(源 代码,而不是呈现的版本).使用auto(默认设置), pandoc将尝试将行换行为由指定的列宽 --columns(默认72).使用none,pandoc将不会自动换行 线.使用preserve,pandoc将尝试 保留源文档的包装(即, 在源中有非语义换行符的地方 也将是输出中的非语义换行符). 自动换行当前在HTML输出中不起作用.

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.

因此,用--wrap=none调用pandoc可以根据需要将段落放在一行中.

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

这篇关于如何将Pandoc markdown导出到与Worpress.com兼容的PHP Markdown Extra?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆