在RMarkdown/pander中定义自定义Markdown语法 [英] Defining custom Markdown syntax in RMarkdown / pander
问题描述
在Markdown/RMarkdown中,** this **转换为粗体,_this_是 cursive 等.
In Markdown / RMarkdown, **this** is translated to bold, _this_ is cursive etc.
是否可以创建自定义语法?例如,-this-(两个破折号之间的单词)被翻译成我自己定义的内容(通过html的css和pdf的乳胶)?
Is it possible to create a custom syntax? For example, that -this- (a word between two dashes) gets translated to something I define myself (via css for html and latex for pdf)?
推荐答案
文档解析由 pandoc 完成.对于这种自定义,必须自定义pandoc的Markdown阅读器(用Haskell编写),然后使用自编译的二进制文件进行编织.
Document parsing is done by pandoc. For this kind of customization, one would have to customize pandoc's Markdown reader (written in Haskell), and then use the self-compiled binary for knitting.
一种接近拥有自定义元素的方法是将spans([like so]{.example}
)或原始LaTeX(\foo{text}
)与支持\textcolor
用于HTML输出的答案.
One way to get close to having custom elements is to use spans ([like so]{.example}
) or raw LaTeX (\foo{text}
) in combination with Lua filters. You can then convert specific spans to any output you like. See, e.g., this answer about how to support \textcolor
for HTML output.
另请参阅John MacFarlane的这项漂亮的技术, Pandoc的作者.
See also this beautiful technique by John MacFarlane, the author of pandoc.
这篇关于在RMarkdown/pander中定义自定义Markdown语法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!