Skip to main content

Module block_diff

Module block_diff 

Source
Expand description

Markdown block segmentation + block-level diff — a faithful port of block-diff.ts.

Blocks are segmented by a line classifier (fenced code, tables, headings, blockquotes, lists, block-level HTML, paragraph runs), then diffed with the same load-bearing LCS tie-break as line_diff (lcs[i+1][j] >= lcs[i][j+1] ⇒ prefer removed). Comparison is over normalized blocks (whitespace collapsed) while the emitted raw is the un-normalized block from the side that owns it. html is left empty here and filled later by the orchestrator via docgen-core::markdown::render_markdown.

Functions§

build_block_diff
Build the full block-level diff stream between two markdown documents. Each DocDiffBlock has html = "" (filled later by the orchestrator).
split_markdown_blocks
Split a markdown document into its top-level blocks, preserving fenced-code and table blocks verbatim. Frontmatter and <script> blocks are stripped first.
strip_invisible_document_parts
Strip a leading frontmatter block and all <script>…</script> blocks, then trim. Mirrors the original’s three non-greedy regex replacements.