mystjs
Version:
Markdown parser for MyST markdown in JavaScript
58 lines (57 loc) • 2.05 kB
TypeScript
import type { Root } from 'mdast';
import type { GenericNode } from './types';
export declare enum TargetKind {
heading = "heading",
math = "math",
figure = "figure",
table = "table",
code = "code"
}
export declare enum ReferenceKind {
ref = "ref",
numref = "numref",
eq = "eq"
}
declare type Target = {
node: GenericNode;
kind: TargetKind;
};
declare type TargetCounts = {
heading?: (number | null)[];
} & Record<string, number>;
export declare type EnumeratorOptions = {
disableHeadingEnumeration?: boolean;
disableContainerEnumeration?: boolean;
disableEquationEnumeration?: boolean;
};
/**
* Increment heading counts based on depth to increment
*
* depth is the depth to increment
* counts is a list of 6 counts, corresponding to 6 heading depths
*
* When a certain depth is incremented, shallower depths are left the same
* and deeper depths are reset to zero. Null counts anywhere are ignored.
*/
export declare function incrementHeadingCounts(depth: number, counts: (number | null)[]): (number | null)[];
/**
* Return dot-delimited header numbering based on heading counts
*
* counts is a list of 6 counts, corresponding to 6 heading depths
*
* Leading zeros are kept, trailing zeros are removed, nulls are ignored.
*/
export declare function formatHeadingEnumerator(counts: (number | null)[]): string;
export declare class State {
targets: Record<string, Target>;
targetCounts: TargetCounts;
constructor(targetCounts?: TargetCounts, targets?: Record<string, Target>);
addTarget(node: GenericNode): void;
initializeNumberedHeadingDepths(tree: Root): void;
incrementCount(node: GenericNode, kind: TargetKind): string;
getTarget(identifier?: string): Target | undefined;
resolveReferenceContent(node: GenericNode): GenericNode['children'] | undefined;
}
export declare const enumerateTargets: (state: State, tree: Root, opts: EnumeratorOptions) => Root;
export declare const resolveReferences: (state: State, tree: Root) => void;
export {};