使用过滤器在pandoc中添加图元
我正在为python编写pandoc的过滤器。我正在使用pandocfilters。使用过滤器在pandoc中添加图元
我想用Figure[InlineEl1, InlineEl2]替换Para[Image]。
Figure不支持pandoc,所以我使用RawBlock来编写原始html。问题是我不知道InlineEl1和InlineEl2的html。我需要让pandoc处理它们。
可能的解决方法:使用Div,然后手工修改生成的html文件。
有没有更好的方法?
编辑:或者我可以把内联元素放在RawBlock?现在我只使用一个简单的字符串。我不知道是否有可能,因为我没有任何文件可用。我只是通过试验和错误进行。
回答:
从pandoc 2.0开始,AST中的数字表示形式为still somewhat adhoc。它只是一个段落,只包含一张图片,图片的title属性以fig:开头。
$ echo '' | pandoc -t native [Para [Image ("",[],[]) [Str "caption"] ("/url/of/image.png","fig:")]]
$ echo '' | pandoc -t html
<figure>
<img src="/url/of/image.png" alt="caption" />
<figcaption>caption</figcaption>
</figure>
见http://pandoc.org/MANUAL.html#extension-implicit_figures
以上是 使用过滤器在pandoc中添加图元 的全部内容, 来源链接: utcz.com/qa/258644.html

