Skip to content

Commit

Permalink
feat(core): Add px unit as 0.75pt as per CSS3
Browse files Browse the repository at this point in the history
We long did without it, but MathML examples may contain lengths in px.
And we'll be happy too with other uses cases such as Markdown etc.
This might break some code as SILE.types.length can ignore the unknown
unit and the raw number value would thus be regarded as being in pt.
But that's rather a parsing bug anyway, and SILE.types.measurement spits
an error, so let's not care.
  • Loading branch information
Omikhleia authored and alerque committed Nov 2, 2024
1 parent f4c513a commit 59f4bfd
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions types/unit.lua
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,13 @@ unittypes["pc"] = {
definition = "0.166666667in",
}

-- Pixel, by convention 1px = 1/96in = 0.75pt
-- (CSS Values and Units Module Level 3, §5.2)
-- Used in MathML, etc.
unittypes["px"] = {
definition = "0.75pt",
}

local checkPaperDefined = function ()
if not SILE.documentState or not SILE.documentState.orgPaperSize then
SU.error("A measurement tried to measure the paper size before the paper was defined", true)
Expand Down

0 comments on commit 59f4bfd

Please sign in to comment.