summaryrefslogtreecommitdiff
path: root/crates/typst-eval
diff options
context:
space:
mode:
authorLaurenz <laurmaedje@gmail.com>2025-07-08 10:52:43 +0200
committerGitHub <noreply@github.com>2025-07-08 08:52:43 +0000
commit0a3c6939dd274f40672484695d909c2cc0d0d755 (patch)
tree465c10338230b895fdd06c8b3491f1734e8a2932 /crates/typst-eval
parent36ecbb2c8dccc1a31c43fee1466f1425844d8607 (diff)
Rewrite foundations of native elements (#6547)
Diffstat (limited to 'crates/typst-eval')
-rw-r--r--crates/typst-eval/src/markup.rs9
-rw-r--r--crates/typst-eval/src/math.rs6
-rw-r--r--crates/typst-eval/src/rules.rs5
3 files changed, 9 insertions, 11 deletions
diff --git a/crates/typst-eval/src/markup.rs b/crates/typst-eval/src/markup.rs
index 9118ded5..cc960626 100644
--- a/crates/typst-eval/src/markup.rs
+++ b/crates/typst-eval/src/markup.rs
@@ -186,7 +186,7 @@ impl Eval for ast::Raw<'_> {
let lines = self.lines().map(|line| (line.get().clone(), line.span())).collect();
let mut elem = RawElem::new(RawContent::Lines(lines)).with_block(self.block());
if let Some(lang) = self.lang() {
- elem.push_lang(Some(lang.get().clone()));
+ elem.lang.set(Some(lang.get().clone()));
}
Ok(elem.pack())
}
@@ -219,9 +219,8 @@ impl Eval for ast::Ref<'_> {
.expect("unexpected empty reference");
let mut elem = RefElem::new(target);
if let Some(supplement) = self.supplement() {
- elem.push_supplement(Smart::Custom(Some(Supplement::Content(
- supplement.eval(vm)?,
- ))));
+ elem.supplement
+ .set(Smart::Custom(Some(Supplement::Content(supplement.eval(vm)?))));
}
Ok(elem.pack())
}
@@ -252,7 +251,7 @@ impl Eval for ast::EnumItem<'_> {
let body = self.body().eval(vm)?;
let mut elem = EnumItem::new(body);
if let Some(number) = self.number() {
- elem.push_number(Some(number));
+ elem.number.set(Some(number));
}
Ok(elem.pack())
}
diff --git a/crates/typst-eval/src/math.rs b/crates/typst-eval/src/math.rs
index 0e271a08..c2325a8c 100644
--- a/crates/typst-eval/src/math.rs
+++ b/crates/typst-eval/src/math.rs
@@ -80,17 +80,17 @@ impl Eval for ast::MathAttach<'_> {
let mut elem = AttachElem::new(base);
if let Some(expr) = self.top() {
- elem.push_t(Some(expr.eval_display(vm)?));
+ elem.t.set(Some(expr.eval_display(vm)?));
}
// Always attach primes in scripts style (not limits style),
// i.e. at the top-right corner.
if let Some(primes) = self.primes() {
- elem.push_tr(Some(primes.eval(vm)?));
+ elem.tr.set(Some(primes.eval(vm)?));
}
if let Some(expr) = self.bottom() {
- elem.push_b(Some(expr.eval_display(vm)?));
+ elem.b.set(Some(expr.eval_display(vm)?));
}
Ok(elem.pack())
diff --git a/crates/typst-eval/src/rules.rs b/crates/typst-eval/src/rules.rs
index f4c1563f..eb6a1e6d 100644
--- a/crates/typst-eval/src/rules.rs
+++ b/crates/typst-eval/src/rules.rs
@@ -1,6 +1,6 @@
use typst_library::diag::{warning, At, SourceResult};
use typst_library::foundations::{
- Element, Fields, Func, Recipe, Selector, ShowableSelector, Styles, Transformation,
+ Element, Func, Recipe, Selector, ShowableSelector, Styles, Transformation,
};
use typst_library::layout::BlockElem;
use typst_library::model::ParElem;
@@ -62,8 +62,7 @@ fn check_show_par_set_block(vm: &mut Vm, recipe: &Recipe) {
if let Some(Selector::Elem(elem, _)) = recipe.selector();
if *elem == Element::of::<ParElem>();
if let Transformation::Style(styles) = recipe.transform();
- if styles.has::<BlockElem>(<BlockElem as Fields>::Enum::Above as _) ||
- styles.has::<BlockElem>(<BlockElem as Fields>::Enum::Below as _);
+ if styles.has(BlockElem::above) || styles.has(BlockElem::below);
then {
vm.engine.sink.warn(warning!(
recipe.span(),