如何使用 YAML 块指定 pandoc 的降价扩展? [英] How can I specify pandoc's markdown extensions using a YAML block?

查看:33
本文介绍了如何使用 YAML 块指定 pandoc 的降价扩展?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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, and markdown-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?

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

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