import type { ElementNode, ElementNodeAttributes, Node, MarkdownDocument } from 'comark' import type { ShjLanguage, ShjLanguages, ShjTheme, ShjThemePair, ShjToken, ShjTokenized } from 'rangi' import { tokenize } from 'rangi' import { languages as rangiBuiltinLanguages } from 'rangi/languages' import { dark as defaultDark, defaultTheme } from 'rangi/themes' import { defineComarkPlugin } from 'comark' import { visitAsync } from 'comark/utils' import { comarkLanguages } from './language-comark.ts' // Only highlighters detect inline-code languages, so this lives here instead of // in `comark`. `@comark/plugin-shiki` and `@comark/plugin-pierre-highlights` // carry equivalent copies that must stay in sync with this one. /** * Fragment languages: a name authors write in `{lang="..."}` mapped onto a real * grammar plus source that seeds the grammar state and is then discarded. * Named after the `@nuxtjs/mdc` conventions so `ts-type` and `vue-html` keep * working for sites migrating off it. */ const GRAMMAR_CONTEXTS = new Map([ ['ts-type', { lang: 'typescript', grammarContextCode: 'let a:' }], ['vue-html', { lang: 'vue', grammarContextCode: '