declare const _default$41: ShjLanguageDefinition; declare const _default$40: ShjLanguageDefinition; declare const _default$39: ShjLanguageDefinition; declare const _default$38: ShjLanguageDefinition; declare const _default$37: ShjLanguageDefinition; declare const _default$36: ShjLanguageDefinition; declare const _default$35: ShjLanguageDefinition; declare const _default$34: ShjLanguageDefinition; declare const _default$33: ShjLanguageDefinition; declare const _default$32: ShjLanguageDefinition; declare const _default$31: ShjLanguageDefinition; declare const _default$30: ShjLanguageDefinition; declare const _default$29: ShjLanguageDefinition; declare const _default$28: ShjLanguageDefinition; declare const definition$1: ShjLanguageDefinition; declare const _default$27: ShjLanguageDefinition; declare const _default$26: ShjLanguageDefinition; declare const _default$25: ShjLanguageDefinition; declare const _default$24: ShjLanguageDefinition; declare const _default$23: ShjLanguageDefinition; declare const _default$22: ShjLanguageDefinition; declare const _default$21: ShjLanguageDefinition; declare const _default$20: ShjLanguageDefinition; declare const _default$19: ShjLanguageDefinition; declare const _default$18: ShjLanguageDefinition; declare const definition: ShjLanguageDefinition; declare const _default$17: ShjLanguageDefinition; declare const _default$16: ShjLanguageDefinition; declare const _default$15: ShjLanguageDefinition; declare const _default$14: ShjLanguageDefinition; declare const _default$13: ShjLanguageDefinition; declare const _default$12: ShjLanguageDefinition; declare const _default$11: ShjLanguageDefinition; declare const _default$10: ShjLanguageDefinition; declare const _default$9: ShjLanguageDefinition; declare const _default$8: ShjLanguageDefinition; declare const _default$7: ShjLanguageDefinition; declare const _default$6: ShjLanguageDefinition; declare const _default$5: ShjLanguageDefinition; declare const _default$4: ShjLanguageDefinition; declare const _default$3: ShjLanguageDefinition; declare const _default$2: ShjLanguageDefinition; declare const _default$1: ShjLanguageDefinition; declare const _default: ShjLanguageDefinition; /** * The grammars that carry a `type` — the token type applied to whatever their * own rules leave unmatched — are the module shaped half of * {@link ShjLanguageModule}, and are exported already assembled so that they * drop into a registry like any other one. */ declare const js_template_literals: { default: ShjLanguageDefinition; type: number; }, /** @see {@link js_template_literals} */ jsdoc: { default: ShjLanguageDefinition; type: number; }, /** @see {@link js_template_literals} */ regex: { default: ShjLanguageDefinition; type: number; }, /** @see {@link js_template_literals} */ todo: { default: ShjLanguageDefinition; type: number; }; /** * The alternative names a bundled language answers to, keyed by the name it is * looked up under and holding the very grammar it stands for. * * They are spread into {@link languages}, so an alias is accepted anywhere a * language name is — the `lang` option, the `sub` of a grammar — and is a named * export of this entry like any other language: `yml` is the `yaml` grammar * itself, not a copy of it. * * Kept as a registry of its own so that the canonical name of a language stays * knowable: {@link ShjLanguage} is the languages, {@link ShjLanguageAlias} the * other names they may be asked for. */ declare const aliases: { cc: ShjLanguageDefinition; cjs: ShjLanguageDefinition; csharp: ShjLanguageDefinition; cts: ShjLanguageDefinition; cxx: ShjLanguageDefinition; dockerfile: ShjLanguageDefinition; golang: ShjLanguageDefinition; gql: ShjLanguageDefinition; h: ShjLanguageDefinition; hpp: ShjLanguageDefinition; htm: ShjLanguageDefinition; javascript: ShjLanguageDefinition; json5: ShjLanguageDefinition; jsonc: ShjLanguageDefinition; jsonl: ShjLanguageDefinition; kotlin: ShjLanguageDefinition; kts: ShjLanguageDefinition; makefile: ShjLanguageDefinition; markdown: ShjLanguageDefinition; mjs: ShjLanguageDefinition; mk: ShjLanguageDefinition; mts: ShjLanguageDefinition; ndjson: ShjLanguageDefinition; patch: ShjLanguageDefinition; perl: ShjLanguageDefinition; powershell: ShjLanguageDefinition; pwsh: ShjLanguageDefinition; python: ShjLanguageDefinition; ruby: ShjLanguageDefinition; rust: ShjLanguageDefinition; sh: ShjLanguageDefinition; shell: ShjLanguageDefinition; svg: ShjLanguageDefinition; text: ShjLanguageDefinition; txt: ShjLanguageDefinition; typescript: ShjLanguageDefinition; url: ShjLanguageDefinition; yml: ShjLanguageDefinition; zsh: ShjLanguageDefinition; }; /** * Every bundled language definition, keyed by language name. * * A language is its bare definition, the same shape a custom language passed as * the `languages` option may take. The few that also carry a `type` — the token * type applied to whatever their own rules leave unmatched — are given in * module shape instead, the other half of {@link ShjLanguageModule}. * * The {@link aliases} are in here too, under the alternative names they stand * for, so a lookup is a plain property read whichever name the caller used. * * This is what the main entry hands the engine, so importing it pulls every * grammar in — which is the whole point of that entry, and the opposite of what * `rangi/core` is for: there, import the ones you want by name. */ declare const languages: { cc: ShjLanguageDefinition; cjs: ShjLanguageDefinition; csharp: ShjLanguageDefinition; cts: ShjLanguageDefinition; cxx: ShjLanguageDefinition; dockerfile: ShjLanguageDefinition; golang: ShjLanguageDefinition; gql: ShjLanguageDefinition; h: ShjLanguageDefinition; hpp: ShjLanguageDefinition; htm: ShjLanguageDefinition; javascript: ShjLanguageDefinition; json5: ShjLanguageDefinition; jsonc: ShjLanguageDefinition; jsonl: ShjLanguageDefinition; kotlin: ShjLanguageDefinition; kts: ShjLanguageDefinition; makefile: ShjLanguageDefinition; markdown: ShjLanguageDefinition; mjs: ShjLanguageDefinition; mk: ShjLanguageDefinition; mts: ShjLanguageDefinition; ndjson: ShjLanguageDefinition; patch: ShjLanguageDefinition; perl: ShjLanguageDefinition; powershell: ShjLanguageDefinition; pwsh: ShjLanguageDefinition; python: ShjLanguageDefinition; ruby: ShjLanguageDefinition; rust: ShjLanguageDefinition; sh: ShjLanguageDefinition; shell: ShjLanguageDefinition; svg: ShjLanguageDefinition; text: ShjLanguageDefinition; txt: ShjLanguageDefinition; typescript: ShjLanguageDefinition; url: ShjLanguageDefinition; yml: ShjLanguageDefinition; zsh: ShjLanguageDefinition; asm: ShjLanguageDefinition; astro: ShjLanguageDefinition; bash: ShjLanguageDefinition; c: ShjLanguageDefinition; cpp: ShjLanguageDefinition; cs: ShjLanguageDefinition; css: ShjLanguageDefinition; csv: ShjLanguageDefinition; dart: ShjLanguageDefinition; diff: ShjLanguageDefinition; docker: ShjLanguageDefinition; go: ShjLanguageDefinition; graphql: ShjLanguageDefinition; html: ShjLanguageDefinition; http: ShjLanguageDefinition; ini: ShjLanguageDefinition; java: ShjLanguageDefinition; js: ShjLanguageDefinition; js_template_literals: { default: ShjLanguageDefinition; type: number; }; jsdoc: { default: ShjLanguageDefinition; type: number; }; json: ShjLanguageDefinition; jsx: ShjLanguageDefinition; kt: ShjLanguageDefinition; less: ShjLanguageDefinition; log: ShjLanguageDefinition; lua: ShjLanguageDefinition; make: ShjLanguageDefinition; md: ShjLanguageDefinition; php: ShjLanguageDefinition; pl: ShjLanguageDefinition; plain: ShjLanguageDefinition; ps1: ShjLanguageDefinition; py: ShjLanguageDefinition; rb: ShjLanguageDefinition; regex: { default: ShjLanguageDefinition; type: number; }; rs: ShjLanguageDefinition; scss: ShjLanguageDefinition; sql: ShjLanguageDefinition; svelte: ShjLanguageDefinition; swift: ShjLanguageDefinition; todo: { default: ShjLanguageDefinition; type: number; }; toml: ShjLanguageDefinition; ts: ShjLanguageDefinition; tsx: ShjLanguageDefinition; uri: ShjLanguageDefinition; vue: ShjLanguageDefinition; xml: ShjLanguageDefinition; yaml: ShjLanguageDefinition; }; /** * An alternative name a bundled language also answers to, derived from * {@link aliases} */ type ShjLanguageAlias = keyof typeof aliases; /** * Name of a bundled language, derived from {@link languages}. * * The fragment grammars are left out: they are reached only through the `sub` * of another language, never passed as the `lang` option. `js_template_literals` * belongs to `js`; `todo` is what marks `TODO`/`FIXME` up inside the comments of * every other grammar, which is the only place it is meant to be used. * * The aliases are left out too: they are names of the same languages, listed by * {@link ShjLanguageAlias}, and this is the one name per language — what a map * keyed by language is keyed by. */ type ShjLanguage = Exclude; /** * @module tokens * (The token types, by name and by index) * * A bundled grammar refers to a token type by its index rather than by its * name: the bundler inlines the constants below, so a rule spends one digit * where a quoted name would cost five to seven bytes — worth a few percent of * the bundle across the ~380 rules of the registry. * * Nothing outside the grammars ever sees an index. {@link TOKENS} maps back, * and the tokenizer resolves the name before it hands a token to a theme, a * callback or the caller — so a custom language is free to keep naming its * types, and may use one that is not on this list. */ /** Every token type, in the order the constants below number them */ declare const TOKENS: readonly ["deleted", "err", "var", "section", "kwd", "class", "cmnt", "insert", "type", "func", "bool", "num", "oper", "str", "esc", "bracket"]; /** * Token types * * The key a {@link ShjTheme} assigns a color to. */ type ShjToken = (typeof TOKENS)[number]; declare const theme$24: ShjTheme; declare const theme$23: ShjTheme; declare const theme$22: ShjTheme; declare const theme$21: ShjTheme; declare const theme$20: ShjTheme; declare const theme$19: ShjTheme; declare const theme$18: ShjTheme; declare const theme$17: ShjTheme; declare const theme$16: ShjTheme; declare const theme$15: ShjTheme; declare const theme$14: ShjTheme; declare const theme$13: ShjTheme; declare const theme$12: ShjTheme; declare const theme$11: ShjTheme; declare const theme$10: ShjTheme; declare const theme$9: ShjTheme; declare const theme$8: ShjTheme; declare const theme$7: ShjTheme; declare const theme$6: ShjTheme; declare const theme$5: ShjTheme; declare const theme$4: ShjTheme; declare const theme$3: ShjTheme; declare const theme$2: ShjTheme; declare const theme$1: ShjTheme; declare const theme: ShjTheme; /** * The two Geist themes as one light/dark pair * * Passed as the `theme` option, its colors are inlined with `light-dark()` and * follow the reader's color scheme, the way `defaultThemes` does. A pair * has no name of its own; the terminal, which has no scheme to follow, reads it * as {@link geistDark}. */ declare const geist: ShjThemePair; /** The two Catppuccin themes as one light/dark pair, {@link geist}-style */ declare const catppuccin: ShjThemePair; /** The two GitHub themes as one light/dark pair, {@link geist}-style */ declare const github: ShjThemePair; /** The two Gruvbox themes as one light/dark pair, {@link geist}-style */ declare const gruvbox: ShjThemePair; /** The two Solarized themes as one light/dark pair, {@link geist}-style */ declare const solarized: ShjThemePair; /** The two VS Code Modern themes as one light/dark pair, {@link geist}-style */ declare const vscodeModern: ShjThemePair; /** * Name of a bundled theme. * * All but `css-variables` are usable both in the browser and in the terminal: * its colors are custom properties, which a terminal cannot resolve, so it * comes out uncolored there. */ type ShjThemeName = "atom-dark" | "catppuccin-latte" | "catppuccin-mocha" | "css-variables" | "dark" | "default" | "dracula" | "geist-dark" | "geist-light" | "github-dark" | "github-dim" | "github-light" | "gruvbox-dark" | "gruvbox-light" | "monokai" | "night-owl" | "nord" | "one-light" | "solarized-dark" | "solarized-light" | "tokyo-night" | "vesper" | "visual-studio-dark" | "vscode-dark-modern" | "vscode-light-modern"; /** * A theme is plain data: colors keyed by token type. * * The highlighter inlines it as `style` attributes, the terminal adaptor turns * it into ANSI escape sequences. */ interface ShjTheme { /** Unique name */ name: string; /** Used for the `color-scheme` CSS property */ scheme?: "light" | "dark"; /** Background color of the code block */ bg: string; /** Default text color of the code block */ fg: string; /** Color of the line numbers (defaults to the `cmnt` token color) */ numbers?: string; /** Color of each token type */ tokens: Partial>; } /** * A light and a dark theme, applied with `prefers-color-scheme` */ interface ShjThemePair { light: ShjTheme; dark: ShjTheme; } /** * The options every entry point shares: what to highlight, and with which * grammar. */ interface ShjTokenizeOptions { /** * The language of the code * * An alias of a bundled language — `yml`, `mjs`, `python` — names the same * grammar as the language itself does. Any name of * {@link ShjTokenizeOptions.languages} is accepted as well. * * @default "plain" */ lang?: ShjLanguage | ShjLanguageAlias | (string & {}); /** * Custom languages, keyed by language name * * They are looked up before the bundled ones, so a bundled language can be * overridden, and are used for sub-languages too. * * @example * codeToHtml(code, { lang: "mine", languages: { mine: myLanguage } }); */ languages?: ShjLanguages; } /** * A single piece of tokenized code, as returned by `tokenize` */ interface ShjTokenized { /** * The raw text of the token, unescaped and never empty * * It may span line breaks — a block comment or a template literal is one * token however many lines it covers. */ text: string; /** * The type of the token, and the key a {@link ShjTheme} assigns a color to * * Absent for text that no rule of the language matched. */ type?: ShjToken; } interface ShjOptions extends ShjTokenizeOptions { /** * The theme, inlined in the generated markup as `style` attributes * * A light/dark pair is inlined as `light-dark()` colors, following the color * scheme of the reader. * * @default the bundled themes, import any other one from `rangi/themes` */ theme?: ShjTheme | ShjThemePair; /** * Emit class names instead of inline styles * * The markup then carries no `style` attribute at all: the block is * `shj shj-lang- shj-`, each typed token is a `shj-` span, * and a multiline block wraps its gutter and its code in `shj-scroll` and * `shj-code`. Nothing is styled until you supply a stylesheet — including * `white-space:pre`, without which the code collapses. * * {@link ShjOptions.theme} is unused in this mode. To keep the styles inline * and only move the colors out, leave this off and pass the `cssVariables` * theme instead. * * @default false */ classes?: boolean; /** * Render the code as an inline `` element instead of a block * * A block is `multiline` when the code contains a line break, `oneline` * otherwise. * * @default false */ inline?: boolean; /** * Indicates whether to number the lines of a multiline code * * @default true */ lineNumbers?: boolean; } interface ShjTerminalOptions extends ShjTokenizeOptions { /** * The theme, emitted as 24 bit escape sequences * * A light/dark pair is read as its dark theme. * * @default the bundled themes */ theme?: ShjTheme | ShjThemePair; } /** * The same options as {@link ShjTokenizeOptions}, as `rangi/core` takes them * * That entry bundles nothing, so what the main entry defaults to is given * explicitly instead: `languages: {}` is a call that highlights nothing. */ type ShjCoreTokenizeOptions = ShjTokenizeOptions & Required>; /** * The same options as {@link ShjOptions}, as `rangi/core` takes them: the * languages and the theme are required, since none is bundled * * `classes: true` renders no color at all, so it takes the place of the theme * rather than being passed alongside one. */ type ShjCoreOptions = ShjOptions & Required> & ({ classes: true; } | Required>); /** * The same options as {@link ShjTerminalOptions}, as `rangi/core` takes * them: the languages and the theme are required, since none is bundled */ type ShjCoreTerminalOptions = ShjTerminalOptions & Required>; /** * * `inline` inside `code` element * * `oneline` inside `div` element and containing only one line * * `multiline` inside `div` element */ type ShjDisplayMode = "inline" | "oneline" | "multiline"; /** * A token type as a grammar refers to it: the index of a bundled type in * `TOKENS`, which is what the bundled grammars use, or its name — which is * what a custom language will usually reach for */ type ShjTokenRef = number | ShjToken | (string & {}); /** * What the rule engine asks of a pattern: it drives `lastIndex` itself and * calls `exec`, which is all it ever uses a `RegExp` for * * A grammar may hand over anything that behaves that way. `js_template_literals` * does, to balance the braces of a `${…}` interpolation — which a regular * expression cannot do. */ interface ShjMatcher { lastIndex: number; exec(str: string): { index: number; 0: string; } | null; } /** * A single rule of a grammar, as a tuple * * The positions are `[match, type, sub]`, and the trailing ones are optional — * a rule with a `sub` but no `type` of its own leaves a hole: `[/…/g, , "js"]`. * The tuple form is what keeps the bundled grammars small: property names * cannot be minified, tuple positions cost nothing. * * * `match` — the pattern, which must carry the `g` flag if it is a regex * * `type` — the token type the match is emitted as * * `sub` — highlight the match with another language instead: a language name, * an inline definition, or a callback returning either a language name or an * anonymous {@link ShjSubLanguage} */ type ShjLanguageComponent = [match: RegExp | ShjMatcher, type?: ShjTokenRef, sub?: string | ShjLanguageDefinition | ((code: string) => string | ShjSubLanguage)]; /** * What a `sub` callback may return besides a language name: an anonymous * language, with the token type applied to whatever its rules leave unmatched * * It is the same tuple as a rule, with the `match` position left empty. */ type ShjSubLanguage = [match: undefined, type: ShjTokenRef | undefined, sub: ShjLanguageDefinition]; type ShjLanguageDefinition = ShjLanguageComponent[]; /** * A language, either as a bare definition or in module shape, so that * `import * as mine from "./mine.ts"` can be handed over as is * * The optional `type` is the token type applied to whatever the rules of the * language leave unmatched. */ type ShjLanguageModule = ShjLanguageDefinition | { default: ShjLanguageDefinition; type?: ShjTokenRef; }; /** * Language definitions keyed by language name */ type ShjLanguages = Record; export { ShjCoreOptions, ShjCoreTerminalOptions, ShjCoreTokenizeOptions, ShjDisplayMode, ShjLanguage, ShjLanguageAlias, ShjLanguageComponent, ShjLanguageDefinition, ShjLanguageModule, ShjLanguages, ShjMatcher, ShjOptions, ShjSubLanguage, ShjTerminalOptions, ShjTheme, ShjThemeName, ShjThemePair, ShjToken, ShjTokenRef, ShjTokenizeOptions, ShjTokenized, _default, _default$1, _default$10, _default$11, _default$12, _default$13, _default$14, _default$15, _default$16, _default$17, _default$18, _default$19, _default$2, _default$20, _default$21, _default$22, _default$23, _default$24, _default$25, _default$26, _default$27, _default$28, _default$29, _default$3, _default$30, _default$31, _default$32, _default$33, _default$34, _default$35, _default$36, _default$37, _default$38, _default$39, _default$4, _default$40, _default$41, _default$5, _default$6, _default$7, _default$8, _default$9, aliases, catppuccin, definition, definition$1, geist, github, gruvbox, js_template_literals, jsdoc, languages, regex, solarized, theme, theme$1, theme$10, theme$11, theme$12, theme$13, theme$14, theme$15, theme$16, theme$17, theme$18, theme$19, theme$2, theme$20, theme$21, theme$22, theme$23, theme$24, theme$3, theme$4, theme$5, theme$6, theme$7, theme$8, theme$9, todo, vscodeModern };