Skip to content

Why the DOM tree is such complicated? #3013

Answered by RunDevelopment
cyfung1031 asked this question in Q&A
Discussion options

You must be logged in to vote

The nested DOM tree is a byproduct of Prism's recursive highlighting algorithm. The DOM structure just reflects the language definitions (e.g. Markup tag is nested, so the DOM tree it produces also has that nesting).

This is also quite useful because the CSS themes have access to (simple) structural information about the code. This allows for very specific custom highlighting. You won't see this kind of highlighting with Prism's standard themes (they are all quite simple) but we have users that do that.

Regarding the lines: Many syntax highlighters are line-based (e.g. all TextMate-based syntax highlighters) but Prism is not. Prism highlights the whole text in one go. Splitting everything…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by cyfung1031
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants