12

Even the simplest rmarkdown document when rendered seems to create an html document that includes javascript. I am looking to create html that can be the body of an email. Is there a way to render markdown with no javascript in the resulting html?

There is nothing special about the following, it is just a generic example:

---
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.

The resulting html source begins like this:

<!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.....

Obviously, i have clipped the rest of the html, but hopefully this explains the issue.

0

1 Answer 1

18

The javascript in the default html output format comes from the theme, syntax highlighting, and mathjax for equations. You can disable these three things in the header like so:

---
output: 
    html_document:
        theme: null
        highlight: null
        mathjax: null
---
Sign up to request clarification or add additional context in comments.

2 Comments

to help others who might have this same question, I will point out that indentation and the placement of colons is very unforgiving in the YAML. If your options are not working as expected check those.
Thank you for this. 715KB down to sub 1KB. Given that I just wanted the R output to be generated (going into wordpress) this is perfect.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.