mirror of
https://github.com/typst/typst
synced 2025-05-14 17:15:28 +08:00
Support start
attribute for enum
in HTML export (#5676)
This commit is contained in:
parent
dda486a412
commit
e61cd6fb9e
@ -229,19 +229,19 @@ impl Show for Packed<EnumElem> {
|
||||
if TargetElem::target_in(styles).is_html() {
|
||||
let mut elem = HtmlElem::new(tag::ol);
|
||||
if self.reversed(styles) {
|
||||
elem =
|
||||
elem.with_attr(const { HtmlAttr::constant("reversed") }, "reversed");
|
||||
elem = elem.with_attr(HtmlAttr::constant("reversed"), "reversed");
|
||||
}
|
||||
return Ok(elem
|
||||
.with_body(Some(Content::sequence(self.children.iter().map(|item| {
|
||||
if let Some(n) = self.start(styles).custom() {
|
||||
elem = elem.with_attr(HtmlAttr::constant("start"), eco_format!("{n}"));
|
||||
}
|
||||
let body = Content::sequence(self.children.iter().map(|item| {
|
||||
let mut li = HtmlElem::new(tag::li);
|
||||
if let Some(nr) = item.number(styles) {
|
||||
li = li.with_attr(attr::value, eco_format!("{nr}"));
|
||||
}
|
||||
li.with_body(Some(item.body.clone())).pack().spanned(item.span())
|
||||
}))))
|
||||
.pack()
|
||||
.spanned(self.span()));
|
||||
}));
|
||||
return Ok(elem.with_body(Some(body)).pack().spanned(self.span()));
|
||||
}
|
||||
|
||||
let mut realized =
|
||||
|
12
tests/ref/html/enum-start.html
Normal file
12
tests/ref/html/enum-start.html
Normal file
@ -0,0 +1,12 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
</head>
|
||||
<body>
|
||||
<ol start="3">
|
||||
<li>Skipping</li><li>Ahead</li>
|
||||
</ol>
|
||||
</body>
|
||||
</html>
|
@ -101,6 +101,13 @@ a + 0.
|
||||
[Red], [Green], [Blue], [Red],
|
||||
)
|
||||
|
||||
--- enum-start html ---
|
||||
#enum(
|
||||
start: 3,
|
||||
[Skipping],
|
||||
[Ahead],
|
||||
)
|
||||
|
||||
--- enum-numbering-closure-nested ---
|
||||
// Test numbering with closure and nested lists.
|
||||
#set enum(numbering: n => super[#n])
|
||||
|
Loading…
x
Reference in New Issue
Block a user