Skip to content

Commit

Permalink
Merge pull request #1052 from pkgw/html-fixes
Browse files Browse the repository at this point in the history
Squeeze in a couple of HTML fixes
  • Loading branch information
pkgw committed Jun 11, 2023
2 parents 4e81df6 + 58c5a0a commit ff9f29e
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion crates/engine_spx2html/src/emission.rs
Original file line number Diff line number Diff line change
Expand Up @@ -424,6 +424,8 @@ impl EmittingState {
match special {
Special::AutoStartParagraph => {
if self.cur_elstate().do_auto_tags {
self.close_automatics();

// Why are we using <div>s instead of <p>? As the HTML spec
// emphasizes, <p> tags are structural, not semantic. You cannot
// put tags like <ul> or <div> inside <p> -- they automatically
Expand Down Expand Up @@ -452,6 +454,7 @@ impl EmittingState {
if let Some(canvas) = self.current_canvas.as_mut() {
canvas.depth += 1;
} else {
self.close_automatics();
self.current_canvas = Some(CanvasState::new(kind, x, y));
}
Ok(())
Expand All @@ -474,6 +477,7 @@ impl EmittingState {
}

Special::ManualFlexibleStart(spec) => {
self.close_automatics();
self.handle_flexible_start_tag(x, y, spec, common)
}

Expand Down Expand Up @@ -1168,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 ff9f29e

Please sign in to comment.