summaryrefslogtreecommitdiff
path: root/library/src/lib.rs
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 /library/src/lib.rs
parente50189cfa75d83ea1b74b1dc2cf1fc9c01f8c825 (diff)
Reference supplements
Diffstat (limited to 'library/src/lib.rs')
-rw-r--r--library/src/lib.rs18
1 files changed, 13 insertions, 5 deletions
diff --git a/library/src/lib.rs b/library/src/lib.rs
index 19539ccf..5b114d9b 100644
--- a/library/src/lib.rs
+++ b/library/src/lib.rs
@@ -11,7 +11,7 @@ pub mod text;
pub mod visualize;
use typst::eval::{LangItems, Library, Module, Scope};
-use typst::geom::{Align, Color, Dir, GenAlign};
+use typst::geom::{Align, Color, Dir, GenAlign, Smart};
use typst::model::{Node, NodeId, StyleMap};
use self::layout::LayoutRoot;
@@ -185,13 +185,21 @@ fn items() -> LangItems {
},
raw_languages: text::RawNode::languages,
link: |url| meta::LinkNode::from_url(url).pack(),
- ref_: |target| meta::RefNode::new(target).pack(),
+ reference: |target, supplement| {
+ let mut node = meta::RefNode::new(target);
+ if let Some(supplement) = supplement {
+ node.push_supplement(Smart::Custom(Some(meta::Supplement::Content(
+ supplement,
+ ))));
+ }
+ node.pack()
+ },
heading: |level, title| meta::HeadingNode::new(title).with_level(level).pack(),
list_item: |body| layout::ListItem::new(body).pack(),
enum_item: |number, body| {
let mut node = layout::EnumItem::new(body);
if let Some(number) = number {
- node = node.with_number(Some(number));
+ node.push_number(Some(number));
}
node.pack()
},
@@ -202,10 +210,10 @@ fn items() -> LangItems {
math_attach: |base, bottom, top| {
let mut node = math::AttachNode::new(base);
if let Some(bottom) = bottom {
- node = node.with_bottom(Some(bottom));
+ node.push_bottom(Some(bottom));
}
if let Some(top) = top {
- node = node.with_top(Some(top));
+ node.push_top(Some(top));
}
node.pack()
},