mirror of
https://github.com/typst/typst
synced 2025-07-19 02:22:53 +08:00
Change enum.item.number
to Smart
instead of Option
(#6609)
This commit is contained in:
parent
9a6268050f
commit
cdbf60e883
@ -251,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.number.set(Some(number));
|
||||
elem.number.set(Smart::Custom(number));
|
||||
}
|
||||
Ok(elem.pack())
|
||||
}
|
||||
|
@ -103,7 +103,7 @@ const ENUM_RULE: ShowFn<EnumElem> = |elem, _, styles| {
|
||||
|
||||
let body = Content::sequence(elem.children.iter().map(|item| {
|
||||
let mut li = HtmlElem::new(tag::li);
|
||||
if let Some(nr) = item.number.get(styles) {
|
||||
if let Smart::Custom(nr) = item.number.get(styles) {
|
||||
li = li.with_attr(attr::value, eco_format!("{nr}"));
|
||||
}
|
||||
// Text in wide enums shall always turn into paragraphs.
|
||||
|
@ -220,7 +220,7 @@ impl EnumElem {
|
||||
pub struct EnumItem {
|
||||
/// The item's number.
|
||||
#[positional]
|
||||
pub number: Option<u64>,
|
||||
pub number: Smart<u64>,
|
||||
|
||||
/// The item's body.
|
||||
#[required]
|
||||
|
BIN
tests/ref/enum-item-number-optional.png
Normal file
BIN
tests/ref/enum-item-number-optional.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 474 B |
@ -56,6 +56,10 @@ a + 0.
|
||||
enum.item(5)[Fifth]
|
||||
)
|
||||
|
||||
--- enum-item-number-optional ---
|
||||
#enum.item[First]
|
||||
#enum.item[Second]
|
||||
|
||||
--- enum-numbering-pattern ---
|
||||
// Test numbering pattern.
|
||||
#set enum(numbering: "(1.a.*)")
|
||||
@ -217,7 +221,7 @@ a + 0.
|
||||
|
||||
--- issue-2530-enum-item-panic ---
|
||||
// Enum item (pre-emptive)
|
||||
#enum.item(none)[Hello]
|
||||
#enum.item(auto)[Hello]
|
||||
#enum.item(17)[Hello]
|
||||
|
||||
--- issue-5503-enum-in-align ---
|
||||
|
Loading…
x
Reference in New Issue
Block a user