From f6e715282a507c45387fdba3956c469ebaf03033 Mon Sep 17 00:00:00 2001 From: perry Date: Fri, 31 May 2019 14:15:23 -0500 Subject: [PATCH] fixing xml/html code example escaping --- site/scripts/markdown-renderer.js | 8 +++----- site/scripts/markdown-renderer.ts | 10 +++++----- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/site/scripts/markdown-renderer.js b/site/scripts/markdown-renderer.js index 8a57008393..cf36b63105 100644 --- a/site/scripts/markdown-renderer.js +++ b/site/scripts/markdown-renderer.js @@ -116,11 +116,6 @@ function collectHeadingMetadata(renderer, metadata) { exports.collectHeadingMetadata = collectHeadingMetadata; function changeCodeCreation(renderer) { function highlight(code, lang) { - if (lang === 'html' || lang === 'xml') { - code = code.replace(/&/g, "&") - .replace(//g, ">"); - } if (lang != null && languages.indexOf(lang) !== -1) { return prismjs_1.default.highlight(code, prismjs_1.default.languages[lang]); } @@ -138,6 +133,9 @@ function changeCodeCreation(renderer) { return line; }) .join('\n'); + if (['html', 'xml'].indexOf(lang) !== -1) { + lang = 'markup'; + } const out = highlight(code, lang); if (out != null) { escaped = true; diff --git a/site/scripts/markdown-renderer.ts b/site/scripts/markdown-renderer.ts index 3c6f4bd979..ebf24ef679 100644 --- a/site/scripts/markdown-renderer.ts +++ b/site/scripts/markdown-renderer.ts @@ -116,11 +116,6 @@ export function collectHeadingMetadata(renderer: marked.Renderer, metadata: Mark export function changeCodeCreation(renderer: marked.Renderer) { function highlight(code: string, lang?: string) { - if (lang === 'html' || lang === 'xml') { - code = code.replace(/&/g, "&") - .replace(//g, ">"); - } if (lang != null && languages.indexOf(lang) !== -1) { return Prism.highlight(code, Prism.languages[lang]); } @@ -139,6 +134,11 @@ export function changeCodeCreation(renderer: marked.Renderer) { return line; }) .join('\n'); + + // markup type gets escaped properly + if (['html','xml'].indexOf(lang) !== -1) { + lang = 'markup'; + } const out = highlight(code, lang);