在RMarkdown/pander中定义自定义Markdown语法 [英] Defining custom Markdown syntax in RMarkdown / pander

查看:382
本文介绍了在RMarkdown/pander中定义自定义Markdown语法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在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屋!

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