From 15656b03ce743461dadc5d093f5347a57f50fa61 Mon Sep 17 00:00:00 2001 From: Alexandre Vryghem Date: Fri, 21 Jul 2023 23:18:40 +0200 Subject: [PATCH] Fix mathjax code being displayed twice This was due to sanitizeHtml rendering the mjx-assistive-mml tag as text. This tag is used by screen readers and therefor we should allow it to be rendered --- src/app/shared/utils/markdown.pipe.ts | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/app/shared/utils/markdown.pipe.ts b/src/app/shared/utils/markdown.pipe.ts index e494a826138..90b6d25731a 100644 --- a/src/app/shared/utils/markdown.pipe.ts +++ b/src/app/shared/utils/markdown.pipe.ts @@ -67,7 +67,9 @@ export class MarkdownPipe implements PipeTransform { // sanitize-html doesn't let through SVG by default, so we extend its allowlists to cover MathJax SVG allowedTags: [ ...sanitizeHtml.defaults.allowedTags, - 'mjx-container', 'svg', 'g', 'path', 'rect', 'text' + 'mjx-container', 'svg', 'g', 'path', 'rect', 'text', + // Also let the mjx-assistive-mml tag (and it's children) through (for screen readers) + 'mjx-assistive-mml', 'math', 'mrow', 'mi', ], allowedAttributes: { ...sanitizeHtml.defaults.allowedAttributes, @@ -88,7 +90,16 @@ export class MarkdownPipe implements PipeTransform { ], text: [ 'transform', 'font-size' - ] + ], + 'mjx-assistive-mml': [ + 'unselectable', 'display', 'style', + ], + math: [ + 'xmlns', + ], + mrow: [ + 'data-mjx-texclass', + ], }, parser: { lowerCaseAttributeNames: false,