7.4 Build and preview slides

You can knit the source document like other Rmd documents to view the output, but it may be tedious to have to knit it over and over again whenever you make changes. The other way to preview the slides is the RStudio addin “Infinite Moon Reader” or the function xaringan::inf_mr(), as mentioned in Section 2.2. With this way, you can continuously preview your slides just by saving the source document. The continuous preview is achieved via a local web server launched by the servr package (Xie 2019d).

One distinction of xaringan::moon_reader when compared to other R Markdown output formats is that it does not generate self-contained HTML documents by default (see Section 3.1.9). This means none of the external dependencies such as images or JavaScript libraries will be embedded in the HTML output file by default. Due to technical difficulties (remark.js does not use Pandoc but renders Markdown in real time in the browser), it is hard to implement the self-contained mode well. If you have to publish the slides to a web server, but it is not convenient for you to upload all the dependencies, xaringan may not be a good choice for you. If you use GitHub Pages or Netlify, this may not be a big problem (you commit or upload all files).


Xie, Yihui. 2019d. Servr: A Simple Http Server to Serve Static Files or Dynamic Documents. https://github.com/yihui/servr.