diff --git a/packages/app-cli/tests/md_to_html/sanitize_12.html b/packages/app-cli/tests/md_to_html/sanitize_12.html new file mode 100644 index 000000000..c8a5e8c24 --- /dev/null +++ b/packages/app-cli/tests/md_to_html/sanitize_12.html @@ -0,0 +1 @@ +
ts
ts
diff --git a/packages/app-cli/tests/md_to_html/sanitize_12.md b/packages/app-cli/tests/md_to_html/sanitize_12.md new file mode 100644 index 000000000..22f71bb68 --- /dev/null +++ b/packages/app-cli/tests/md_to_html/sanitize_12.md @@ -0,0 +1,3 @@ +```"> +ts +``` diff --git a/packages/renderer/MdToHtml.ts b/packages/renderer/MdToHtml.ts index 333c0e7cd..1e57d6993 100644 --- a/packages/renderer/MdToHtml.ts +++ b/packages/renderer/MdToHtml.ts @@ -8,6 +8,8 @@ import { RenderResult, RenderResultPluginAsset } from './MarkupToHtml'; import { Options as NoteStyleOptions } from './noteStyle'; import hljs from './highlight'; +const Entities = require('html-entities').AllHtmlEntities; +const htmlentities = new Entities().encode; const MarkdownIt = require('markdown-it'); const md5 = require('md5'); @@ -482,7 +484,7 @@ export default class MdToHtml { // The strings includes the last \n that is part of the fence, // so we remove it because we need the exact code in the source block const trimmedStr = this.removeLastNewLine(str); - const sourceBlockHtml = `
${markdownIt.utils.escapeHtml(trimmedStr)}
`; + const sourceBlockHtml = `
${markdownIt.utils.escapeHtml(trimmedStr)}
`; if (this.shouldSkipHighlighting(trimmedStr, lang)) { outputCodeHtml = markdownIt.utils.escapeHtml(trimmedStr);