TLDR · PROGRAMMING, DESIGN & DATA SCIENCE
HIGH-PERFORMANCE SYNTAX HIGHLIGHTING WITH CSS HIGHLIGHTS API
Summary from the TLDR newsletter
The CSS Custom Highlight API lets developers style arbitrary text ranges without modifying the DOM structure. Developers just have to define 'Range' objects that point to a specific character position in text nodes, group them by style type, and register them with the browser's highlight registry. The API is supported in all modern browsers. This post provides an example implementation of syntax highlighting using the CSS Highlights API.