【问题标题】:Manually knitting an Rmd file produces different results when the file is located at different place当文件位于不同的位置时,手动编织 Rmd 文件会产生不同的结果
【发布时间】:2021-11-09 05:21:14
【问题描述】:

在写博文时,我经常手动编织文档来检查结果,并且输出曾经是正常的html_document。但是,在最近的更新之后,在 blogdown 目录下手动编织文档不再产生 html_document 输出。相反,它会在乳胶公式和图形无法正确显示的情况下产生如下内容(以 Rmd 文件的默认内容为例):

这是 RStudio 中“R Markdown”控制台的输出:

/usr/lib/rstudio/bin/pandoc/pandoc +RTS -K512m -RTS 1.knit.md 
--to html4 
--from markdown+autolink_bare_uris+tex_math_single_backslash 
--output 1.html~ 
--lua-filter /usr/local/lib/R/site-library/bookdown/rmarkdown/lua/custom-environment.lua 
--lua-filter /usr/local/lib/R/site-library/rmarkdown/rmarkdown/lua/pagebreak.lua 
--lua-filter /usr/local/lib/R/site-library/rmarkdown/rmarkdown/lua/latex-div.lua 
--wrap preserve -M link-citations=true 
--standalone 
--section-divs 
--template /usr/local/lib/R/site-library/blogdown/resources/template-minimal.html 
--no-highlight 
--include-in-header /tmp/RtmphBPBhs/rmarkdown-str73fd791178f2.html 
--mathjax

如果我在 blogdown 目录之外编写相同的文档,则结果输出如预期:

“R Markdown”控制台的输出是:

/usr/lib/rstudio/bin/pandoc/pandoc +RTS -K512m -RTS 1.knit.md 
--to html4 
--from markdown+autolink_bare_uris+tex_math_single_backslash 
--output 1.html 
--lua-filter /usr/local/lib/R/site-library/rmarkdown/rmarkdown/lua/pagebreak.lua 
--lua-filter /usr/local/lib/R/site-library/rmarkdown/rmarkdown/lua/latex-div.lua 
--self-contained 
--variable bs3=TRUE 
--standalone 
--section-divs 
--template /usr/local/lib/R/site-library/rmarkdown/rmd/h/default.html 
--no-highlight 
--variable highlightjs=1 
--variable theme=bootstrap 
--include-in-header /tmp/RtmpXfya1w/rmarkdown-str724a4171c407.html 
--mathjax 
--variable 'mathjax-url:https://mathjax.rstudio.com/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML

当我单击 RStudio 中的“编织”按钮时会发生什么?如何调整行为,以便在 blogdown 目录中编织文档时生成 html_output 文件?

【问题讨论】:

    标签: r r-markdown rstudio blogdown


    【解决方案1】:

    第一个 .Rmd 可能只是一个简单的 YAML 语法错误,请确保您在任何地方都没有任何提取空格。甚至可以发布您正在使用的代码。

    what happens when we renderdifferent build methods for blogdown

    Note that the minimum requirement for any R Markdown website is that it have an index.Rmd file as well as a _site.yml file. If you execute the rmarkdown::render_site() function from within the directory containing the website, the following will occur

    根据我的经验,我使用了一些不同的命令来帮助在 blogdown 中渲染单个 .Rmd 文件,然后您必须运行其他命令来渲染整个 blogdown 网站,以便所有内容都能正确地渲染到各自的目录中。

    blogdown::serve_site() 将呈现 blogdown 目录中的所有内容并允许将其托管给网站

    rmarkdown::render() 在您编织时运行,但我认为您也可以使用它渲染单个文件。

    rmarkdown::render_site() 这会渲染整个网站

    您必须更具体地查看每个功能,看看是否对您的问题有任何帮助,我已经过了一分钟,因为我编辑了我的 Blogdown 网站。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-11-26
      • 1970-01-01
      • 2014-11-06
      • 1970-01-01
      • 1970-01-01
      • 2011-10-31
      • 1970-01-01
      • 2011-12-26
      相关资源
      最近更新 更多