Creating tiny yet beautiful documents and vignettes from R Markdown. The package provides the 'html_pretty' output format as an alternative to the 'html_document' and 'html_vignette' engines that convert R Markdown into HTML pages. Various themes and syntax highlight styles are supported.
documents, like this page?
With the powerful rmarkdown package, we could easily create nice HTML document by adding some meta information in the header, for example
---title: Nineteen Years Laterauthor: Harry Potterdate: July 31, 2016output:rmarkdown::html_document:theme: lumen---
The html_document engine uses the Bootswatch theme library to support different styles of the document. This is a quick and easy way to tune the appearance of your document, yet with the price of a large file size (> 700KB) since the whole Bootstrap library needs to be packed in.
For package vignettes, we can use the
engine to generate a more lightweight HTML file that is meant to minimize the
package size, but the output HTML is less stylish than the
So can we do BOTH, a lightweight yet nice-looking theme for R Markdown?
The answer is YES! (At least towards that direction)
The prettydoc package provides an alternative engine,
to knit your R Markdown document into pretty HTML pages.
Its usage is extremely easy: simply replace the
rmarkdown::html_vignette output engine by
prettydoc::html_pretty in your R Markdown header, and use one of the built-in
themes and syntax highlighters. For example
---title: Nineteen Years Laterauthor: Harry Potterdate: July 31, 2016output:prettydoc::html_pretty:theme: caymanhighlight: github---
You can also create documents from prettydoc templates in RStudio.
Step 1: Click the "New File" button and choose "R Markdown".
Step 2: In the "From Template" tab, choose one of the built-in templates.
The options for the
html_pretty engine are mostly compatible with the default
(see the documentation)
with a few exceptions:
themeoption can take the following values. More themes will be added in the future.
highlightoption takes value from
toc_floatare not applicable.
Here are some screenshots of the HTML pages generated by prettydoc with different themes and syntax highlighters.