stable

Clone or download

Read-only

Wrap syntax highlighting in a custom element

No visible changes for git (blob, tree), and artifact (text fields, comments). The only visible change is when you edit a follow-up comment, then the new version is syntax highlighted. This custom element <tlp-syntax-highlighting> use IntersectionObserver so that code blocks that never enter the viewport are not syntax highlighted. However, while this is true for follow-up comment edition, it is not true for the other case, since importing prismjs module automatically trigger a highlightAll() on the page. Luckily, highlighting seems to be idempotent. Part of request #20075: Syntax highlights fenced code blocks in artifacts Change-Id: Iec82510c15bcf8afaf358eabdc30932b75550ffc

Modified Files

Name
M plugins/git/templates/gitphp/tuleap/blob.tpl +6 −4 Go to diff View file
M src/common/Markdown/BlockRenderer/EnhancedCodeBlockRenderer.php +6 −0 Go to diff View file
M src/common/include/Codendi_HTMLPurifier.class.php +2 −1 Go to diff View file
M src/scripts/syntax-highlight/index.ts +4 −139 Go to diff View file
A src/scripts/syntax-highlight/syntax-highlight-element.test.ts +91 −0 Go to diff View file
R plugins/git/scripts/repository/file/syntax-highlight.ts Go to diff View file
M tests/unit/Tuleap/Markdown/BlockRenderer/EnhancedCodeBlockRendererTest.php +2 −2 Go to diff View file
M tests/unit/common/Include/Codendi_HTMLPurifierTest.php +25 −0 Go to diff View file