highlight-pending.ts#
3 documented symbols. Read the signatures first, then expand each item for parameters, return types, and examples.
Reference#
modulehighlight-pendingHighlighting the blocks the native pass could not claim. These arrive already named — the native pass reports each one'…
Highlighting the blocks the native pass could not claim.
These arrive already named — the native pass reports each one's language — which lets this load exactly the grammars a page needs instead of the whole bundled set, and splice each result back without an HTML parser.
fnhighlightPendingBlocks(blocks: readonly { language: string; source: string }[], theme: string | ThemeRegistration = CSS_VARIABLES_THEME, langs: LanguageRegistration[] = []): Promise<string[]>Highlight the blocks the native pass left pending, in order. Entry i of the res…
Highlight the blocks the native pass left pending, in order.
Entry i of the result is the <pre> for block i, or an empty string when Shiki has no grammar for it either — in which case the block is left exactly as it arrived, the same outcome the tree walk reached by keeping the original element.
This is the whole point of the pending list: a page whose only unsupported block is a Mermaid diagram used to be handed to the tree walk in full, which re-highlighted every one of its other blocks and paid for a parse and a serialize of the page to do it.
Signature
export async function highlightPendingBlocks(blocks: readonly { language: string; source: string }[], theme: string | ThemeRegistration = CSS_VARIABLES_THEME, langs: LanguageRegistration[] = []): Promise<string[]>Parameters
-
blocksreadonly { language: string; source: string }[] -
themestring | ThemeRegistrationoptional · default: CSSVARIABLESTHEME
-
langsLanguageRegistration[]optional · default: []
Returns
Promise<string[]>
variableconst lazyHighlighterCache = new Map<string, Promise<Highlighter>>()A highlighter that starts with no grammars and gains them on demand. getHighlig…
A highlighter that starts with no grammars and gains them on demand.
getHighlighter loads all two dozen BUILTIN_LANGS up front, because the tree walk it serves discovers a page's languages only while rewriting it. The pending list does not have that problem — it names every language it needs — and paying for two dozen TextMate grammars to highlight one Vue block is most of what a page with an exotic block costs.
Signature
const lazyHighlighterCache = new Map<string, Promise<Highlighter>>()