summaryrefslogtreecommitdiff
path: root/crates/typst-docs
diff options
context:
space:
mode:
authorLaurenz <laurmaedje@gmail.com>2023-08-22 14:21:04 +0200
committerLaurenz <laurmaedje@gmail.com>2023-08-22 14:21:04 +0200
commitafc95ed19db8ded044d3b9b916fa0194cb882d0b (patch)
treeae9f5aa62398c1c81efe1f6d046fb2d631cb1c1c /crates/typst-docs
parent756bdb623c9deda1458506b1783a66d92f2d9414 (diff)
Virtual path type
Fixes #1937
Diffstat (limited to 'crates/typst-docs')
-rw-r--r--crates/typst-docs/src/html.rs8
1 files changed, 4 insertions, 4 deletions
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!("<pre>{}</pre>", 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<Bytes> {
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())
}