quarto-source-map
Unified source-location tracking with byte-range provenance, for parsers and diagnostics.
quarto-source-map records where a piece of text came from and follows it
through transformation chains (extraction, concatenation, normalization), so a
position in derived text can be mapped back to a line/column in the original
source file. It is the source-location substrate underneath Quarto's diagnostics,
but it has no Quarto-specific dependencies and is usable on its own.
Core types
SourceInfo— a location plus its transformation history.SourceContext— registers files and provides the content needed to map offsets torow/column.MappedLocation— the result of mapping an offset back through the chain.
Example
use *;
// Create a context and register a file.
let mut ctx = new;
let file_id = ctx.add_file;
// A source location stores only offsets…
let info = original;
// …and maps to row/column on demand.
let mapped = info.map_offset.unwrap;
assert_eq!;
assert_eq!;
License
MIT © Posit Software, PBC