/** * Placeholder/highlight macros for docrev. * * Users write `\tofill{X}` (or any custom macro they declare) in markdown * source and the build pipeline expands it per output format: * * - docx: raw OpenXML run with explicit color + bold (Span+style is NOT * honored by pandoc's docx writer, so we emit raw nodes). * - pdf / tex / beamer: a `\providecommand` is injected via header-includes, * so the LaTeX command works directly. `\providecommand` means the user * can still override with `\renewcommand` in their own preamble. * - html: raw HTML span with inline style. * - everything else (markdown, gfm, etc.): bold [X] fallback. Never silently * dropped. * * The mechanism is generic: `\tofill` is the first built-in. Users can add * their own macros under `macros:` in rev.yaml, and override the built-in by * declaring a macro with the same name. */ /** * Per-format rendering rules for a macro. * * Fields are independent — set any subset. Unset fields fall back to defaults * (no color, no bold, no italic, bracket wrap on, etc.). */ export interface MacroFormatStyle { /** Hex color without '#' (e.g. "C2410C"). */ color?: string; /** Wrap the rendered content in bold. */ bold?: boolean; /** Wrap the rendered content in italic. */ italic?: boolean; /** Wrap the content in [...] brackets. Default: true. */ bracket?: boolean; /** Optional literal prefix string inside the brackets (e.g. "NOTE: "). */ prefix?: string; /** Optional literal suffix string inside the brackets. */ suffix?: string; } /** * Macro definition. `name` is the LaTeX command name without the leading * backslash (e.g. "tofill" → \tofill{...}). `formats` holds per-format rules; * a missing format key inherits from `default`. */ export interface MacroDef { name: string; /** Default rendering rules; used when a format-specific override is absent. */ default?: MacroFormatStyle; /** Per-format overrides, keyed by pandoc format (docx, pdf, html, ...). */ formats?: Record; } /** * Built-in macros shipped with docrev. The first entry is the original use * case: \tofill{X} → bold orange [X] placeholder. */ export declare const BUILTIN_MACROS: MacroDef[]; /** * Validate a user-declared macro entry. Returns a list of error strings; * empty means the macro is valid. */ export declare function validateMacro(macro: unknown): string[]; /** * Merge built-in macros with user-declared macros. User entries override * built-ins by `name` (case-sensitive). Invalid entries are dropped with a * console warning so a malformed user macro never silently disables the * built-in. */ export declare function mergeMacros(userMacros: unknown): MacroDef[]; /** * Generate `\providecommand` definitions for all macros. `\providecommand` * means user-supplied `\renewcommand` (in a custom header-includes file) still * wins, preserving backwards compat with existing projects. * * Returns an empty string when the macro list is empty. */ export declare function generateLatexPreamble(macros: MacroDef[]): string; /** * Resolve the effective style for a macro in a given pandoc format. Per-format * override wins over the macro's default; both can be partial — fields are * not merged across `default` and `formats[fmt]` (the format-specific entry * replaces `default` entirely when present), keeping rev.yaml semantics * predictable. * * Falls back to `default` when no `formats[fmt]` exists, and to an empty * style ({}) when neither is set. */ export declare function pickStyle(macro: MacroDef, format: string): MacroFormatStyle; /** * Serialize the macro list to a compact JSON sidecar consumed by the lua * filter at build time. The lua filter reads this file at startup and uses it * to expand `\tofill{X}` (or any other declared macro) per FORMAT. * * Returns the absolute path to the written sidecar. */ export declare function writeMacrosSidecar(directory: string, macros: MacroDef[]): string; /** * Resolve the absolute path to the bundled lua filter. Works both from source * (`lib/macro-filter.lua`) and from the compiled package (`dist/lib/...`) * because the postbuild script copies .lua files alongside the .js output. */ export declare function getMacroFilterPath(): string; //# sourceMappingURL=macros.d.ts.map