summaryrefslogtreecommitdiff
path: root/src/eval
diff options
context:
space:
mode:
authorLaurenz <laurmaedje@gmail.com>2023-03-14 22:33:22 +0100
committerLaurenz <laurmaedje@gmail.com>2023-03-14 22:34:43 +0100
commit2a86e4db0bb3894d1cc3b94e1a1af31a6cd87b80 (patch)
treed5c0954ef779689c40eb9b2f58d477869546ea89 /src/eval
parente50189cfa75d83ea1b74b1dc2cf1fc9c01f8c825 (diff)
Reference supplements
Diffstat (limited to 'src/eval')
-rw-r--r--src/eval/library.rs6
-rw-r--r--src/eval/mod.rs4
2 files changed, 6 insertions, 4 deletions
diff --git a/src/eval/library.rs b/src/eval/library.rs
index 14f02d98..d3f7547d 100644
--- a/src/eval/library.rs
+++ b/src/eval/library.rs
@@ -59,8 +59,8 @@ pub struct LangItems {
pub raw_languages: fn() -> Vec<(&'static str, Vec<&'static str>)>,
/// A hyperlink: `https://typst.org`.
pub link: fn(url: EcoString) -> Content,
- /// A reference: `@target`.
- pub ref_: fn(target: Label) -> Content,
+ /// A reference: `@target`, `@target[..]`.
+ pub reference: fn(target: Label, supplement: Option<Content>) -> Content,
/// A section heading: `= Introduction`.
pub heading: fn(level: NonZeroUsize, body: Content) -> Content,
/// An item in a bullet list: `- ...`.
@@ -106,7 +106,7 @@ impl Hash for LangItems {
self.emph.hash(state);
self.raw.hash(state);
self.link.hash(state);
- self.ref_.hash(state);
+ self.reference.hash(state);
self.heading.hash(state);
self.list_item.hash(state);
self.enum_item.hash(state);
diff --git a/src/eval/mod.rs b/src/eval/mod.rs
index ae5f668a..127c930f 100644
--- a/src/eval/mod.rs
+++ b/src/eval/mod.rs
@@ -567,7 +567,9 @@ impl Eval for ast::Ref {
type Output = Content;
fn eval(&self, vm: &mut Vm) -> SourceResult<Self::Output> {
- Ok((vm.items.ref_)(Label(self.get().into())))
+ let label = Label(self.target().into());
+ let supplement = self.supplement().map(|block| block.eval(vm)).transpose()?;
+ Ok((vm.items.reference)(label, supplement))
}
}