Skip to content

Commit

Permalink
fix code highlighting
Browse files Browse the repository at this point in the history
  • Loading branch information
Hasan Özbey committed Jul 22, 2022
1 parent ec828bb commit 307891b
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 3 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
### 1.0.5

- **Fix** code highlighting breaks when you interact with the page.

### 1.0.4

Requires Flarum v1.2.0+
Expand Down
2 changes: 1 addition & 1 deletion js/dist/forum.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion js/dist/forum.js.map

Large diffs are not rendered by default.

7 changes: 6 additions & 1 deletion js/src/forum/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,12 @@ app.initializers.add(

// using `c.innerText` destroys line breaks
// using `c.innerHTML` introduces security concerns
codeNodeList.forEach((c) => (c.textContent = replaceDelimiters(c.textContent, true)));
codeNodeList.forEach((c) => {
// don't break code highlighting
if (c.classList.contains('hljs')) return;

c.textContent = replaceDelimiters(c.textContent, true);
});
};

/**
Expand Down

0 comments on commit 307891b

Please sign in to comment.