0

I used a custom CSS style for my R markdown HTML output. I expected the output to simply insert the CSS file contents in the head of the HTML file, but the CSS was modified.

For example, the CSS embedded some external fonts with @import url(...) and those were embedded directly into the document with data URIs (src: url(data:font/ttf;base64,...). Similar behavior applies to external JavaScript files. Something like Google Analytics is transformed from a few lines that load an external script to embedding the whole script on a page. I may be satisfied with the behavior (no external dependencies in the HTML file), but maybe I wanted to keep my file as small as possible.

The closest to an explanation can be found in the bookdown book, where it says: "to provide all of the styles for the document from your own CSS you set the theme (and potentially highlight) to null". My theme and highlight are set to null.

Is there a way to control how the CSS gets parsed?

1 Answer 1

2

I think what you're seeing there is the result of html_document's self_contained option (or whatever other HTML output format you're using), so to disable it you would do:

output: 
  html_document:
    self_contained: no
Sign up to request clarification or add additional context in comments.

1 Comment

That is perfect. This option is mentioned in the rmarkdown::html_document documentation, but it was not clear to me what it did based on that description.

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.