自动编织时失去 R-Markdown 头衔

Losing R-Markdown title when automating knitting

我正在尝试自动创建一堆 Rmd 文件,这些文件我一直使用 R-Studio 手动编排 - 使用编辑 Rmd 文件时启用的 "Knit HTML" 按钮。但是,如果我从脚本中使用 knit2html 命令,它会丢失标题。这显然是设计使然 post:

但是它没有解释 R-Studio 如何设法在其生成的 html 文件中生成标题 - 这一定是可能的,对吧?我一直在尝试这个 test.Rmd R-markdown.

---
title: "My Title"
author: "Joe Programmer"
date: "Thursday, 10 June 2015"
output: html_document
---

Just read the instructions.

当我使用下面的编织 HTML 按钮时得到这个

但是当我使用 knit2html()

从控制台编织时

如何让我的代码像 R-Studio 那样工作?

RStudio 回答 here. You can see the template they use at this gist,如果您查看 markdown 生成窗格,您会看到最终进行了一个邪恶的长 pandoc 调用:

/usr/local/bin/pandoc forso.utf8.md 
  --to html 
  --from markdown+autolink_bare_uris+ascii_identifiers+tex_math_single_backslash-implicit_figures 
  --output forso.html 
  --smart 
  --email-obfuscation none 
  --self-contained 
  --standalone 
  --section-divs 
  --template /Library/Frameworks/R.framework/Versions/3.2/Resources/library/rmarkdown/rmd/h/default.html 
  --variable 'theme:bootstrap' 
  --include-in-header /var/folders/2d/r3dsy9j17lqcctq5k0hmmg040000gn/T//RtmptThd32/rmarkdown-str16cec488b85bd.html 
  --mathjax --variable 'mathjax-url:https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML' 
  --no-highlight 
  --variable highlightjs=/Library/Frameworks/R.framework/Versions/3.2/Resources/library/rmarkdown/rmd/h/highlight 

在您自己的系统上深入研究类似的输出,看看您还需要将什么传递给您自己的自定义渲染器以获得所需的输出。