From 2237ae209e8ae769d7b62768d081447272911562 Mon Sep 17 00:00:00 2001 From: jguillen-at-wiris Date: Wed, 29 Oct 2025 17:22:16 +0100 Subject: [PATCH 1/2] fix(viewer): improve namespaced MathML element detection --- packages/viewer/src/mathml.ts | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/packages/viewer/src/mathml.ts b/packages/viewer/src/mathml.ts index a9195409d..e92717c39 100644 --- a/packages/viewer/src/mathml.ts +++ b/packages/viewer/src/mathml.ts @@ -77,7 +77,15 @@ export async function renderMathML(properties: Properties, root: HTMLElement): P decodeSafeMathML(root, properties.ignored_containers); - for (const mathElement of [...root.getElementsByTagName("math")]) { + // Fixed to get all possible math elements, including namespaced ones. + const allMathElements = [ + ...root.getElementsByTagName("math"), // Standard + ...root.getElementsByTagNameNS("*", "math"), // Any valid namespaced math + ...root.querySelectorAll("m\\:math"), // CSS: (literal colon) + ...root.querySelectorAll("mml\\:math"), // CSS: (literal colon) + ]; + + for (const mathElement of allMathElements) { const mml = serializeHtmlToXml(mathElement.outerHTML); try { let imgSource; From f727a26c8954eababdf1fae6fcfb3181039a9a50 Mon Sep 17 00:00:00 2001 From: jguillen-at-wiris Date: Wed, 29 Oct 2025 17:27:43 +0100 Subject: [PATCH 2/2] chore: linter fixes --- packages/viewer/src/mathml.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/viewer/src/mathml.ts b/packages/viewer/src/mathml.ts index e92717c39..8cf0a0693 100644 --- a/packages/viewer/src/mathml.ts +++ b/packages/viewer/src/mathml.ts @@ -79,10 +79,10 @@ export async function renderMathML(properties: Properties, root: HTMLElement): P // Fixed to get all possible math elements, including namespaced ones. const allMathElements = [ - ...root.getElementsByTagName("math"), // Standard - ...root.getElementsByTagNameNS("*", "math"), // Any valid namespaced math - ...root.querySelectorAll("m\\:math"), // CSS: (literal colon) - ...root.querySelectorAll("mml\\:math"), // CSS: (literal colon) + ...root.getElementsByTagName("math"), // Standard + ...root.getElementsByTagNameNS("*", "math"), // Any valid namespaced math + ...root.querySelectorAll("m\\:math"), // CSS: (literal colon) + ...root.querySelectorAll("mml\\:math"), // CSS: (literal colon) ]; for (const mathElement of allMathElements) {