Skip to content

Commit ff9f29e

Browse files
authored
Merge pull request #1052 from pkgw/html-fixes
Squeeze in a couple of HTML fixes
2 parents 4e81df6 + 58c5a0a commit ff9f29e

1 file changed

Lines changed: 11 additions & 1 deletion

File tree

crates/engine_spx2html/src/emission.rs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -424,6 +424,8 @@ impl EmittingState {
424424
match special {
425425
Special::AutoStartParagraph => {
426426
if self.cur_elstate().do_auto_tags {
427+
self.close_automatics();
428+
427429
// Why are we using <div>s instead of <p>? As the HTML spec
428430
// emphasizes, <p> tags are structural, not semantic. You cannot
429431
// put tags like <ul> or <div> inside <p> -- they automatically
@@ -452,6 +454,7 @@ impl EmittingState {
452454
if let Some(canvas) = self.current_canvas.as_mut() {
453455
canvas.depth += 1;
454456
} else {
457+
self.close_automatics();
455458
self.current_canvas = Some(CanvasState::new(kind, x, y));
456459
}
457460
Ok(())
@@ -474,6 +477,7 @@ impl EmittingState {
474477
}
475478

476479
Special::ManualFlexibleStart(spec) => {
480+
self.close_automatics();
477481
self.handle_flexible_start_tag(x, y, spec, common)
478482
}
479483

@@ -1168,14 +1172,20 @@ impl EmittingState {
11681172

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

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+
11711181
write!(
11721182
self.content,
11731183
"<{} class=\"canvas {}\" style=\"width: {}rem; height: {}rem; padding-left: {}rem{}\">",
11741184
element.name(),
11751185
layout_class,
11761186
(x_max_tex - x_min_tex) as f32 * self.rems_per_tex,
11771187
(y_max_tex - y_min_tex) as f32 * self.rems_per_tex,
1178-
-x_min_tex as f32 * self.rems_per_tex,
1188+
pad_left,
11791189
valign,
11801190
)
11811191
.unwrap();

0 commit comments

Comments
 (0)