/** * markdown → {@link RichDoc} — flatten the parsed AST into the rich-text * element's flat text+spans+blocks model. * * Models paragraphs, headings, the inline set (bold/italic/strike/code/link), * and — flat, one block attr per line, markers **never in the text** (they're * draw-only natively and re-synthesized by `docToMd`): * * - **tight single-paragraph lists** → one `bullet`/`ordered`/`task` line per * item (`checked` from GFM task syntax; a non-1 ordered start rides * `level` on the run's first line); * - **blockquotes of plain paragraphs** → one `blockquote` line per quoted * line; * - **fenced code** → one `codeBlock` line per content line (`lang` carried * on every line of the fence). * * Everything the flat model cannot hold losslessly — nested / loose / * multi-paragraph lists, quotes containing non-paragraphs, tables, thematic * breaks, and any paragraph containing an unrepresentable inline (images) — * becomes a **`raw` block**: the original markdown source verbatim, edited as * source and serialized back byte-for-byte. That's the lossless escape hatch * that keeps the round trip safe. * * Line convention (chat-style): every `\n` in `doc.text` is a paragraph * boundary. Markdown hard breaks split into separate doc lines; `docToMd` * serializes doc lines back as blank-line-separated paragraphs (hard breaks * normalize to paragraph breaks — documented). */ import type { InlineSpan, RichDoc } from '@sigx/lynx-richtext'; import type { ParserInlineExtension } from '../../parser/extensions.js'; import type { InlineExtension } from '../../ast.js'; /** AST extension node → editor span (a plugin's `docMapping.toSpan`). Must be pure. */ export type ExtensionSpanMapper = (node: InlineExtension) => { text: string; span: Omit; } | null; export interface MdToDocOptions { /** Inline extensions to parse with (plugin `inline.syntax`). */ extensions?: readonly ParserInlineExtension[]; /** Span mappers keyed by extension name (plugin `docMapping.toSpan`). */ spanMappers?: Record; } export declare function mdToDoc(markdown: string, v?: number, options?: MdToDocOptions): RichDoc;