Expand description
Finding a range again in a document edited somewhere this crate never saw.
A saved Selection is offsets, and offsets only hold for the document
they were taken from. A Quote is the text under the range with a little
context either side — the W3C Web Annotation model’s TextQuoteSelector —
which is what survives the file being rewritten on disk.
use markdown::{Cursor, Part, Quote, Selection, parse};
let before = parse("alpha one\n\nbravo two");
let range = Selection::new(Cursor::new(1, Part::Body, 6), Cursor::new(1, Part::Body, 9));
let quote = Quote::of(&before, range).unwrap();
let after = parse("new first\n\nalpha one\n\nbravo two");
let found = quote.find(&after, Some(range)).unwrap();
assert_eq!(found.ordered().0, Cursor::new(2, Part::Body, 6));Structs§
- Quote
- The text a range covers, and what stands either side of it.