Expand description
Comment-aware reflow inside a Region::Code.
The contract: take the raw body of a code block (between the fence
lines), reflow any prose carried inside comments per the language’s
configured comment markers, and optionally pipe the result through an
external formatter. Lines that are not comments pass through unchanged
unless the formatter rewrites them.
Indentation is preserved exactly. For a line that matches the
line_comment marker, the leading whitespace + marker + (optional one
space) are stripped, the remainder runs through the sentence splitter
with Format::Plaintext semantics, and each output sentence is re-emitted
with the original prefix.
Block comments (block_comment = ["open", "close"]) treat the open and
close marker lines verbatim and reflow the prose between as a single
plaintext blob.
The // snapper:off / // snapper:on pragma applies inside code blocks:
lines between the markers (inclusive of the pragma lines) emit verbatim.
The pragma matcher accepts the language’s line_comment marker in
addition to the format-specific prefixes already recognised by
parser::check_pragma.
Constants§
- FORMATTER_
TIMEOUT_ SECS - Wall-clock budget for the external formatter, in seconds.
Functions§
- reflow_
code_ body - Reflow the
bodyof aRegion::Code. - run_
formatter - Pipe
bodythrough the formatterargvvia stdin/stdout. Returns the formatter’s stdout on success. ReturnsErr(message)on any failure mode (binary missing, non-zero exit, timeout, I/O); the caller is expected to log the message and fall back to the input.