Vendor reveal.js 5.2.1 (from 5.1.0)
Contains the upstream 5.2.x feature set, most notably the lightbox
(data-preview-image/data-preview-video opens media full-size in an
overlay), controls: "speaker-only", search API extensions and
speaker-view fixes. The package's local additions are carried over
unchanged: IDS theme (ids.css/ids.scss), extra theme fonts,
chalkboard/customcontrols/menu plugins, and the 1280x720 default
slide size (patched in js/config.js and the dist bundles).
Also fixes a pre-existing fork bug (unrelated to the upgrade): the
slidechanged Highcharts resize hook in default.html now checks that
Highcharts exists, no longer throwing in decks without highcharter.
Docs: README (Rmd + rendered md) gained a short Lightbox section,
NEWS.md notes the library bump.
Verified: examples/ids.html and examples/simple.html re-render and run
error-free through all 13/5 slides (Reveal.VERSION = 5.2.1); lightbox
opens on click and closes with Esc in a dedicated test deck.
Change-Id: I0751129dfb0c9d20b56241377905876314a26011
diff --git a/inst/reveal.js-5.2.1/plugin/math/katex.js b/inst/reveal.js-5.2.1/plugin/math/katex.js
new file mode 100755
index 0000000..2cddafc
--- /dev/null
+++ b/inst/reveal.js-5.2.1/plugin/math/katex.js
@@ -0,0 +1,96 @@
+/**
+ * A plugin which enables rendering of math equations inside
+ * of reveal.js slides. Essentially a thin wrapper for KaTeX.
+ *
+ * @author Hakim El Hattab
+ * @author Gerhard Burger
+ */
+export const KaTeX = () => {
+ let deck;
+
+ let defaultOptions = {
+ version: 'latest',
+ delimiters: [
+ {left: '$$', right: '$$', display: true}, // Note: $$ has to come before $
+ {left: '$', right: '$', display: false},
+ {left: '\\(', right: '\\)', display: false},
+ {left: '\\[', right: '\\]', display: true}
+ ],
+ ignoredTags: ['script', 'noscript', 'style', 'textarea', 'pre', 'code']
+ }
+
+ const loadCss = src => {
+ let link = document.createElement('link');
+ link.rel = 'stylesheet';
+ link.href = src;
+ document.head.appendChild(link);
+ };
+
+ /**
+ * Loads a JavaScript file and returns a Promise for when it is loaded
+ * Credits: https://aaronsmith.online/easily-load-an-external-script-using-javascript/
+ */
+ const loadScript = src => {
+ return new Promise((resolve, reject) => {
+ const script = document.createElement('script')
+ script.type = 'text/javascript'
+ script.onload = resolve
+ script.onerror = reject
+ script.src = src
+ document.head.append(script)
+ })
+ };
+
+ async function loadScripts(urls) {
+ for(const url of urls) {
+ await loadScript(url);
+ }
+ }
+
+ return {
+ id: 'katex',
+
+ init: function (reveal) {
+
+ deck = reveal;
+
+ let revealOptions = deck.getConfig().katex || {};
+
+ let options = {...defaultOptions, ...revealOptions};
+ const {local, version, extensions, ...katexOptions} = options;
+
+ let baseUrl = options.local || 'https://cdn.jsdelivr.net/npm/katex';
+ let versionString = options.local ? '' : '@' + options.version;
+
+ let cssUrl = baseUrl + versionString + '/dist/katex.min.css';
+ let katexUrl = baseUrl + versionString + '/dist/katex.min.js';
+ let mhchemUrl = baseUrl + versionString + '/dist/contrib/mhchem.min.js'
+ let karUrl = baseUrl + versionString + '/dist/contrib/auto-render.min.js';
+
+ let katexScripts = [katexUrl];
+ if(options.extensions && options.extensions.includes("mhchem")) {
+ katexScripts.push(mhchemUrl);
+ }
+ katexScripts.push(karUrl);
+
+ const renderMath = () => {
+ renderMathInElement(reveal.getSlidesElement(), katexOptions);
+ deck.layout();
+ }
+
+ loadCss(cssUrl);
+
+ // For some reason dynamically loading with defer attribute doesn't result in the expected behavior, the below code does
+ loadScripts(katexScripts).then(() => {
+ if( deck.isReady() ) {
+ renderMath();
+ }
+ else {
+ deck.on( 'ready', renderMath.bind( this ) );
+ }
+ });
+
+ }
+ }
+
+};