pandoc 处理围栏代码块有问题吗?
Is there an issue with pandoc's handling of fenced code blocks?
我不知道我是否做错了什么(我对 markdown 不是很有经验)但是我有一个这样的 .md 文件:
Here is some code:
~~~bash
my_command arg1 arg2
~~~
我希望 pandoc 能够识别具有 github 语法的围栏代码块,所以我正在使用此命令:
pandoc -f markdown_github+fenced_code_blocks+fenced_code_attributes -t html -s
但是 pandoc 不识别代码块。这是我得到的输出:
Here is some code:
~bash
my_command arg1 arg2
~
如果我在代码块之前添加一个换行符,它会起作用:
Here is some code:
~~~bash
my_command arg1 arg2
~~~
正确的输出:
Here is some code:
my_command arg1 arg2
如果我尝试 GitHub 中的原始 .md 文件,它会按原样被识别。 pandoc 中是否有一些选项让我无法使我的原始 .md 正常工作?
Pandoc 的 fenced_code_blocks
扩展需要空行。来自 the manual:
Like regular code blocks, fenced code blocks must be separated from surrounding text by blank lines.
此外,pandoc中的github_markdown
reader并不是一个独立的reader(只有markdown and Common Mark readers): it is merely reading regular markdown with some default extensions,不同于常规的pandoc风味markdownreader.
也就是说,即使在github markdown 中编写,也必须遵守此规则。除了预处理文件以在编译前添加换行符外,我看不到解决它的方法。
我不知道我是否做错了什么(我对 markdown 不是很有经验)但是我有一个这样的 .md 文件:
Here is some code:
~~~bash
my_command arg1 arg2
~~~
我希望 pandoc 能够识别具有 github 语法的围栏代码块,所以我正在使用此命令:
pandoc -f markdown_github+fenced_code_blocks+fenced_code_attributes -t html -s
但是 pandoc 不识别代码块。这是我得到的输出:
Here is some code:
~bash~
my_command arg1 arg2
如果我在代码块之前添加一个换行符,它会起作用:
Here is some code:
~~~bash
my_command arg1 arg2
~~~
正确的输出:
Here is some code:
my_command arg1 arg2
如果我尝试 GitHub 中的原始 .md 文件,它会按原样被识别。 pandoc 中是否有一些选项让我无法使我的原始 .md 正常工作?
Pandoc 的 fenced_code_blocks
扩展需要空行。来自 the manual:
Like regular code blocks, fenced code blocks must be separated from surrounding text by blank lines.
此外,pandoc中的github_markdown
reader并不是一个独立的reader(只有markdown and Common Mark readers): it is merely reading regular markdown with some default extensions,不同于常规的pandoc风味markdownreader.
也就是说,即使在github markdown 中编写,也必须遵守此规则。除了预处理文件以在编译前添加换行符外,我看不到解决它的方法。