Files
notescraft/scripts/waves/wave2/fix-markdown.md
T
2026-10-13 19:00:33 -03:00

923 B

Crate: crates/markdown (notescraft-markdown). Existing, tested crate: make surgical fixes, no rewrite. No new dependencies.

  1. Document::replace_range currently clamps out-of-range or non-char-boundary ranges silently. Change it to return Result<String> with a new Error::InvalidRange { start, end, len } (and Error::NotCharBoundary(usize)); never clamp. Update all callers and tests; add tests for start > end, end > len, and a range splitting a multi-byte char.
  2. Same rule for Document::text(range) if it clamps: it must return Err, not a truncated string.
  3. Remove the panic!() from the crate-level doc example (use assert!(matches!(..)) or let ... else { return }).
  4. Add 3 regression tests for edge inputs you consider most likely to break the scanner (for example [[a|b]] inside a table cell, a #tag directly after a closing code fence, ^id inside a blockquote) and fix any bug they expose.