mathpix-markdown-it
Version:
Mathpix-markdown-it is an open source implementation of the mathpix-markdown spec written in Typescript. It relies on the following open source libraries: MathJax v3 (to render math with SVGs), markdown-it (for standard Markdown parsing)
23 lines (22 loc) • 1.21 kB
TypeScript
export declare const isNewlineChar: (ch: string | null) => boolean;
export declare const findPlaceholders: (s: string, from?: number) => RegExpMatchArray | null;
export declare const placeholderToId: (placeholder: string) => string;
export declare const getPrevNonSpaceChar: (s: string, idx: number) => string | null;
export declare const getNextNonSpaceChar: (s: string, idx: number) => string | null;
/**
* Returns non-whitespace neighbors around [start,end) span of a placeholder.
* Useful to decide whether injected "block-ish" content must be surrounded by newlines.
*/
export declare const getInlineContextAroundSpan: (s: string, start: number, end: number) => {
beforeNonSpace: string | null;
afterNonSpace: string | null;
};
/**
* Wraps injected content with leading/trailing '\n' if:
* - injected matches `blockRe`, AND
* - placeholder is embedded inline (neighbors are not newlines),
* - and injected isn't already newline-wrapped on that side.
*
* Note: `blockRe` might be BEGIN_LIST_ENV_INLINE_RE (strict) or BLOCK_LATEX_RE (broader).
*/
export declare const wrapWithNewlinesIfInline: (injected: string, beforeNonSpace: string | null, afterNonSpace: string | null) => string;