From afc95ed19db8ded044d3b9b916fa0194cb882d0b Mon Sep 17 00:00:00 2001 From: Laurenz Date: Tue, 22 Aug 2023 14:21:04 +0200 Subject: Virtual path type Fixes #1937 --- crates/typst-docs/src/html.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'crates/typst-docs/src') diff --git a/crates/typst-docs/src/html.rs b/crates/typst-docs/src/html.rs index 38e56c09..4bb1def1 100644 --- a/crates/typst-docs/src/html.rs +++ b/crates/typst-docs/src/html.rs @@ -7,7 +7,7 @@ use typst::diag::FileResult; use typst::eval::{Bytes, Datetime, Tracer}; use typst::font::{Font, FontBook}; use typst::geom::{Point, Size}; -use typst::syntax::{FileId, Source}; +use typst::syntax::{FileId, Source, VirtualPath}; use typst::World; use yaml_front_matter::YamlFrontMatter; @@ -424,7 +424,7 @@ fn code_block(resolver: &dyn Resolver, lang: &str, text: &str) -> Html { return Html::new(format!("
{}
", highlighted.as_str())); } - let id = FileId::new(None, Path::new("/main.typ")); + let id = FileId::new(None, VirtualPath::new("main.typ")); let source = Source::new(id, compile); let world = DocWorld(source); let mut tracer = Tracer::default(); @@ -498,8 +498,8 @@ impl World for DocWorld { fn file(&self, id: FileId) -> FileResult { assert!(id.package().is_none()); Ok(FILES - .get_file(id.path().strip_prefix("/").unwrap()) - .unwrap_or_else(|| panic!("failed to load {:?}", id.path().display())) + .get_file(id.vpath().as_rootless_path()) + .unwrap_or_else(|| panic!("failed to load {:?}", id.vpath())) .contents() .into()) } -- cgit v1.2.3