Change enum.item.number to Smart instead of Option (#6609)

This commit is contained in:
Malo 2025-07-16 09:05:52 +01:00 committed by GitHub
parent 9a6268050f
commit cdbf60e883
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 8 additions and 4 deletions

View File

@ -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())
}

View File

@ -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.

View File

@ -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]

Binary file not shown.

After

Width:  |  Height:  |  Size: 474 B

View File

@ -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 ---