/** * Create a `lowlight` instance. * * @param {Readonly> | null | undefined} [grammars] * Grammars to add (optional). * @returns * Lowlight. */ export function createLowlight(grammars?: Readonly> | null | undefined): { highlight: (language: string, value: string, options?: Readonly | null | undefined) => Root; highlightAuto: (value: string, options?: Readonly | null | undefined) => Root; listLanguages: () => Array; register: { /** * Register languages. * * @example * ```js * import {createLowlight} from 'lowlight' * import xml from 'highlight.js/lib/languages/xml' * * const lowlight = createLowlight() * * lowlight.register({xml}) * * // Note: `html` is an alias for `xml`. * console.log(lowlight.highlight('html', 'Emphasis')) * ``` * * Yields: * * ```js * {type: 'root', children: [Array], data: {language: 'html', relevance: 2}} * ``` * * @overload * @param {Readonly>} grammars * @returns {undefined} * * @overload * @param {string} name * @param {LanguageFn} grammar * @returns {undefined} * * @param {Readonly> | string} grammarsOrName * Grammars or programming language name. * @param {LanguageFn | undefined} [grammar] * Grammar, if with name. * @returns {undefined} * Nothing. */ (grammars: Readonly>): undefined; /** * Register languages. * * @example * ```js * import {createLowlight} from 'lowlight' * import xml from 'highlight.js/lib/languages/xml' * * const lowlight = createLowlight() * * lowlight.register({xml}) * * // Note: `html` is an alias for `xml`. * console.log(lowlight.highlight('html', 'Emphasis')) * ``` * * Yields: * * ```js * {type: 'root', children: [Array], data: {language: 'html', relevance: 2}} * ``` * * @overload * @param {Readonly>} grammars * @returns {undefined} * * @overload * @param {string} name * @param {LanguageFn} grammar * @returns {undefined} * * @param {Readonly> | string} grammarsOrName * Grammars or programming language name. * @param {LanguageFn | undefined} [grammar] * Grammar, if with name. * @returns {undefined} * Nothing. */ (name: string, grammar: LanguageFn): undefined; }; registerAlias: { /** * Register aliases. * * @example * ```js * import {createLowlight} from 'lowlight' * import markdown from 'highlight.js/lib/languages/markdown' * * const lowlight = createLowlight() * * lowlight.register({markdown}) * * // lowlight.highlight('mdown', 'Emphasis') * // ^ would throw: Error: Unknown language: `mdown` is not registered * * lowlight.registerAlias({markdown: ['mdown', 'mkdn', 'mdwn', 'ron']}) * lowlight.highlight('mdown', 'Emphasis') * // ^ Works! * ``` * * @overload * @param {Readonly | string>>} aliases * @returns {undefined} * * @overload * @param {string} language * @param {ReadonlyArray | string} alias * @returns {undefined} * * @param {Readonly | string>> | string} aliasesOrName * Map of programming language names to one or more aliases, or programming * language name. * @param {ReadonlyArray | string | undefined} [alias] * One or more aliases for the programming language, if with `name`. * @returns {undefined} * Nothing. */ (aliases: Readonly | string>>): undefined; /** * Register aliases. * * @example * ```js * import {createLowlight} from 'lowlight' * import markdown from 'highlight.js/lib/languages/markdown' * * const lowlight = createLowlight() * * lowlight.register({markdown}) * * // lowlight.highlight('mdown', 'Emphasis') * // ^ would throw: Error: Unknown language: `mdown` is not registered * * lowlight.registerAlias({markdown: ['mdown', 'mkdn', 'mdwn', 'ron']}) * lowlight.highlight('mdown', 'Emphasis') * // ^ Works! * ``` * * @overload * @param {Readonly | string>>} aliases * @returns {undefined} * * @overload * @param {string} language * @param {ReadonlyArray | string} alias * @returns {undefined} * * @param {Readonly | string>> | string} aliasesOrName * Map of programming language names to one or more aliases, or programming * language name. * @param {ReadonlyArray | string | undefined} [alias] * One or more aliases for the programming language, if with `name`. * @returns {undefined} * Nothing. */ (language: string, alias: ReadonlyArray | string): undefined; }; registered: (aliasOrName: string) => boolean; }; /** * Extra fields. */ export type ExtraOptions = { /** * List of allowed languages (default: all registered languages). */ subset?: ReadonlyArray | null | undefined; }; /** * Configuration for `highlight`. */ export type Options = { /** * Class prefix (default: `'hljs-'`). */ prefix?: string | null | undefined; }; /** * Configuration for `highlightAuto`. */ export type AutoOptions = Options & ExtraOptions; import type { LanguageFn } from 'highlight.js'; import type { Root } from 'hast'; //# sourceMappingURL=index.d.ts.map