@mdfriday/foundry
Version:
The core engine of MDFriday. Convert Markdown and shortcodes into fully themed static sites – Hugo-style, powered by TypeScript.
129 lines (128 loc) • 4.41 kB
TypeScript
import { Item, ItemType, Items } from './item';
export type stateFunc = ((l: pageLexer) => stateFunc | null) | null;
declare enum ParamState {
none = 0,
named = 1,
positional = 2
}
interface lexerShortcodeState {
currLeftDelimItem: ItemType;
currRightDelimItem: ItemType;
isInline: boolean;
currShortcodeName: string;
closingState: number;
elementStepNum: number;
paramElements: number;
paramState: ParamState;
openShortcodes: {
[key: string]: boolean;
};
}
export interface Config {
}
declare class sectionHandlers {
l: pageLexer;
skipAll: boolean;
handlers: sectionHandler[];
skipIndexes: number[];
constructor(l: pageLexer);
skip(): number;
lex(origin: stateFunc): stateFunc | null;
}
declare class sectionHandler {
l: pageLexer;
skipAll: boolean;
skipFunc: (l: pageLexer) => number;
lexFunc: (origin: stateFunc, l: pageLexer) => [stateFunc | null, boolean];
constructor(l: pageLexer, skipFunc: (l: pageLexer) => number, lexFunc: (origin: stateFunc, l: pageLexer) => [stateFunc | null, boolean]);
skip(): number;
}
export declare class Iterator {
items: Item[];
lastPos: number;
constructor(items: Item[]);
Next(): Item;
Current(): Item;
Backup(): void;
Pos(): number;
IsValueNext(): boolean;
Peek(): Item;
PeekWalk(walkFn: (item: Item) => boolean): void;
Consume(cnt: number): void;
LineNumber(source: Uint8Array): number;
}
export declare function NewIterator(items: Item[]): Iterator;
export declare class pageLexer {
input: Uint8Array;
stateStart: stateFunc;
state: stateFunc | null;
pos: number;
start: number;
width: number;
sectionHandlers: sectionHandlers;
cfg: Config;
summaryDivider: Uint8Array | null;
summaryDividerChecked: boolean;
lexerShortcodeState: lexerShortcodeState;
items: Items;
err: Error | null;
inFrontMatter: boolean;
parenDepth: number;
constructor(input: Uint8Array, stateStart: stateFunc, cfg: Config);
Iterator(): Iterator;
Input(): Uint8Array;
run(): pageLexer;
next(): number;
peek(): number;
backup(): void;
append(item: Item): void;
emit(t: ItemType): void;
emitString(t: ItemType): void;
isEOF(): boolean;
ignoreEscapesAndEmit(t: ItemType, isString: boolean): void;
current(): Uint8Array;
ignore(): void;
errorf(format: string, ...args: any[]): null;
consumeCRLF(): boolean;
consumeToSpace(): void;
consumeSpace(): void;
private isUnicodeSpace;
index(sep: Uint8Array): number;
hasPrefix(prefix: Uint8Array): boolean;
isShortCodeStart(): boolean;
lexFrontMatterSection(tp: ItemType, delimr: number, name: string, delim: Uint8Array): stateFunc;
currentLeftShortcodeDelimItem(): ItemType;
currentRightShortcodeDelimItem(): ItemType;
currentLeftShortcodeDelim(): Uint8Array;
currentRightShortcodeDelim(): Uint8Array;
lexIdentifier(): stateFunc;
lexMainSection(): stateFunc;
lexInlineShortcodeContent(): stateFunc;
lexIdentifierInShortcode(): stateFunc;
lexEndOfShortcode(): stateFunc;
lexShortcodeLeftDelim(): stateFunc;
peekString(s: string | Uint8Array): string | null;
lexSummaryDivider(): stateFunc;
handleBOM(): boolean;
lexIntroSection(): stateFunc;
lexInsideShortcode(): stateFunc;
lexShortcodeParam(escapedQuoteStart: boolean): stateFunc;
lexShortcodeParamVal(): stateFunc;
lexShortcodeValueUnquoted(): stateFunc;
lexShortcodeQuotedParamVal(escapedQuotedValuesAllowed: boolean, typ: ItemType): stateFunc;
lexShortCodeParamRawStringVal(typ: ItemType): stateFunc;
lexDone(): null;
lexShortcodeRightDelim(): stateFunc;
lexShortcodeValue(): stateFunc;
lexShortcodeValueQuoted(): stateFunc;
isRightShortcodeDelim(): boolean;
lexComment(): stateFunc;
isComment(): boolean;
}
export declare function ParseBytes(b: Uint8Array, cfg: Config): [Items, Error | null];
export declare function ParseBytesMain(b: Uint8Array, cfg: Config): [Items, Error | null];
export declare function HasShortcode(s: string): boolean;
export declare function newPageLexer(input: Uint8Array, stateStart: stateFunc, cfg: Config): pageLexer;
export declare function lexIntroSection(l: pageLexer): stateFunc;
export declare function lexMainSection(l: pageLexer): stateFunc;
export {};