/** * Build system - combines sections → paper.md → PDF/DOCX/TEX * * Features: * - Reads rev.yaml config * - Combines section files into paper.md (persisted) * - Strips annotations appropriately per output format * - Runs pandoc with crossref filter */ import type { Author, JournalFormatting } from './types.js'; import { type MacroDef } from './macros.js'; export interface CrossrefConfig { figureTitle?: string; tableTitle?: string; figPrefix?: string | string[]; tblPrefix?: string | string[]; secPrefix?: string | string[]; linkReferences?: boolean; } export interface PdfConfig { template?: string | null; headerIncludes?: string | null; documentclass?: string; fontsize?: string; geometry?: string; linestretch?: number; numbersections?: boolean; toc?: boolean; /** * LaTeX engine: pdflatex (default), xelatex, lualatex, tectonic, etc. * xelatex/lualatex are required for native UTF-8 rendering of Latin-Extended * diacritics (Czech/Polish/Croatian/Spanish author names, species epithets). */ engine?: string; /** Roman/serif main font (xelatex/lualatex only — uses fontspec). */ mainfont?: string; /** Sans-serif font (xelatex/lualatex only). */ sansfont?: string; /** Monospace font (xelatex/lualatex only). */ monofont?: string; /** Extra pandoc args appended for this format (after top-level pandocArgs). */ pandocArgs?: string[]; } export interface DocxConfig { reference?: string | null; keepComments?: boolean; affiliationNewline?: boolean; toc?: boolean; pandocArgs?: string[]; /** * Auto-translate the common-shape raw `\begin{figure}...\end{figure}` block * to portable `![caption](path){#fig:label width=N%}` markdown so figures * survive the docx build (pandoc otherwise drops raw LaTeX silently). * Default true. Set false to opt out — blocks then warn and are left alone. */ translateRawFigures?: boolean; } export interface TexConfig { standalone?: boolean; pandocArgs?: string[]; } export interface BeamerConfig { theme?: string; colortheme?: string | null; fonttheme?: string | null; aspectratio?: string | null; navigation?: string | null; section?: boolean; notes?: string | false; fit_images?: boolean; pandocArgs?: string[]; } export interface PptxConfig { theme?: string; reference?: string | null; media?: string | null; colors?: { default?: string; title?: string; }; buildup?: { grey?: string; accent?: string; enabled?: boolean; }; pandocArgs?: string[]; } export interface TablesConfig { nowrap?: string[]; } export interface PostprocessConfig { pdf?: string | null; docx?: string | null; tex?: string | null; pptx?: string | null; beamer?: string | null; all?: string | null; [key: string]: string | null | undefined; } export interface BuildConfig { title: string; authors: (string | Author)[]; affiliations: Record; sections: string[]; bibliography: string | null; csl: string | null; crossref: CrossrefConfig; pdf: PdfConfig; docx: DocxConfig; tex: TexConfig; beamer: BeamerConfig; pptx: PptxConfig; tables: TablesConfig; postprocess: PostprocessConfig; /** * User-declared placeholder macros. Merged with the built-in macros * (currently \tofill). Each entry overrides a built-in by name. * * See lib/macros.ts for the per-format rendering rules. */ macros?: MacroDef[]; /** * Directory (relative to the project) where final outputs land. Created on * demand. Set to null/empty to keep outputs alongside paper.md (legacy * behavior). */ outputDir?: string | null; /** * Per-format output filenames. Keys are format names (pdf/docx/tex/beamer/ * pptx); values are paths. Relative paths resolve under outputDir; absolute * paths are honored as-is. Extension is added if missing. CLI `-o` wins * over this map. */ output?: Record; /** * Extra pandoc args applied to every format. Format-specific args * (e.g. docx.pandocArgs) are appended *after* these, and CLI --pandoc-arg * values are appended last. */ pandocArgs?: string[]; _configPath?: string | null; } export interface BuildResult { format: string; success: boolean; outputPath?: string; error?: string; } interface BuildOptions { verbose?: boolean; config?: BuildConfig; /** * Internal: forces the exact output path. Used by dual-mode/temp builds that * route to specific temp files. Bypasses the `output:` resolver. */ outputPath?: string; /** * CLI override (`-o, --output `). Beats `config.output[format]` but * loses to `options.outputPath`. Relative paths resolve under outputDir; * absolute paths bypass outputDir. */ output?: string; crossref?: boolean; /** Extra pandoc args from CLI (--pandoc-arg). Appended after config args. */ pandocArgs?: string[]; _refsAutoInjected?: boolean; _forwardRefsResolved?: number; } interface CombineOptions extends BuildOptions { _refsAutoInjected?: boolean; } interface PandocResult { outputPath: string; success: boolean; error?: string; } interface FullBuildResult { results: BuildResult[]; paperPath: string; warnings: string[]; forwardRefsResolved: number; refsAutoInjected?: boolean; } interface Registry { figures: Map; tables: Map; equations: Map; byNumber: { fig?: Map; figS?: Map; tbl?: Map; tblS?: Map; eq?: Map; }; } /** * Default rev.yaml configuration */ export declare const DEFAULT_CONFIG: BuildConfig; /** * Merge journal formatting defaults into a config. * Priority: DEFAULT_CONFIG < journal formatting < rev.yaml explicit settings */ export declare function mergeJournalFormatting(config: BuildConfig, formatting: JournalFormatting, directory: string): BuildConfig; /** * Load rev.yaml config from directory * @param directory - Project directory path * @returns Merged config with defaults * @throws {TypeError} If directory is not a string * @throws {Error} If rev.yaml exists but cannot be parsed */ export declare function loadConfig(directory: string): BuildConfig; /** * Find section files in directory * @param directory - Project directory path * @param configSections - Sections from rev.yaml (optional) * @returns Ordered list of section file names * @throws {TypeError} If directory is not a string */ export declare function findSections(directory: string, configSections?: string[]): string[]; /** * Combine section files into paper.md */ export declare function combineSections(directory: string, config: BuildConfig, options?: CombineOptions): string; /** * Process markdown tables to apply nowrap formatting to specified columns. * Converts distribution notation (Normal, Student-t, Gamma) to LaTeX math. * @param content - Markdown content * @param tablesConfig - tables config from rev.yaml * @param format - output format (pdf, docx, etc.) * @returns processed content */ export declare function processTablesForFormat(content: string, tablesConfig: TablesConfig, format: string): string; /** * Apply format-specific transforms (table normalization, author blocks, * crossref display conversion, slide syntax). Caller is responsible for * stripping annotations beforehand — the dual-output paths keep comments * in the markdown stream and need to apply these transforms separately * from annotation handling. * * @param content - Markdown content (annotations already stripped as needed) * @param format - Output format * @param config - Build config * @param registry - Crossref registry for the project * @returns Transformed markdown */ export declare function applyFormatTransforms(content: string, format: string, config: BuildConfig, registry: Registry): string; /** * Prepare paper.md for specific output format */ export declare function prepareForFormat(paperPath: string, format: string, config: BuildConfig, _options?: BuildOptions): string; /** * A raw LaTeX `\begin{figure}...\end{figure}` block found in source markdown. * `exotic` blocks contain features we don't auto-translate (multiple * `\includegraphics`, `\subfloat`, `\rotatebox`, unrecognised width units); * pandoc strips raw LaTeX silently in docx output, so users get warned about * anything that won't be translated. */ export interface RawLatexFigure { file?: string; line: number; block: string; exotic: boolean; } /** * Find raw LaTeX figure blocks containing `\includegraphics` in markdown. * `file`, if given, is attached to each result. `line` is 1-based within the * supplied content (the line where `\begin{figure}` sits). */ export declare function detectRawLatexFigures(content: string, file?: string): RawLatexFigure[]; /** * Translate the 80% case: single `\includegraphics` figure with optional * `\caption{...}` and `\label{...}`, wrapped in `\begin{figure}...\end{figure}`, * to portable `![caption](path){#fig:label width=N%}` markdown. Exotic blocks * (see `isExoticFigureBlock`) are left untouched. */ export declare function translateRawLatexFigures(content: string): { translated: string; translatedCount: number; }; /** * Walk section files and gather a warning for any raw LaTeX figure blocks that * won't survive the docx build. Returns null when there's nothing to warn about. */ export declare function collectRawLatexFigureWarning(directory: string, config: BuildConfig): string | null; /** * Build pandoc arguments for format. * * Returns only the built-in args derived from config. Passthrough args * (config.pandocArgs, config[format].pandocArgs, CLI --pandoc-arg) are * appended later in runPandoc so they win against pptx/crossref defaults * added there. */ export declare function buildPandocArgs(format: string, config: BuildConfig, outputPath: string): string[]; /** * Collect passthrough pandoc args for a format in the canonical order: * top-level config → format-specific config → CLI extras. Later wins for * repeated flags. */ export declare function collectPandocPassthroughArgs(format: string, config: BuildConfig, extraArgs?: string[]): string[]; /** * Resolve the absolute directory where final outputs should land. * Honors config.outputDir; falls back to the project directory when null/empty. */ export declare function resolveOutputDir(directory: string, config: BuildConfig): string; /** Get file extension for a format, defaulting to `.pdf`. */ export declare function getFormatExtension(format: string): string; /** * Slugify a title for use as a default output filename. Lowercases, replaces * non-alphanumeric runs with `-`, and truncates at the last `-` boundary * at-or-before MAX_TITLE_FILENAME_LENGTH so words stay whole (the old blind * `.slice` cut mid-word). */ export declare function slugifyTitle(title: string): string; /** * Resolve the final output path for a build. * * Priority: `options.outputPath` (internal force) > `cliOverride` (-o flag) > * `config.output[format]` > slugified title fallback. * * Relative paths from `cliOverride`/`config.output` resolve under outputDir; * absolute paths bypass outputDir. The fallback path always lives under * outputDir. * * @param suffix - Appended before the extension (e.g. "-changes", "-slides"). * Suppressed when user supplied an explicit name via CLI or * config — they pick their own suffix. */ export declare function resolveOutputPath(directory: string, config: BuildConfig, format: string, options?: { cliOverride?: string; suffix?: string; }): string; /** * Run pandoc build */ export declare function runPandoc(inputPath: string, format: string, config: BuildConfig, options?: BuildOptions): Promise; /** * Full build pipeline */ export declare function build(directory: string, formats?: string[], options?: BuildOptions): Promise; /** * Get build status summary */ export declare function formatBuildResults(results: BuildResult[]): string; export {}; //# sourceMappingURL=build.d.ts.map