pub fn css_length(length: &Length) -> StringExpand description
Returns length spelled as a CSS length: a length in tabs as
calc(<amount> * var(--flm-tab)) (TAB_PROPERTY), a length of any
other unit as written, amount then unit (1.5em, 10pt, 3mm,
0.25in, 2cm).
The vocabulary’s units other than the tab are CSS’s own, spelled as CSS
spells them, and its point is CSS’s point, 1/72 inch. The amount is
written in the decimal the length projects as — the shortest that reads
back to the same exact amount — so the output is byte-identical wherever
it is produced. This is the only way a length is written on the page; the
emitter writes it as the value of a custom property (Written::Style).
§Examples
use flm_core::stdlib::backends::html::conventions::css_length;
use flm_core::stdlib::backends::pres::Length;
assert_eq!(css_length(&Length::tabs(2)), "calc(2 * var(--flm-tab))");
assert_eq!(css_length(&Length::parse("1.5em")?), "1.5em");
assert_eq!(css_length(&Length::parse("10pt")?), "10pt");