mirror of
https://github.com/typst/typst
synced 2025-06-22 21:32:52 +08:00
Encode empty attributes with shorthand syntax
This commit is contained in:
parent
f364b3c323
commit
fee6844045
@ -69,6 +69,10 @@ fn write_element(w: &mut Writer, element: &HtmlElement) -> SourceResult<()> {
|
|||||||
for (attr, value) in &element.attrs.0 {
|
for (attr, value) in &element.attrs.0 {
|
||||||
w.buf.push(' ');
|
w.buf.push(' ');
|
||||||
w.buf.push_str(&attr.resolve());
|
w.buf.push_str(&attr.resolve());
|
||||||
|
|
||||||
|
// If the string is empty, we can use shorthand syntax.
|
||||||
|
// `<elem attr="">..</div` is equivalent to `<elem attr>..</div>`
|
||||||
|
if !value.is_empty() {
|
||||||
w.buf.push('=');
|
w.buf.push('=');
|
||||||
w.buf.push('"');
|
w.buf.push('"');
|
||||||
for c in value.chars() {
|
for c in value.chars() {
|
||||||
@ -80,6 +84,7 @@ fn write_element(w: &mut Writer, element: &HtmlElement) -> SourceResult<()> {
|
|||||||
}
|
}
|
||||||
w.buf.push('"');
|
w.buf.push('"');
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
w.buf.push('>');
|
w.buf.push('>');
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user