R markdown CSS/JS 解析
R markdown CSS/JS parsing
我为我的 R markdown HTML 输出使用了自定义 CSS 样式。我希望输出只是将 CSS 文件内容插入 HTML 文件的头部,但是 CSS 被修改了。
例如,CSS 使用 @import url(...)
嵌入了一些外部字体,而那些使用数据 URI (src: url(data:font/ttf;base64,...
) 直接嵌入到文档中。类似的行为适用于外部 JavaScript 文件。 Google Analytics 之类的东西从加载外部脚本的几行代码转换为将整个脚本嵌入到页面上。我可能对这种行为感到满意(HTML 文件中没有外部依赖项),但也许我想让我的文件尽可能小。
最接近的解释可以在 bookdown book 中找到,它说:"to provide all of the styles for the document from your own CSS you set the theme
(and potentially highlight
) to null
"。我的 theme
和 highlight
设置为 null
.
有没有办法控制 CSS 的解析方式?
我认为您所看到的是 html_document
的 self_contained
选项(或您正在使用的任何其他 HTML 输出格式)的结果,因此禁用你会这样做:
output:
html_document:
self_contained: no
我为我的 R markdown HTML 输出使用了自定义 CSS 样式。我希望输出只是将 CSS 文件内容插入 HTML 文件的头部,但是 CSS 被修改了。
例如,CSS 使用 @import url(...)
嵌入了一些外部字体,而那些使用数据 URI (src: url(data:font/ttf;base64,...
) 直接嵌入到文档中。类似的行为适用于外部 JavaScript 文件。 Google Analytics 之类的东西从加载外部脚本的几行代码转换为将整个脚本嵌入到页面上。我可能对这种行为感到满意(HTML 文件中没有外部依赖项),但也许我想让我的文件尽可能小。
最接近的解释可以在 bookdown book 中找到,它说:"to provide all of the styles for the document from your own CSS you set the theme
(and potentially highlight
) to null
"。我的 theme
和 highlight
设置为 null
.
有没有办法控制 CSS 的解析方式?
我认为您所看到的是 html_document
的 self_contained
选项(或您正在使用的任何其他 HTML 输出格式)的结果,因此禁用你会这样做:
output:
html_document:
self_contained: no