frontend: check that a sized figure keeps its own shape

The size is a width and nothing else, so the height comes from the picture's
aspect ratio and a figure cannot be deformed. That is worth asserting rather
than assuming, in both halves: the shape the browser actually drew, and that no
height was written into the style at all.

Measured on the paper this was built for, which now has all sixteen of its
figures at 50%: 638px wide each, aspect ratio within 0.2% of the file's own — the
rounding of the measurement, not the layout.
This commit is contained in:
2026-09-24 12:46:10 +08:00
parent 48f0c12fd2
commit b19f28492e
2 changed files with 26 additions and 1 deletions
+7 -1
View File
@@ -413,7 +413,13 @@ line":
The size is optional and comes from pandoc's attribute form — `{width=70%}`,
`{width=400px}` — and is validated to digits plus one unit before it becomes a
CSS length, so no second declaration can be smuggled through it. A bare number
CSS length, so no second declaration can be smuggled through it. It is a
**width and only a width**: the height is whatever keeps the picture's own shape,
which is why a figure can be resized but not stretched, and why the format has
nowhere to put a second number even if a writer wanted one. Measured on the
sixteen figures of the paper this was built for, every drawn rectangle matched
its picture's aspect ratio to within 0.2% — the rounding of the measurement,
not the layout. A bare number
is a **share of the column**, because `parseImageWidth` only reads a value as
pixels when it says `px`; the MCP tool that writes the same attribute follows
that rule rather than inventing its own.