Expand description
Document AST and reconstruction: turns kopitiam_pdf::Page layout data
into a semantic Document (headings, paragraphs, lists, tables, figures),
plus a validation report auditing the conversion.
Structs§
- Citation
- A citation detected inside paragraph text, kept for provenance reporting. Citations are never extracted out of or altered within their surrounding paragraph text – this only records that one was seen, and where.
- Code
Block - No reconstruction pass produces this yet – code listings currently fall
through to
Paragraph. Kept in the AST so renderers and future reconstruction heuristics have a target to produce/consume. - Conversion
Report - Audits one PDF-to-Markdown conversion: how much of the extracted text survived into the rendered output, plus a tally of the structural blocks found, so every conversion is auditable rather than a silent best-effort guess.
- Document
- Figure
- Heading
- List
- Metadata
- Page
Recovery - Character recovery for a single source page, attributed via the
<!-- page N -->anchors the renderer emits at page boundaries (kopitiam_token_max.md§8 card I-B). - Paragraph
- Quote
- No reconstruction pass produces this yet – block quotes currently fall
through to
Paragraph. - Segment
- One translation-sized unit of a
Document: a run of source text with a content-derivedSegmentId, its position in the segment sequence, and the source block(s) it came from. - Segment
Id - A stable identifier for a translation segment: the FNV-1a content hash of the segment’s normalized text, as lower-case hex.
- Table
Enums§
Functions§
- reconstruct
- Turn a page’s raw text spans into the semantic
DocumentAST: split each page into reading-order columns, group spans into lines, then classify each line (or run of lines) as a heading, list, table, figure caption, or paragraph. A final pass repairs the one join a per-page pipeline cannot see by construction: a paragraph split across a page break (seemerge_page_breaks/ kopitiam-d3n). - reconstruct_
preordered - Like
reconstruct, but for pages whose spans are already in true reading order — oneTextSpanper visual line, columns already linearised and inter-word spacing already correct (whatkopitiam_pdf::extract_mupdfproduces via the ported MuPDFstextengine). - segments
- Splits
documentinto deterministic, order-stable translation segments. - validate
- Compares what was extracted against what was rendered, and tallies the block types found, so every conversion produces an auditable report rather than a silent best-effort guess.