Skip to main content

Crate kopitiam_document

Crate kopitiam_document 

Source
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.
CodeBlock
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.
ConversionReport
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
PageRecovery
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-derived SegmentId, its position in the segment sequence, and the source block(s) it came from.
SegmentId
A stable identifier for a translation segment: the FNV-1a content hash of the segment’s normalized text, as lower-case hex.
Table

Enums§

Block

Functions§

reconstruct
Turn a page’s raw text spans into the semantic Document AST: 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 (see merge_page_breaks / kopitiam-d3n).
reconstruct_preordered
Like reconstruct, but for pages whose spans are already in true reading order — one TextSpan per visual line, columns already linearised and inter-word spacing already correct (what kopitiam_pdf::extract_mupdf produces via the ported MuPDF stext engine).
segments
Splits document into 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.