4746aed001
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
923 B
923 B
Crate: crates/markdown (notescraft-markdown). Existing, tested crate: make surgical fixes, no rewrite. No new dependencies.
Document::replace_rangecurrently clamps out-of-range or non-char-boundary ranges silently. Change it to returnResult<String>with a newError::InvalidRange { start, end, len }(andError::NotCharBoundary(usize)); never clamp. Update all callers and tests; add tests for start > end, end > len, and a range splitting a multi-byte char.- Same rule for
Document::text(range)if it clamps: it must return Err, not a truncated string. - Remove the
panic!()from the crate-level doc example (useassert!(matches!(..))orlet ... else { return }). - Add 3 regression tests for edge inputs you consider most likely to break the scanner (for example
[[a|b]]inside a table cell, a#tagdirectly after a closing code fence,^idinside a blockquote) and fix any bug they expose.