![]() Using both of the above options will actually embed the css directly into the HTML output that is produced, making the output larger in size. # path-to-r-script.Rmd, with desired options Knitr::spin("path-to-r-script.R", knit = FALSE) The below example will embed styles present in path_to_custom.css into the resulting HTML: # Creates the intermediate path-to-r-script.Rmd This allows us to provide additional arguments extensions, stylesheet, header, template and encoding in the second step, instead of relying on the changed options to be passed as defaults. ![]() ![]() Rmd file with the desired options directly specified as arguments Rmd file via spin(), using spin(., knit = FALSE) The method that could be considered more proper is to actually split the production of the final output into 2 steps: The method above works but can seem quite workaround-ish. To use a custom css stylesheet instead of the one provided by default with the markdown package: options( = "path_to_custom.css") For a somewhat minimalistic HTML output still keeping images self-contained, we can do: options( If we want to keep the spinning in one step, we can simply update those options before calling spin (and ideally change them back afterwards). # "/usr/local/lib/R/site-library/markdown/resources/markdown.css" # "space_headers" "superscript" "latex_math" # "autolink" "strikethrough" "lax_spacing" # "no_intra_emphasis" "tables" "fenced_code" # "use_xhtml" "smartypants" "base64_images" "mathjax" Let’s have a look at some interesting default options’ values: library(markdown) Some of the interesting arguments are by default selected in the following way: options = getOption(""),Įxtensions = getOption("markdown.extensions") Changing the options that govern the default values and just call spin() as beforeĪs mentioned above, spin() does not expose the arguments of markdownToHTML() directly, so what happens in practice is that the default values for those arguments are used when spin() is called.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |