highlightjs / highlightjs/highlight.js

Rethink sublanguages

Open
#1,263 1 comment 0 reactions 1 assignee Claimed by @joshgoebel View on GitHub
parser
Dominant language
JavaScript
Stars
25k
Forks
3.8k
Avg merge
11h 35m
Merged PRs (30d)
3

Description

There are many subtly different ways of embedding one syntax into another:
- The host language clearly defines boundaries, between which we can use a completely independent highlighting process. It's the case with `..` in HTML.
- The host language defines boundaries, but the closing boundary can only happen at the top level of the sublanguage. This the case of PHP in HTML, where `?>` inside a PHP comment wouldn't end the sublanguage.
- The sublanguage ends when it parses out a single top-level mode. This is the case of JSX.

Current implementation of `subLanguage` only works for the first case. And the `skip` attribute only fixes a few common cases.

Current idea is to implement sublanguages as sub-parsers embedded in the host parser tree.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.