Skip to content

Commit 2b355c9

Browse files
authoredJan 29, 2021
Markdown: Workaround for incorrect highlighting due to double wrap hook (#2719)
The hook that highlights code blocks in markdown code was unable to handle code blocks that were highlighted already. The hook can now handle any existing markup in markdown code blocks.
1 parent 30b0444 commit 2b355c9

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed
 

‎components/prism-markdown.js

+4-2
Original file line numberDiff line numberDiff line change
@@ -347,8 +347,10 @@
347347
});
348348
}
349349
} else {
350-
// reverse Prism.util.encode
351-
var code = env.content.replace(/&lt;/g, '<').replace(/&amp;/g, '&');
350+
// get the textContent of the given env HTML
351+
var tempContainer = document.createElement('div');
352+
tempContainer.innerHTML = env.content;
353+
var code = tempContainer.textContent;
352354

353355
env.content = Prism.highlight(code, grammar, codeLang);
354356
}

‎components/prism-markdown.min.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)