import { LiteAdaptor } from "@mathjax/src/js/adaptors/liteAdaptor.js"; import { TeX } from "@mathjax/src/js/input/tex.js"; import { CHTML } from "@mathjax/src/js/output/chtml.js"; import { SVG } from "@mathjax/src/js/output/svg.js"; import { MarkdownItTexOptions } from "@mdit/plugin-tex"; import { LiteElement } from "@mathjax/src/js/adaptors/lite/Element.js"; import { MathDocument } from "@mathjax/src/js/core/MathDocument.js"; import { MathItem } from "@mathjax/src/js/core/MathItem.js"; import { MmlNode } from "@mathjax/src/js/core/MmlTree/MmlNode.js"; import TexError from "@mathjax/src/js/input/tex/TexError.js"; import { ChtmlFontData } from "@mathjax/src/js/output/chtml/FontData.js"; import { ChtmlWrapperFactory } from "@mathjax/src/js/output/chtml/WrapperFactory.js"; import { LinebreakVisitor } from "@mathjax/src/js/output/common/LinebreakVisitor.js"; import { SvgFontData } from "@mathjax/src/js/output/svg/FontData.js"; import { SvgWrapperFactory } from "@mathjax/src/js/output/svg/WrapperFactory.js"; import { CssStyles } from "@mathjax/src/js/ui/menu/mj-context-menu.js"; import { MarkdownIt } from "markdown-it"; //#region src/mathjax.d.ts type TexPackage = "action" | "ams" | "amscd" | "bbm" | "bboldx" | "bbox" | "begingroup" | "boldsymbol" | "braket" | "bussproofs" | "cancel" | "cases" | "centernot" | "color" | "colortbl" | "colorv2" | "configmacros" | "dsfont" | "empheq" | "enclose" | "extpfeil" | "gensymb" | "html" | "mathtools" | "mhchem" | "newcommand" | "noerrors" | "noundefined" | "physics" | "setoptions" | "tagformat" | "texhtml" | "textcomp" | "textmacros" | "unicode" | "units" | "upgreek" | "verb"; interface MathJaxTexInputOptions { /** * Extensions to use * * @default [ * 'action', * 'ams', * 'amscd', * 'bbm', * 'bboldx', * 'bbox', * 'begingroup', * 'boldsymbol', * 'braket', * 'bussproofs', * 'cancel', * 'cases', * 'centernot', * 'color', * 'colortbl', * 'colorv2', * 'configmacros', * 'dsfont', * 'empheq', * 'enclose', * 'extpfeil', * 'gensymb', * 'html', * 'mathtools', * 'mhchem', * 'newcommand', * 'noerrors', * 'noundefined', * 'physics', * 'require', * 'setoptions', * 'tagformat', * 'texhtml', * 'textcomp', * 'textmacros', * 'unicode', * 'units', * 'upgreek', * 'verb', * ] */ packages?: TexPackage[]; /** * Pattern for recognizing numbers * * @default /^(?:[0-9]+(?:\{,\}[0-9]{3})_(?:\.[0-9]_)?|\.[0-9]+)/ */ digits?: RegExp; tags?: "ams" | "all" | "none"; /** Side for `\tag` macros */ tagSide?: "left" | "right"; /** * Amount to indent tags * * @default "0.8em" */ tagIndent?: "0.8em"; /** * Use label name rather than tag for ids * * @default true; */ useLabelIds?: boolean; /** * Maximum number of macro substitutions per expression * * @default 1000 */ maxMacros?: number; /** * Maximum size for the internal TeX string (in bytes) * * @default 5120 */ maxBuffer?: number; formatError?: (jax: TeX, error: typeof TexError) => MmlNode; } /** Data passed to MathJax filters */ interface MathjaxFilterData { math: MathItem; document: MathDocument; data: any; } /** MathJax filter function */ type MathjaxFilter = (data: MathjaxFilterData) => void; /** @see https://docs.mathjax.org/en/latest/options/output/index.html#option-descriptions */ interface MathjaxCommonOutputOptions { /** * Global scaling factor for all expressions * * @default 1 */ scale?: number; /** * Smallest scaling factor to use * * @default 0.5 */ minScale?: number; /** * Make mtext elements use surrounding font * * @default false */ mtextInheritFont?: boolean; /** * Make merror text use surrounding font * * @default true */ merrorInheritFont?: boolean; /** * Font to use for mtext, if not inheriting (empty means use MathJax fonts) * * @default "" */ mtextFont?: string; /** * Font to use for merror, if not inheriting (empty means use MathJax fonts) * * @default "serif" */ merrorFont?: string; /** * Font to use for character that aren’t in MathJax's fonts * * @default "serif" */ unknownFamily?: string; /** * - `true` for MathML spacing rules * - `false` for TeX rules * * @default false */ mathmlSpacing?: boolean; /** RFDa and other attributes NOT to copy to the output */ skipAttributes?: Record; /** * Default size of ex in em units * * @default 0.5 */ exFactor?: number; /** * Default for indentalign when set to 'auto' * * @default "center" */ displayAlign?: "left" | "center" | "right"; /** * Default for indentshift when set to 'auto' * * @default 0 */ displayIndent?: string; /** * Default for overflow * * @default "overflow" */ displayOverflow?: "scroll" | "scale" | "truncate" | "elide" | "linebreak" | "overflow"; /** Options for when overflow is linebreak */ linebreaks?: { /** * True for browser-based breaking of inline equations * * @default true */ inline?: boolean; /** * A fixed size or a percentage of the container width * * @default "100%" */ width?: string; /** * The default lineleading in em units * * @default 0.2 */ lineleading?: number; /** For developers only */ LinebreakVisitor?: typeof LinebreakVisitor; }; /** * The font component to load * * @default "" */ font?: string; /** * The path to the font definitions * * @default "https://cdn.jsdelivr.net/npm/@mathjax/mathjax-newcm-font/" */ fontPath?: string; /** * The font extensions to load * * @default [ ] */ fontExtensions?: string[]; /** * 'use', 'force', or 'ignore' data-mjx-hdw attributes * * @default "auto" */ htmlHDW?: "use" | "force" | "ignore"; /** * A list of pre-filters to add to the output jax * * @default [ ] */ preFilters?: MathjaxFilter[]; /** * A list of post-filters to add to the output jax * * @default [ ] */ postFilters?: MathjaxFilter[]; /** For developers only */ cssStyles?: typeof CssStyles; } interface MathjaxCommonHTMLOutputOptions extends MathjaxCommonOutputOptions { /** * Whether match ex-height of surrounding font * * @default true */ matchFontHeight?: boolean; /** * Font data to use * * @default font data from `@mathjax/mathjax-newcm-font` */ fontData?: typeof ChtmlFontData; /** * The URL where the fonts are found * * @default jsdelivr CDN links for `@mathjax/mathjax-newcm-font` */ fontURL?: string; /** * Location where MathJax should look for font data that has to be loaded dynamically. * * @default jsdelivr CDN links for `@mathjax/mathjax-newcm-font` */ dynamicPrefix?: string; /** * Whether only produce CSS that is used in the processed equations * * @default true */ adaptiveCSS?: boolean; /** For developers only */ wrapperFactory?: typeof ChtmlWrapperFactory; } interface MathjaxSVGOutputOptions extends MathjaxCommonOutputOptions { /** * Stroke-width to use for SVG character paths in units that are 1/1000 of an em * * @default 3 */ blacker?: number; /** * @default "local" * @see https://docs.mathjax.org/en/latest/options/output/svg.html#option-descriptions */ fontCache?: "local" | "global" | "none"; /** * Font data to use * * @default font data from `@mathjax/mathjax-newcm-font` */ fontData?: typeof SvgFontData; /** * Whether the xlink namespace should be included in the href attributes or not * * @default true */ useXlink?: boolean; /** ID to use for local font cache (for single equation processing) */ localID?: string | null; /** For developers only */ wrapperFactory?: typeof SvgWrapperFactory; } //#endregion //#region src/options.d.ts type TeXTransformer = (content: string, displayMode: boolean) => string; interface MarkdownItMathjaxOptions extends Pick { /** * Output syntax * * 输出格式 * * @default "svg" */ output?: "chtml" | "svg"; /** * Enable A11y * * 是否启用无障碍 * * @default true */ a11y?: boolean; /** * TeX input options * * TeX 输入选项 */ tex?: MathJaxTexInputOptions; /** * Common HTML output options * * 通用 HTML 输出选项 */ chtml?: MathjaxCommonHTMLOutputOptions; /** * SVG output options * * SVG 输出选项 */ svg?: MathjaxSVGOutputOptions; /** * Transformer on output content * * 输出内容的转换器 */ transformer?: TeXTransformer; /** * Enable debug mode * * 启用调试模式 * * @default false */ debug?: boolean; } interface DocumentOptions { InputJax: TeX; OutputJax: CHTML | SVG; enableAssistiveMml: boolean; } /** Mathjax instance common options */ interface MathjaxInstance extends Required> { /** Mathjax adaptor */ adaptor: LiteAdaptor; /** Mathjax document options */ documentOptions: DocumentOptions; /** * Output style for rendered content and clears it * * @returns Style */ outputStyle: () => Sync extends true ? string : Promise; /** Reset tex (including labels) */ reset: () => void; /** Clear style cache */ clearStyle: () => void; /** Output content transformer */ transformer: TeXTransformer | null; } //#endregion //#region src/plugin.d.ts declare const getDocumentOptions: (options: MarkdownItMathjaxOptions) => Promise; declare const createMathjaxInstance: (options?: MarkdownItMathjaxOptions) => Promise; declare const mathjax: (md: MarkdownIt, { allowInlineWithSpace, adaptor, delimiters, documentOptions, mathFence, reset, transformer }: MathjaxInstance) => void; //#endregion export { type DocumentOptions, type MarkdownItMathjaxOptions, type MathJaxTexInputOptions, type MathjaxCommonHTMLOutputOptions, type MathjaxCommonOutputOptions, type MathjaxFilter, type MathjaxFilterData, type MathjaxInstance, type MathjaxSVGOutputOptions, type TeXTransformer, type TexPackage, createMathjaxInstance, getDocumentOptions, mathjax }; //# sourceMappingURL=index.d.ts.map