Expand description
Source mapping for Quarto
This crate provides unified source location tracking with support for transformations (extraction, concatenation, normalization). It enables precise error reporting and mapping positions back through transformation chains to original source files.
§Overview
The core types are:
SourceInfo: Enum tracking a location and its transformation historySourceContext: Manages files and provides content for mappingMappedLocation: Result of mapping through transformation chains
§Example
use quarto_source_map::*;
// Create a context and register a file
let mut ctx = SourceContext::new();
let file_id = ctx.add_file("main.qmd".into(), Some("# Hello\nWorld".into()));
// Create a source location (stores only offsets)
let info = SourceInfo::original(file_id, 0, 7);
// Map to get row/column information
let mapped = info.map_offset(0, &ctx).unwrap();
assert_eq!(mapped.location.row, 0);
assert_eq!(mapped.location.column, 0);Re-exports§
pub use context::FileMetadata;pub use context::SourceContext;pub use context::SourceFile;pub use file_info::FileInformation;pub use mapping::MappedLocation;pub use source_info::Anchor;pub use source_info::AnchorRole;pub use source_info::By;pub use source_info::SourceInfo;pub use source_info::SourcePiece;pub use types::FileId;pub use types::Location;pub use types::Range;pub use utils::line_col_to_offset;pub use utils::offset_to_location;pub use utils::range_from_offsets;