mirror of
https://github.com/typst/typst
synced 2025-07-07 12:42:53 +08:00
Add support for weak elements in math (#1633)
This commit is contained in:
parent
5bdad06d92
commit
a4756d8576
@ -47,6 +47,7 @@ use crate::meta::{
|
|||||||
Count, Counter, CounterUpdate, LocalName, Numbering, Outlinable, Refable,
|
Count, Counter, CounterUpdate, LocalName, Numbering, Outlinable, Refable,
|
||||||
};
|
};
|
||||||
use crate::prelude::*;
|
use crate::prelude::*;
|
||||||
|
use crate::shared::BehavedBuilder;
|
||||||
use crate::text::{
|
use crate::text::{
|
||||||
families, variant, FontFamily, FontList, LinebreakElem, SpaceElem, TextElem, TextSize,
|
families, variant, FontFamily, FontList, LinebreakElem, SpaceElem, TextElem, TextSize,
|
||||||
};
|
};
|
||||||
@ -414,7 +415,11 @@ impl LayoutMath for Content {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if let Some(children) = self.to_sequence() {
|
if let Some(children) = self.to_sequence() {
|
||||||
|
let mut bb = BehavedBuilder::new();
|
||||||
for child in children {
|
for child in children {
|
||||||
|
bb.push(child.clone(), StyleChain::default());
|
||||||
|
}
|
||||||
|
for (child, _) in bb.finish().0.iter() {
|
||||||
child.layout_math(ctx)?;
|
child.layout_math(ctx)?;
|
||||||
}
|
}
|
||||||
return Ok(());
|
return Ok(());
|
||||||
|
@ -60,7 +60,7 @@ macro_rules! ops {
|
|||||||
);)*
|
);)*
|
||||||
|
|
||||||
let dif = |d| {
|
let dif = |d| {
|
||||||
HElem::new(THIN.into()).pack()
|
HElem::new(THIN.into()).with_weak(true).pack()
|
||||||
+ MathStyleElem::new(TextElem::packed(d)).with_italic(Some(false)).pack()
|
+ MathStyleElem::new(TextElem::packed(d)).with_italic(Some(false)).pack()
|
||||||
};
|
};
|
||||||
math.define("dif", dif('d'));
|
math.define("dif", dif('d'));
|
||||||
|
Binary file not shown.
Before Width: | Height: | Size: 24 KiB After Width: | Height: | Size: 28 KiB |
@ -20,6 +20,11 @@ $ binom(circle, square) $
|
|||||||
// Error: 8-13 missing argument: lower
|
// Error: 8-13 missing argument: lower
|
||||||
$ binom(x^2) $
|
$ binom(x^2) $
|
||||||
|
|
||||||
|
---
|
||||||
|
// Test dif.
|
||||||
|
$ (dif y)/(dif x), dif/x, x/dif, dif/dif \
|
||||||
|
frac(dif y, dif x), frac(dif, x), frac(x, dif), frac(dif, dif) $
|
||||||
|
|
||||||
---
|
---
|
||||||
// Test associativity.
|
// Test associativity.
|
||||||
$ 1/2/3 = (1/2)/3 = 1/(2/3) $
|
$ 1/2/3 = (1/2)/3 = 1/(2/3) $
|
||||||
|
Loading…
x
Reference in New Issue
Block a user