Skip to main content

Module markdown

Module markdown 

Source
Expand description

Markdown -> Product extraction (PORT-CONTRACT.d/03, parity landmine #2).

Bespoke CommonMark block-boundary tokenizer reproducing markdown-it-py 4.2.0’s "commonmark" preset for the consumed surface only: heading_open (tag + 0-based start line) and inline (raw content + start line), plus the oracle’s section-slicing walk on top (src/rac/core/markdown.py).

The bake-off of PORT-CONTRACT decision 4 resolves to bespoke: external markdown crates are not in the dependency allowlist and the consumed surface is block boundaries only, so the block rules of markdown-it-py (code fence blockquote hr list reference html_block heading lheading paragraph) are ported line-by-line from the oracle venv’s source.

Python-semantics helpers (py_strip, py_casefold, py_repr_str, Unicode \d) come from crate::pycompat per the layer-1 contract.

Structs§

BlockEvent
One consumed-surface event: a heading (tag + raw inline text) or a body inline (raw content), each with the block’s 0-based start line.
FrontmatterSplit
split_frontmatter result (decided.core.frontmatter.FrontmatterSplit).
Issue
MalformedRequirement
Product
Requirement
SearchSection
Token

Constants§

DEFAULT_MAX_FILE_BYTES
MAX_CAPTURED_LINES
MAX_FIELD_CHARS

Functions§

consumed_events
The exact token surface the oracle walk consumes (contract section 1).
max_file_bytes
The per-file byte cap, honoring DECIDED_MAX_FILE_BYTES (REQ-001).
max_file_bytes_from
max_file_bytes() computed from a raw env value (None = unset).
parse
Parse Markdown text into a Product (decided.core.markdown.parse), with the byte cap taken from the environment.
parse_file
Read path and parse it (decided.core.markdown.parse_file).
parse_file_with_cap
parse_file with an explicit byte cap (testing seam).
parse_with_cap
parse with an explicit byte cap (testing seam; the oracle reads the env).
py_parse_int
Python int(str) (decimal): strips the Unicode whitespace set (which, unlike str.strip(), excludes U+001C-U+001F — verified empirically, and it matches Rust str::trim), accepts an optional sign, Unicode Nd digits, and single underscores strictly between digits.
split_frontmatter
Split a leading --- frontmatter block (decided.core.frontmatter).
tokenize_blocks
Tokenize a (frontmatter-stripped) Markdown body into the flat block-level token stream, exactly as markdown-it-py 4.2.0 “commonmark” emits it.