Skip to content

Commit 58c5a0a

Browse files
committed
engine_spx2html: avoid emitting negative padding values, which are illegal
1 parent 543dc2a commit 58c5a0a

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

crates/engine_spx2html/src/emission.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1172,14 +1172,20 @@ impl EmittingState {
11721172

11731173
let element = self.create_elem(element, true, common);
11741174

1175+
// Negative padding values are illegal.
1176+
let pad_left = match -x_min_tex as f32 * self.rems_per_tex {
1177+
pl if pl <= 0.0 => 0.0,
1178+
pl => pl,
1179+
};
1180+
11751181
write!(
11761182
self.content,
11771183
"<{} class=\"canvas {}\" style=\"width: {}rem; height: {}rem; padding-left: {}rem{}\">",
11781184
element.name(),
11791185
layout_class,
11801186
(x_max_tex - x_min_tex) as f32 * self.rems_per_tex,
11811187
(y_max_tex - y_min_tex) as f32 * self.rems_per_tex,
1182-
-x_min_tex as f32 * self.rems_per_tex,
1188+
pad_left,
11831189
valign,
11841190
)
11851191
.unwrap();

0 commit comments

Comments
 (0)