@farberg/reveal-template 1.1.16 → 1.1.17

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@farberg/reveal-template",
3
- "version": "1.1.16",
3
+ "version": "1.1.17",
4
4
  "homepage": "https://github.com/pfisterer/reveal-template",
5
5
  "description": "Reveal.js template for Dennis' lectures",
6
6
  "main": "index.js",
@@ -80,6 +80,17 @@ export default () => {
80
80
  ignoreUnescapedHTML: true
81
81
  });
82
82
 
83
+ // highlightOnLoad is false (to avoid double-highlighting external code snippets
84
+ // loaded below). Manually highlight all inline markdown code blocks here.
85
+ // The reveal.js markdown plugin sets class="mermaid" (no "language-" prefix) for
86
+ // mermaid fences. RevealMermaid already rendered those elements before the ready
87
+ // event fired, so we must skip them — otherwise hljs reads the SVG innerHTML as
88
+ // code text and overwrites the rendered diagram.
89
+ for (let el of deck.getRevealElement().querySelectorAll("pre code[class]")) {
90
+ if (!el.classList.contains("mermaid")) {
91
+ highlightPlugin.hljs.highlightElement(el);
92
+ }
93
+ }
83
94
 
84
95
  for (let el of deck.getRevealElement().querySelectorAll("a[data-code]")) {
85
96
  //console.log(`Loading code snippets, looking at`, el)
@@ -122,7 +133,7 @@ export default () => {
122
133
 
123
134
  const newEl = showCode(el, language, code, showLink ? url : null, outdent)
124
135
  if (language !== 'mermaid')
125
- highlightPlugin.hljs.highlightElement(newEl)
136
+ highlightPlugin.hljs.highlightElement(newEl.querySelector('code') ?? newEl)
126
137
  } catch (err) {
127
138
  console.error(`show-code-snippets: failed to load ${url}:`, err)
128
139
  showError(el, `Failed to load ${url}: ${err.message}`)