Skip to content

Commit

Permalink
engine_spx2html: avoid emitting negative padding values, which are il…
Browse files Browse the repository at this point in the history
…legal
  • Loading branch information
pkgw committed Jun 11, 2023
1 parent 543dc2a commit 58c5a0a
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion crates/engine_spx2html/src/emission.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1172,14 +1172,20 @@ impl EmittingState {

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

// Negative padding values are illegal.
let pad_left = match -x_min_tex as f32 * self.rems_per_tex {
pl if pl <= 0.0 => 0.0,
pl => pl,
};

write!(
self.content,
"<{} class=\"canvas {}\" style=\"width: {}rem; height: {}rem; padding-left: {}rem{}\">",
element.name(),
layout_class,
(x_max_tex - x_min_tex) as f32 * self.rems_per_tex,
(y_max_tex - y_min_tex) as f32 * self.rems_per_tex,
-x_min_tex as f32 * self.rems_per_tex,
pad_left,
valign,
)
.unwrap();
Expand Down

0 comments on commit 58c5a0a

Please sign in to comment.