如何使用 YAML 块指定 pandoc 的降价扩展? [英] How can I specify pandoc's markdown extensions using a YAML block?
问题描述
Pandoc 的 markdown 让您可以指定扩展,以了解您希望如何处理您的 markdown:
Pandoc's markdown lets you specify extensions for how you would like your markdown to be handled:
可以通过将 +EXTENSION
或 -EXTENSION
附加到格式名称来单独启用或禁用 Markdown 语法扩展.因此,例如,markdown_strict+footnotes+definition_lists
是启用了脚注和定义列表的严格降价,而 markdown-pipe_tables+hard_line_breaks
是 pandoc 没有管道表和硬线的降价休息.
Markdown syntax extensions can be individually enabled or disabled by appending
+EXTENSION
or-EXTENSION
to the format name. So, for example,markdown_strict+footnotes+definition_lists
is strict markdown with footnotes and definition lists enabled, andmarkdown-pipe_tables+hard_line_breaks
is pandoc’s markdown without pipe tables and with hard line breaks.
我的具体问题
对于给定的 pandoc 转换,例如,我在源代码中使用 网格表:
pandoc myReport.md --from markdown+pipe_tables --to latex -o myReport.pdf
我怎样才能写一个 pandoc YAML 块来完成同样的事情(指定我的源包含网格表?)
How can I write a pandoc YAML block to accomplish the same thing (specifying that my source contains grid tables?)
如何使用 pandoc YAML 打开和关闭扩展?
How can I turn extensions on and off using pandoc YAML?
- 我可以使用 YAML 设置命令行参数吗元数据 - 这个处理如何指定输出选项,但我试图告诉 pandoc 我的输入结构
- 我可以使用 YAML 标头选项控制什么pandoc? - 回答者提到 pandoc 的模板,但 latex 输出 模板和 markdown 模板 表示任何类型的
grid_tables
的选项.因此,从这些答案中我不清楚了解模板将如何帮助我弄清楚如何构建我的 YAML.
- Can I set command line arguments using the YAML metadata - This one deals with how to specify output options, but I'm trying to tell pandoc about the structure of my input
- What can I control with YAML header options in pandoc? - Answerers mention pandoc's templates, but neither the latex output template nor the markdown template indicate any sort of option for
grid_tables
. So, it's not clear to me from these answers how knowing about the templates will help me figure out how to structure my YAML.
pandoc 始终有可能并非旨在让您在 YAML 中指定这些扩展.不过,我希望是这样.
It's always possible that pandoc isn't designed to let you specify those extensions in the YAML. Although, I'm hoping it is.
推荐答案
您可以使用 Markdown Variants 在 Rmarkdown 文档中执行此操作.本质上,您将扩展输入到 .Rmd
文件开头的 YAML
标头块中的 variant
选项中.
You can use Markdown Variants to do this in an Rmarkdown document. Essentially, you enter your extensions into a variant
option in the YAML
header block at the start of the your .Rmd
file.
例如,要使用网格表,您的 YAML
标头块中有这样的内容:
For example, to use grid tables, you have something like this in your YAML
header block:
---
title: "Habits"
author: John Doe
date: March 22, 2005
output: md_document
variant: markdown+grid_tables
---
然后您可以直接在 pandoc
中编译成 PDF,方法是在命令行中键入如下内容:
Then you can compile to a PDF directly in pandoc
by typing in your command line something like:
pandoc yourfile.md -o yourfile.pdf
有关 RStudio 中的降价变体的更多信息:http://rmarkdown.rstudio.com/markdown_document_format.html#markdown_variants
For more information on markdown variants in RStudio: http://rmarkdown.rstudio.com/markdown_document_format.html#markdown_variants
有关 RStudio 中 markdown/Rmarkdown 中 Pandoc 扩展的更多信息:http://rmarkdown.rstudio.com/authoring_pandoc_markdown.html#pandoc_markdown
For more information on Pandoc extensions in markdown/Rmarkdown in RStudio: http://rmarkdown.rstudio.com/authoring_pandoc_markdown.html#pandoc_markdown
这篇关于如何使用 YAML 块指定 pandoc 的降价扩展?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!