/** * The pages of a chapter that a heading style's running head dressed * (#874): where each run of Markdown under a migrated page design starts and * ends, page by page, so the migration can wrap it in a `::::page{template}` * fence. A line scanner, not the parser: it only has to know headings, the * fences that open and close containers, code blocks and page breaks, and it * keeps every other line byte for byte. */ /** A heading line of the chapter. */ export interface HeadingLine { /** 0-based line index. */ line: number; level: number; /** The title as written, without its attribute block. */ title: string; /** The `{…}` block as written (without the braces), if any. */ attrsRaw?: string; /** Its attributes; a bare word is `''`, `#x` is `id`. */ attrs: Record; /** Where each attribute is written in `attrsRaw` (`key=value` as typed). */ attrTokens: Record; } /** One page of a run: lines `startLine`…`endLine` (inclusive). */ export interface RunPage { startLine: number; endLine: number; headings: HeadingLine[]; } /** Lines under one page design, from the heading that opens it to the line * before what closes it. */ export interface DesignRun { design: string; startLine: number; endLine: number; pages: RunPage[]; } export interface ScannedChapter { lines: string[]; headings: HeadingLine[]; runs: DesignRun[]; /** Lines of bare `:::pagebreak` directives next to a run (blank lines * aside): a composed page starts a page of its own and the flow after it * resumes on a new one, so these breaks would add empty pages. */ dropBreaks: number[]; } export interface ScanOptions { /** The page design a heading style is migrated into, if any. */ designOf: (styleId: string) => string | undefined; /** Whether a heading starts a new page (its style's, else its level's * `breakBefore.enabled`). */ breaksPage: (heading: HeadingLine) => boolean; } /** The `{…}` attributes of a heading line: `key="v"`, `key='v'`, `key=v`, * `#id`, `.class` (ignored) and bare words. */ export declare function parseAttrBlock(raw: string): { attrs: Record; tokens: Record; }; /** A heading's text and trailing attribute block. */ export declare function readHeading(line: string, index: number): HeadingLine | null; /** Find the runs of a chapter's Markdown under the page designs `designOf` * names. A run opens at a heading whose style is migrated and goes on * while the headings that follow belong to the same design (or are * unstyled and deeper than the one that opened it); a heading of another * style, a part, the contents, a composed page fence or the chapter's end * close it. Inside a run a page break, or a heading that breaks the page, * starts the run's next page. Only top-level lines count: what sits in a * container or a code block is carried along. */ export declare function scanChapter(markdown: string, opts: ScanOptions): ScannedChapter; //# sourceMappingURL=markdownRuns.d.ts.map