Skip to content

Commit

Permalink
fix(viewer): Formulas with '&' symbol not rendereting
Browse files Browse the repository at this point in the history
Taskid 42230
  • Loading branch information
carla-at-wiris committed Jan 2, 2024
1 parent 3e1639c commit eee3bcd
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
4 changes: 4 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 4 additions & 2 deletions packages/viewer/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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('"&lt;"')
.split('">"')
.join('"&gt;"')
.split('><<')
.join('>&lt;<');
.join('>&lt;<')
.split('&')
.join('&amp;');

let result = '';
for (let i = 0; i < text.length; i++) {
Expand Down

0 comments on commit eee3bcd

Please sign in to comment.