From eee3bcd47732414ec32c6bc9d05f144d4dd8c81b Mon Sep 17 00:00:00 2001 From: carla-at-wiris Date: Fri, 22 Dec 2023 09:21:58 +0100 Subject: [PATCH] fix(viewer): Formulas with '&' symbol not rendereting Taskid 42230 --- CHANGES.md | 4 ++++ packages/viewer/src/utils.ts | 6 ++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index e15faaec2..0b84a08bd 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -15,6 +15,10 @@ Last release of this project is was 20th of December 2023. - feat: Add method that allows the integration forcing the hand mode. - feat(viewer): decode safe mathml +## Unreleased + + - fix(viewer): Formulas containing '&' symbol are not rendered. #KB-42230 + ### 8.7.3 2023-11-22 - fix(tinymce): non blur chemtype svg icon diff --git a/packages/viewer/src/utils.ts b/packages/viewer/src/utils.ts index c4a6ac136..5d479fdd8 100644 --- a/packages/viewer/src/utils.ts +++ b/packages/viewer/src/utils.ts @@ -21,12 +21,14 @@ function decodeEntities(text: string): string { export function htmlEntitiesToXmlEntities(text: string): string { text = decodeEntities(text); - // Replaces the < & > characters to its HTMLEntity to avoid render issues. + // Replaces the '<', '&', '>', and '"' characters to its HTMLEntity to avoid render issues. text = text.split('"<"').join('"<"') .split('">"') .join('">"') .split('><<') - .join('><<'); + .join('><<') + .split('&') + .join('&'); let result = ''; for (let i = 0; i < text.length; i++) {