我需要同时渲染一个.qmd
文件到gfm(.md
)和.html
,但是当我渲染.html
文件时,夸托删除了现有的.md
。有什么方法可以同时保持这两种格式吗?
夸托网站似乎表明这是可能的:https://quarto.org/docs/get-started/authoring/rstudio.html#rendering,但我在让它工作时遇到了麻烦。
这是我的档案:
format_test.qmd
---
title: "format_test"
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
到目前为止我尝试过的:
1.在RStudio中点击Render:
- 生成一个带有
gfm
标签的.html
文件。但是,单击gfm
标签会导致一个空白页面,其中包含“未找到”。Screenshot of HTML render
我的工作目录有一个format_test.html
文件,但没有format_test.md
文件:
list.files()
[1] "format_test_files" "format_test.html" "format_test.qmd"
[4] "format_test.Rproj"
2.终端渲染:结果同上。
quarto render format_test.qmd --to gfm,html
processing file: format_test.qmd
output file: format_test.knit.md
pandoc
to: html
output-file: format_test.html
standalone: true
section-divs: true
html-math-method: mathjax
wrap: none
default-image-extension: png
metadata
document-css: false
link-citations: true
date-format: long
lang: en
title: format_test
processing file: format_test.qmd
output file: format_test.knit.md
pandoc
to: >-
commonmark+autolink_bare_uris+emoji+footnotes+gfm_auto_identifiers+pipe_tables+strikeout+task_lists+tex_math_dollars
output-file: format_test.md
standalone: true
default-image-extension: png
toc: true
number-sections: true
metadata
title: format_test
list.files()
[1] "format_test_files" "format_test.html" "format_test.qmd"
[4] "format_test.Rproj"
3.单独渲染:夸托删除.md
文件并将其替换为.html
这个命令给了我一个format_test.md
文件:
quarto render format_test.qmd --to gfm
processing file: format_test.qmd
output file: format_test.knit.md
pandoc
to: \>-
commonmark+autolink_bare_uris+emoji+footnotes+gfm_auto_identifiers+pipe_tables+strikeout+task_lists+tex_math_dollars
output-file: format_test.md
standalone: true
default-image-extension: png
toc: true
number-sections: true
metadata
title: format_test
Output created: format_test.md
ls
format_test.Rproj format_test.md format_test.qmd
运行此命令将删除format_test.md
,并将其替换为format_test.html
。
quarto render format_test.qmd --to html
processing file: format_test.qmd
output file: format_test.knit.md
pandoc
to: html
output-file: format_test.html
standalone: true
section-divs: true
html-math-method: mathjax
wrap: none
default-image-extension: png
metadata
document-css: false
link-citations: true
date-format: long
lang: en
title: format_test
Output created: format_test.html
ls
format_test.Rproj format_test.qmd
format_test.html format_test_files
sessionInfo:
R version 4.2.2 (2022-10-31)
Platform: aarch64-apple-darwin20 (64-bit)
Running under: macOS Ventura 13.1
Matrix products: default
LAPACK: /Library/Frameworks/R.framework/Versions/4.2-arm64/Resources/lib/libRlapack.dylib
locale:
\[1\] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
attached base packages:
\[1\] stats graphics grDevices utils datasets methods base
loaded via a namespace (and not attached):
\[1\] compiler_4.2.2 tools_4.2.2 rstudioapi_0.14 knitr_1.42
\[5\] xfun_0.37
夸托版本:
[✓] Checking versions of quarto binary dependencies...
Pandoc version 3.1.1: OK
Dart Sass version 1.55.0: OK
[✓] Checking versions of quarto dependencies......OK
[✓] Checking Quarto installation......OK
Version: 1.3.340
Path: /Applications/quarto/bin
2条答案
按热度按时间6jjcrrmo1#
如果您想在渲染到
html
时获取底层的markdown文件,只需使用选项keep-md: true
,现在有一个原因可以解释为什么在
quarto render format_test.qmd --to gfm,html
命令执行结束后没有得到markdown文件。夸托实际上首先生成format_test.md
文件,然后继续渲染到html。在生成html输出后,它删除了markdown文件。因此,请尝试以下命令,而不是首先指定
html
,然后指定gfm
,但如果您不想关心格式顺序,请使用专门针对
html
的keep-md: true
,如下所示:然后运行下面的任意一个命令都会生成html和markdown文件
或
lztngnrs2#
编辑文件的顶部,使其看起来像这样:
这在execution options文档中有介绍。