如何使用 Quarto 模拟编织两种格式?

duf*_*fei 11 r-markdown quarto

是否可以通过在 YAML 标头中指定来一次从 Quarto/R Markdown 文档创建多种输出格式?

我的猜测没有成功:

---
title: Stacked Area chart with Annotations
format: 
  - html
  - gfm
---
Run Code Online (Sandbox Code Playgroud)

sha*_*fee 14

尝试这种方式(假设文件名是format_test.qmd

格式测试.qmd

---
title: "Untitled"
format:
  html: default
  gfm: default
---

## Quarto

Quarto enables you to weave together content and executable code
into a finished document. To learn more about Quarto 
see <https://quarto.org>.

## Running Code

When you click the **Render** button a document will 
be generated that includes both content and the output 
of embedded code. You can embed code like this:

```{r}
1 + 1
```

Run Code Online (Sandbox Code Playgroud)

然后从控制台运行以下代码,立即生成 html 和 github 风格的 markdown (gfm) 文件。

---
title: "Untitled"
format:
  html: default
  gfm: default
---

## Quarto

Quarto enables you to weave together content and executable code
into a finished document. To learn more about Quarto 
see <https://quarto.org>.

## Running Code

When you click the **Render** button a document will 
be generated that includes both content and the output 
of embedded code. You can embed code like this:

```{r}
1 + 1
```

Run Code Online (Sandbox Code Playgroud)

或者,如果您更喜欢使用终端(或者如果您不是 R 用户),您可以在终端中运行以下命令,

quarto render format_test.qmd --to html,gfm
Run Code Online (Sandbox Code Playgroud)

请小心指定多种格式,不要在它们之间添加任何空格,即将它们键入为html,gfm.

在终端中运行上述命令不需要您format在文档中指定 yaml 选项。因此对于

格式测试.qmd

---
title: "Untitled"
---

## Quarto

Quarto enables you to weave together content and executable code
into a finished document. To learn more about Quarto 
see <https://quarto.org>.
Run Code Online (Sandbox Code Playgroud)
quarto render format_test.qmd --to pdf,html,gfm
Run Code Online (Sandbox Code Playgroud)

将生成 HTML、pdf 和 markdown 格式的三个文件。

  • 四开本没有这样的针织钩@EmmanuelTeitelbaum (2认同)