From a3f3a1a83330e3fe9a686fbe4c0eda9f1e9e99b2 Mon Sep 17 00:00:00 2001 From: Myriad-Dreamin <35292584+Myriad-Dreamin@users.noreply.github.com> Date: Sun, 14 Jul 2024 21:14:21 +0800 Subject: Change the signature of `World::main` (#4531) Co-authored-by: Laurenz --- docs/src/html.rs | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'docs/src') diff --git a/docs/src/html.rs b/docs/src/html.rs index ab140a90..58c8e54c 100644 --- a/docs/src/html.rs +++ b/docs/src/html.rs @@ -6,7 +6,7 @@ use heck::{ToKebabCase, ToTitleCase}; use pulldown_cmark as md; use serde::{Deserialize, Serialize}; use typed_arena::Arena; -use typst::diag::{FileResult, StrResult}; +use typst::diag::{FileError, FileResult, StrResult}; use typst::foundations::{Bytes, Datetime}; use typst::layout::{Abs, Point, Size}; use typst::syntax::{FileId, Source, VirtualPath}; @@ -463,12 +463,16 @@ impl World for DocWorld { &FONTS.0 } - fn main(&self) -> Source { - self.0.clone() + fn main(&self) -> FileId { + self.0.id() } - fn source(&self, _: FileId) -> FileResult { - Ok(self.0.clone()) + fn source(&self, id: FileId) -> FileResult { + if id == self.0.id() { + Ok(self.0.clone()) + } else { + Err(FileError::NotFound(id.vpath().as_rootless_path().into())) + } } fn file(&self, id: FileId) -> FileResult { -- cgit v1.2.3