gpt4 book ai didi

html - 如何在输出中没有 javascript 的情况下从 RMarkdown 呈现 HTML

转载 作者:太空狗 更新时间:2023-10-29 13:26:40 24 4
gpt4 key购买 nike

即使是最简单的 rmarkdown 文档在呈现时似乎也会创建一个包含 javascript 的 html 文档。我正在寻找创建可以作为电子邮件正文的 html。有没有一种方法可以在生成的 html 中不使用 javascript 来呈现 Markdown ?

下面没有什么特别的,只是一个通用的例子:

---
title: "Sample"
author: "JKGrain"
date: "March 31, 2015"
output: html_document
---

This is an R Markdown document. Markdown is a simple formatting syntax for authoring HTML, PDF, and MS Word documents. For more details on using R Markdown see <http://rmarkdown.rstudio.com>.

When you click the **Knit** button a document will be generated that includes both content as well as the output of any embedded R code chunks within the document. You can embed an R code chunk like this:

```{r}
summary(cars)
```

You can also embed plots, for example:

```{r, echo=FALSE}
plot(cars)
```

Note that the `echo = FALSE` parameter was added to the code chunk to prevent printing of the R code that generated the plot.

生成的 html 源代码是这样开始的:

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

<meta charset="utf-8">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="generator" content="pandoc" />

<meta name="author" content="JKGrain" />

<meta name="date" content="2015-03-31" />

<title>Sample</title>

<script src="data:application/x-javascript,%2F%2A%21%20jQuery%20v1%2E11.....

显然,我已经剪掉了其余的 html,但希望这能解释问题。

最佳答案

默认 html 输出格式中的 javascript 来自主题、语法高亮和方程式的 mathjax。您可以像这样在 header 中禁用这三样东西:

---
output:
html_document:
theme: null
highlight: null
mathjax: null
---

关于html - 如何在输出中没有 javascript 的情况下从 RMarkdown 呈现 HTML,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29370306/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com