Define the shared markdown helper behavior in nils-common::markdown used by multiple CLI crates.
- Rejects literal escaped-control artifacts (
\\n,\\r,\\t) in markdown payloads. - Accepts real control characters (
\n,\r,\t). - Returns structured violations via
MarkdownPayloadError.
- Produces markdown-table-safe cell text for render/compare round-trips.
- Normalizes:
|->/\n/\rruns -> single space
- Idempotent: applying it multiple times yields the same output.
- Sorts JSON object keys recursively.
- Emits stable pretty JSON text for markdown code blocks and report artifacts.
- Clamps heading level to 1..=6.
- Trims heading text and emits a trailing newline.
- Emits fenced code blocks using backticks.
- Preserves body text and guarantees a trailing newline before fence close.
- Markdown table renderers before writing rows.
- Drift/contract comparisons for table-parsed values.
- Notes fields that must survive markdown table serialization without false-positive diffs.
- API test/report markdown builders that need stable heading and code-fence layout.
- JSON-in-markdown renderers that require deterministic key ordering.
nils-commonowns the canonical production implementation.- Consuming crates should not duplicate table-cell canonicalization logic.
- Consuming crates should prefer shared heading/code-block/json-format helpers over local duplicates.
nils-commondoes not own GitHub adapters orghcommand orchestration; keep those crate-local.
A|B->A/B"line1\r\nline2"->"line1 line2""x\n\n y"->"x y"is not guaranteed; callers should not rely on whitespace collapsing beyond line-break run normalization.