generated from nhcarrigan/template
fix: escape raw HTML in markdown renderer (#169)
Prevents HTML tags from being rendered as live DOM elements in terminal output. Overrides the marked codespan and html renderers to escape < and > before inserting into the output HTML.
This commit is contained in:
@@ -35,7 +35,12 @@
|
||||
};
|
||||
|
||||
renderer.codespan = ({ text }) => {
|
||||
return `<code class="hljs-inline">${text}</code>`;
|
||||
const escaped = text.replace(/</g, "<").replace(/>/g, ">");
|
||||
return `<code class="hljs-inline">${escaped}</code>`;
|
||||
};
|
||||
|
||||
renderer.html = ({ text }) => {
|
||||
return text.replace(/</g, "<").replace(/>/g, ">");
|
||||
};
|
||||
|
||||
marked.setOptions({
|
||||
|
||||
Reference in New Issue
Block a user