import { Generator } from './generator/generator.ts'; import { PackageOpts } from './options.ts'; import { ArgType, MacroArgs, MacroFn, MacroMeta, MacroMode, MacroPackageClass } from './macros.ts'; /** the arguments of a macro (or environment) while and after they are parsed */ export interface ParsedArgs { name: string; /** the mode of the macro; undefined for an environment */ mode?: MacroMode; /** * array with ArgTypes; as they are parsed, they get removed here one by one * and the parsed result added to parsed below, one by one */ args: MacroArgs; /** array with parsed content for the respective arg */ parsed: (DocumentFragment | boolean | string | any)[]; } /** * This class is used by the parser and the generator. The parser needs to know what arguments to parse for a * macro it encountered, and the MacroManager keeps track with state in #curArgs. The parser then executes the * macro with parsed arguments using the generator's macro(), which asks the MacroManager for the macro function. * * MacroManager knows about the Generator to pass it on to instantiated macro packages. Macros need the generator * to create output. * * Macro packages are: latex.ltx, documentclasses, packages, custom macros class(es). * All macro packages should ideally be frozen. State is held in the generator. * * Macro definitions live in three layers; within a layer, a later definition replaces an earlier one: * - format: latex.ltx, then the documentclass, then the packages, in load order * - custom: the CustomMacros given in the options; they override the format * - document: definitions made in the document (\newcommand etc.); they override everything * * The layers are kept for clarity and for replacing a whole layer; lookups use #resolved, the layers * overlaid in that order, which is updated whenever a layer changes. */ export declare class MacroManager { #private; constructor(); setGenerator(generator: Generator): void; reset(): void; loadFormat(): void; loadDocumentClass(name: string, options?: PackageOpts): boolean; loadPackage(name: string, options?: PackageOpts): boolean; setCustomMacros(CustomMacros: MacroPackageClass): void; stylesheets(): string[]; hasMacro(name: string): boolean; macroFn(name: string): MacroFn; define(name: string, fn: MacroFn, meta?: MacroMeta): void; isHmode(macro: string): boolean; isVmode(macro: string): boolean; isHVmode(macro: string): boolean; isPreamble(macro: string): boolean; /** * Begin parsing the arguments of the macro `name` if it is a macro of one of the given modes (a macro * without a declaration is an H-mode macro). Returns false otherwise; the caller has already made sure * that the macro exists. Ends with endArgs(). */ beginMacro(name: string, ...modes: MacroMode[]): boolean; beginArgs(name: string): void; selectArgsBranch(nextChar: string): boolean | undefined; nextArg(arg: ArgType): boolean; argError(m: string): never; addParsedArg(a: any): void; parsedArgs(): any[]; preExecMacro(): void; endArgs(): ParsedArgs; }