pulpweaver4 0.0.0-stage → 0.0.91
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/ast/djot.d.ts +124 -0
- package/dist/ast/djot.js +464 -0
- package/dist/ast/djot.js.map +1 -0
- package/dist/ast/index.d.ts +10 -0
- package/dist/ast/index.js +11 -0
- package/dist/ast/index.js.map +1 -0
- package/dist/ast/locator.d.ts +27 -0
- package/dist/ast/locator.js +77 -0
- package/dist/ast/locator.js.map +1 -0
- package/dist/ast/nodes.d.ts +543 -0
- package/dist/ast/nodes.js +56 -0
- package/dist/ast/nodes.js.map +1 -0
- package/dist/ast/position.d.ts +88 -0
- package/dist/ast/position.js +98 -0
- package/dist/ast/position.js.map +1 -0
- package/dist/ast/traverse.d.ts +12 -0
- package/dist/ast/traverse.js +37 -0
- package/dist/ast/traverse.js.map +1 -0
- package/dist/bibliography/biblatex.d.ts +13 -0
- package/dist/bibliography/biblatex.js +849 -0
- package/dist/bibliography/biblatex.js.map +1 -0
- package/dist/bibliography/bibtex.d.ts +39 -0
- package/dist/bibliography/bibtex.js +259 -0
- package/dist/bibliography/bibtex.js.map +1 -0
- package/dist/bibliography/csl.d.ts +9 -0
- package/dist/bibliography/csl.js +241 -0
- package/dist/bibliography/csl.js.map +1 -0
- package/dist/bibliography/dates.d.ts +33 -0
- package/dist/bibliography/dates.js +223 -0
- package/dist/bibliography/dates.js.map +1 -0
- package/dist/bibliography/index.d.ts +8 -0
- package/dist/bibliography/index.js +9 -0
- package/dist/bibliography/index.js.map +1 -0
- package/dist/bibliography/item.d.ts +142 -0
- package/dist/bibliography/item.js +181 -0
- package/dist/bibliography/item.js.map +1 -0
- package/dist/bibliography/latex.d.ts +21 -0
- package/dist/bibliography/latex.js +586 -0
- package/dist/bibliography/latex.js.map +1 -0
- package/dist/bibliography/names.d.ts +23 -0
- package/dist/bibliography/names.js +244 -0
- package/dist/bibliography/names.js.map +1 -0
- package/dist/bibliography/read.d.ts +24 -0
- package/dist/bibliography/read.js +50 -0
- package/dist/bibliography/read.js.map +1 -0
- package/dist/citations/book.d.ts +93 -0
- package/dist/citations/book.js +217 -0
- package/dist/citations/book.js.map +1 -0
- package/dist/citations/collect.d.ts +56 -0
- package/dist/citations/collect.js +129 -0
- package/dist/citations/collect.js.map +1 -0
- package/dist/citations/hast.d.ts +12 -0
- package/dist/citations/hast.js +49 -0
- package/dist/citations/hast.js.map +1 -0
- package/dist/citations/index.d.ts +14 -0
- package/dist/citations/index.js +15 -0
- package/dist/citations/index.js.map +1 -0
- package/dist/citations/lint.d.ts +70 -0
- package/dist/citations/lint.js +92 -0
- package/dist/citations/lint.js.map +1 -0
- package/dist/citations/notes.d.ts +11 -0
- package/dist/citations/notes.js +163 -0
- package/dist/citations/notes.js.map +1 -0
- package/dist/citations/positions.d.ts +34 -0
- package/dist/citations/positions.js +90 -0
- package/dist/citations/positions.js.map +1 -0
- package/dist/citations/project.d.ts +7 -0
- package/dist/citations/project.js +24 -0
- package/dist/citations/project.js.map +1 -0
- package/dist/colour/cmyk.d.ts +71 -0
- package/dist/colour/cmyk.js +210 -0
- package/dist/colour/cmyk.js.map +1 -0
- package/dist/colour/images.d.ts +36 -0
- package/dist/colour/images.js +106 -0
- package/dist/colour/images.js.map +1 -0
- package/dist/colour/index.d.ts +7 -0
- package/dist/colour/index.js +8 -0
- package/dist/colour/index.js.map +1 -0
- package/dist/colour/ink-limit.d.ts +68 -0
- package/dist/colour/ink-limit.js +109 -0
- package/dist/colour/ink-limit.js.map +1 -0
- package/dist/colour/intents.d.ts +145 -0
- package/dist/colour/intents.js +193 -0
- package/dist/colour/intents.js.map +1 -0
- package/dist/colour/lcms.d.ts +79 -0
- package/dist/colour/lcms.js +229 -0
- package/dist/colour/lcms.js.map +1 -0
- package/dist/colour/previews.d.ts +49 -0
- package/dist/colour/previews.js +116 -0
- package/dist/colour/previews.js.map +1 -0
- package/dist/colour/wasm/LICENSE-lcms2 +22 -0
- package/dist/colour/wasm/lcms2.wasm +0 -0
- package/dist/config/config.d.ts +114 -0
- package/dist/config/config.js +309 -0
- package/dist/config/config.js.map +1 -0
- package/dist/config/index.d.ts +6 -0
- package/dist/config/index.js +7 -0
- package/dist/config/index.js.map +1 -0
- package/dist/config/page.d.ts +42 -0
- package/dist/config/page.js +95 -0
- package/dist/config/page.js.map +1 -0
- package/dist/config/project-schema.d.ts +23 -0
- package/dist/config/project-schema.js +223 -0
- package/dist/config/project-schema.js.map +1 -0
- package/dist/config/schema.d.ts +68 -0
- package/dist/config/schema.js +333 -0
- package/dist/config/schema.js.map +1 -0
- package/dist/config/toml.d.ts +54 -0
- package/dist/config/toml.js +238 -0
- package/dist/config/toml.js.map +1 -0
- package/dist/contents/index.d.ts +8 -0
- package/dist/contents/index.js +9 -0
- package/dist/contents/index.js.map +1 -0
- package/dist/contents/transform.d.ts +64 -0
- package/dist/contents/transform.js +149 -0
- package/dist/contents/transform.js.map +1 -0
- package/dist/csl/affix.d.ts +16 -0
- package/dist/csl/affix.js +74 -0
- package/dist/csl/affix.js.map +1 -0
- package/dist/csl/data/chicago-author-date.d.ts +2 -0
- package/dist/csl/data/chicago-author-date.js +3 -0
- package/dist/csl/data/chicago-author-date.js.map +1 -0
- package/dist/csl/data/chicago-notes-bibliography.d.ts +2 -0
- package/dist/csl/data/chicago-notes-bibliography.js +3 -0
- package/dist/csl/data/chicago-notes-bibliography.js.map +1 -0
- package/dist/csl/data/locales-en-GB.d.ts +2 -0
- package/dist/csl/data/locales-en-GB.js +3 -0
- package/dist/csl/data/locales-en-GB.js.map +1 -0
- package/dist/csl/data/locales-en-US.d.ts +2 -0
- package/dist/csl/data/locales-en-US.js +3 -0
- package/dist/csl/data/locales-en-US.js.map +1 -0
- package/dist/csl/dates.d.ts +30 -0
- package/dist/csl/dates.js +223 -0
- package/dist/csl/dates.js.map +1 -0
- package/dist/csl/format.d.ts +29 -0
- package/dist/csl/format.js +157 -0
- package/dist/csl/format.js.map +1 -0
- package/dist/csl/index.d.ts +26 -0
- package/dist/csl/index.js +16 -0
- package/dist/csl/index.js.map +1 -0
- package/dist/csl/ir.d.ts +103 -0
- package/dist/csl/ir.js +549 -0
- package/dist/csl/ir.js.map +1 -0
- package/dist/csl/load.d.ts +98 -0
- package/dist/csl/load.js +163 -0
- package/dist/csl/load.js.map +1 -0
- package/dist/csl/locale.d.ts +90 -0
- package/dist/csl/locale.js +251 -0
- package/dist/csl/locale.js.map +1 -0
- package/dist/csl/names.d.ts +41 -0
- package/dist/csl/names.js +203 -0
- package/dist/csl/names.js.map +1 -0
- package/dist/csl/numbers.d.ts +48 -0
- package/dist/csl/numbers.js +170 -0
- package/dist/csl/numbers.js.map +1 -0
- package/dist/csl/processor.d.ts +179 -0
- package/dist/csl/processor.js +765 -0
- package/dist/csl/processor.js.map +1 -0
- package/dist/csl/project.d.ts +21 -0
- package/dist/csl/project.js +85 -0
- package/dist/csl/project.js.map +1 -0
- package/dist/csl/render.d.ts +130 -0
- package/dist/csl/render.js +748 -0
- package/dist/csl/render.js.map +1 -0
- package/dist/csl/style.d.ts +168 -0
- package/dist/csl/style.js +262 -0
- package/dist/csl/style.js.map +1 -0
- package/dist/csl/xml.d.ts +28 -0
- package/dist/csl/xml.js +162 -0
- package/dist/csl/xml.js.map +1 -0
- package/dist/djot/djot.js/LICENSE +20 -0
- package/dist/djot/djot.js/src/ast.d.ts +327 -0
- package/dist/djot/djot.js/src/ast.js +68 -0
- package/dist/djot/djot.js/src/ast.js.map +1 -0
- package/dist/djot/djot.js/src/attributes.d.ts +31 -0
- package/dist/djot/djot.js/src/attributes.js +300 -0
- package/dist/djot/djot.js/src/attributes.js.map +1 -0
- package/dist/djot/djot.js/src/block.d.ts +87 -0
- package/dist/djot/djot.js/src/block.js +1201 -0
- package/dist/djot/djot.js/src/block.js.map +1 -0
- package/dist/djot/djot.js/src/djot-renderer.d.ts +8 -0
- package/dist/djot/djot.js/src/djot-renderer.js +755 -0
- package/dist/djot/djot.js/src/djot-renderer.js.map +1 -0
- package/dist/djot/djot.js/src/event.d.ts +6 -0
- package/dist/djot/djot.js/src/event.js +2 -0
- package/dist/djot/djot.js/src/event.js.map +1 -0
- package/dist/djot/djot.js/src/filter.d.ts +13 -0
- package/dist/djot/djot.js/src/filter.js +159 -0
- package/dist/djot/djot.js/src/filter.js.map +1 -0
- package/dist/djot/djot.js/src/find.d.ts +7 -0
- package/dist/djot/djot.js/src/find.js +33 -0
- package/dist/djot/djot.js/src/find.js.map +1 -0
- package/dist/djot/djot.js/src/html.d.ts +40 -0
- package/dist/djot/djot.js/src/html.js +657 -0
- package/dist/djot/djot.js/src/html.js.map +1 -0
- package/dist/djot/djot.js/src/index.d.ts +9 -0
- package/dist/djot/djot.js/src/index.js +9 -0
- package/dist/djot/djot.js/src/index.js.map +1 -0
- package/dist/djot/djot.js/src/inline.d.ts +62 -0
- package/dist/djot/djot.js/src/inline.js +1032 -0
- package/dist/djot/djot.js/src/inline.js.map +1 -0
- package/dist/djot/djot.js/src/options.d.ts +13 -0
- package/dist/djot/djot.js/src/options.js +27 -0
- package/dist/djot/djot.js/src/options.js.map +1 -0
- package/dist/djot/djot.js/src/pandoc.d.ts +20 -0
- package/dist/djot/djot.js/src/pandoc.js +1110 -0
- package/dist/djot/djot.js/src/pandoc.js.map +1 -0
- package/dist/djot/djot.js/src/parse.d.ts +19 -0
- package/dist/djot/djot.js/src/parse.js +1445 -0
- package/dist/djot/djot.js/src/parse.js.map +1 -0
- package/dist/djot/djot.js/src/version.d.ts +1 -0
- package/dist/djot/djot.js/src/version.js +2 -0
- package/dist/djot/djot.js/src/version.js.map +1 -0
- package/dist/djot/index.d.ts +5 -0
- package/dist/djot/index.js +6 -0
- package/dist/djot/index.js.map +1 -0
- package/dist/djot/read.d.ts +57 -0
- package/dist/djot/read.js +146 -0
- package/dist/djot/read.js.map +1 -0
- package/dist/fonts/css.d.ts +82 -0
- package/dist/fonts/css.js +329 -0
- package/dist/fonts/css.js.map +1 -0
- package/dist/fonts/faces.d.ts +101 -0
- package/dist/fonts/faces.js +226 -0
- package/dist/fonts/faces.js.map +1 -0
- package/dist/fonts/index.d.ts +12 -0
- package/dist/fonts/index.js +13 -0
- package/dist/fonts/index.js.map +1 -0
- package/dist/fonts/lint.d.ts +58 -0
- package/dist/fonts/lint.js +209 -0
- package/dist/fonts/lint.js.map +1 -0
- package/dist/fonts/match.d.ts +36 -0
- package/dist/fonts/match.js +104 -0
- package/dist/fonts/match.js.map +1 -0
- package/dist/fonts/names.d.ts +9 -0
- package/dist/fonts/names.js +50 -0
- package/dist/fonts/names.js.map +1 -0
- package/dist/fonts/subset.d.ts +72 -0
- package/dist/fonts/subset.js +169 -0
- package/dist/fonts/subset.js.map +1 -0
- package/dist/fonts/walk.d.ts +33 -0
- package/dist/fonts/walk.js +120 -0
- package/dist/fonts/walk.js.map +1 -0
- package/dist/fonts/wasm/LICENSE-harfbuzzjs +19 -0
- package/dist/fonts/wasm/harfbuzz-subset.wasm +0 -0
- package/dist/html/check.d.ts +62 -0
- package/dist/html/check.js +186 -0
- package/dist/html/check.js.map +1 -0
- package/dist/html/counters.d.ts +32 -0
- package/dist/html/counters.js +72 -0
- package/dist/html/counters.js.map +1 -0
- package/dist/html/css.d.ts +33 -0
- package/dist/html/css.js +72 -0
- package/dist/html/css.js.map +1 -0
- package/dist/html/dom.d.ts +28 -0
- package/dist/html/dom.js +162 -0
- package/dist/html/dom.js.map +1 -0
- package/dist/html/editions.d.ts +26 -0
- package/dist/html/editions.js +57 -0
- package/dist/html/editions.js.map +1 -0
- package/dist/html/images.d.ts +13 -0
- package/dist/html/images.js +62 -0
- package/dist/html/images.js.map +1 -0
- package/dist/html/index.d.ts +14 -0
- package/dist/html/index.js +15 -0
- package/dist/html/index.js.map +1 -0
- package/dist/html/registry.d.ts +120 -0
- package/dist/html/registry.js +48 -0
- package/dist/html/registry.js.map +1 -0
- package/dist/html/render.d.ts +99 -0
- package/dist/html/render.js +694 -0
- package/dist/html/render.js.map +1 -0
- package/dist/hyphenation/NOTICE +429 -0
- package/dist/hyphenation/exceptions.d.ts +60 -0
- package/dist/hyphenation/exceptions.js +79 -0
- package/dist/hyphenation/exceptions.js.map +1 -0
- package/dist/hyphenation/hyphenator.d.ts +66 -0
- package/dist/hyphenation/hyphenator.js +245 -0
- package/dist/hyphenation/hyphenator.js.map +1 -0
- package/dist/hyphenation/index.d.ts +4 -0
- package/dist/hyphenation/index.js +5 -0
- package/dist/hyphenation/index.js.map +1 -0
- package/dist/hyphenation/languages.d.ts +20 -0
- package/dist/hyphenation/languages.js +75 -0
- package/dist/hyphenation/languages.js.map +1 -0
- package/dist/hyphenation/patterns/af.wasm +0 -0
- package/dist/hyphenation/patterns/as.wasm +0 -0
- package/dist/hyphenation/patterns/be.wasm +0 -0
- package/dist/hyphenation/patterns/bg.wasm +0 -0
- package/dist/hyphenation/patterns/bn.wasm +0 -0
- package/dist/hyphenation/patterns/ca.wasm +0 -0
- package/dist/hyphenation/patterns/cy.wasm +0 -0
- package/dist/hyphenation/patterns/da.wasm +0 -0
- package/dist/hyphenation/patterns/de.wasm +0 -0
- package/dist/hyphenation/patterns/el-monoton.wasm +0 -0
- package/dist/hyphenation/patterns/el-polyton.wasm +0 -0
- package/dist/hyphenation/patterns/en-gb.wasm +0 -0
- package/dist/hyphenation/patterns/en-us.wasm +0 -0
- package/dist/hyphenation/patterns/eo.wasm +0 -0
- package/dist/hyphenation/patterns/es.wasm +0 -0
- package/dist/hyphenation/patterns/et.wasm +0 -0
- package/dist/hyphenation/patterns/eu.wasm +0 -0
- package/dist/hyphenation/patterns/fi-x-school.wasm +0 -0
- package/dist/hyphenation/patterns/fr.wasm +0 -0
- package/dist/hyphenation/patterns/fur.wasm +0 -0
- package/dist/hyphenation/patterns/ga.wasm +0 -0
- package/dist/hyphenation/patterns/gl.wasm +0 -0
- package/dist/hyphenation/patterns/gu.wasm +0 -0
- package/dist/hyphenation/patterns/hi.wasm +0 -0
- package/dist/hyphenation/patterns/hr.wasm +0 -0
- package/dist/hyphenation/patterns/hsb.wasm +0 -0
- package/dist/hyphenation/patterns/ia.wasm +0 -0
- package/dist/hyphenation/patterns/is.wasm +0 -0
- package/dist/hyphenation/patterns/it.wasm +0 -0
- package/dist/hyphenation/patterns/ka.wasm +0 -0
- package/dist/hyphenation/patterns/kmr.wasm +0 -0
- package/dist/hyphenation/patterns/kn.wasm +0 -0
- package/dist/hyphenation/patterns/la.wasm +0 -0
- package/dist/hyphenation/patterns/lt.wasm +0 -0
- package/dist/hyphenation/patterns/ml.wasm +0 -0
- package/dist/hyphenation/patterns/mn-cyrl.wasm +0 -0
- package/dist/hyphenation/patterns/mr.wasm +0 -0
- package/dist/hyphenation/patterns/nb.wasm +0 -0
- package/dist/hyphenation/patterns/nl.wasm +0 -0
- package/dist/hyphenation/patterns/nn.wasm +0 -0
- package/dist/hyphenation/patterns/no.wasm +0 -0
- package/dist/hyphenation/patterns/oc.wasm +0 -0
- package/dist/hyphenation/patterns/or.wasm +0 -0
- package/dist/hyphenation/patterns/pa.wasm +0 -0
- package/dist/hyphenation/patterns/pi.wasm +0 -0
- package/dist/hyphenation/patterns/pl.wasm +0 -0
- package/dist/hyphenation/patterns/pms.wasm +0 -0
- package/dist/hyphenation/patterns/pt.wasm +0 -0
- package/dist/hyphenation/patterns/rm.wasm +0 -0
- package/dist/hyphenation/patterns/ru.wasm +0 -0
- package/dist/hyphenation/patterns/sh-cyrl.wasm +0 -0
- package/dist/hyphenation/patterns/sh-latn.wasm +0 -0
- package/dist/hyphenation/patterns/sk.wasm +0 -0
- package/dist/hyphenation/patterns/sl.wasm +0 -0
- package/dist/hyphenation/patterns/sq.wasm +0 -0
- package/dist/hyphenation/patterns/sv.wasm +0 -0
- package/dist/hyphenation/patterns/ta.wasm +0 -0
- package/dist/hyphenation/patterns/te.wasm +0 -0
- package/dist/hyphenation/patterns/th.wasm +0 -0
- package/dist/hyphenation/patterns/tk.wasm +0 -0
- package/dist/hyphenation/patterns/tr.wasm +0 -0
- package/dist/hyphenation/patterns/uk.wasm +0 -0
- package/dist/hyphenation/patterns/zh-latn-pinyin.wasm +0 -0
- package/dist/index.d.ts +47 -0
- package/dist/index.js +48 -0
- package/dist/index.js.map +1 -0
- package/dist/indexes/index.d.ts +10 -0
- package/dist/indexes/index.js +11 -0
- package/dist/indexes/index.js.map +1 -0
- package/dist/indexes/layout.d.ts +30 -0
- package/dist/indexes/layout.js +83 -0
- package/dist/indexes/layout.js.map +1 -0
- package/dist/indexes/locators.d.ts +33 -0
- package/dist/indexes/locators.js +51 -0
- package/dist/indexes/locators.js.map +1 -0
- package/dist/indexes/terms.d.ts +97 -0
- package/dist/indexes/terms.js +211 -0
- package/dist/indexes/terms.js.map +1 -0
- package/dist/indexes/transform.d.ts +90 -0
- package/dist/indexes/transform.js +154 -0
- package/dist/indexes/transform.js.map +1 -0
- package/dist/layout/calibrate.d.ts +12 -0
- package/dist/layout/calibrate.js +50 -0
- package/dist/layout/calibrate.js.map +1 -0
- package/dist/layout/converge.d.ts +31 -0
- package/dist/layout/converge.js +84 -0
- package/dist/layout/converge.js.map +1 -0
- package/dist/layout/counters.d.ts +16 -0
- package/dist/layout/counters.js +62 -0
- package/dist/layout/counters.js.map +1 -0
- package/dist/layout/first-letter.d.ts +34 -0
- package/dist/layout/first-letter.js +183 -0
- package/dist/layout/first-letter.js.map +1 -0
- package/dist/layout/fonts.d.ts +67 -0
- package/dist/layout/fonts.js +110 -0
- package/dist/layout/fonts.js.map +1 -0
- package/dist/layout/generated.d.ts +9 -0
- package/dist/layout/generated.js +83 -0
- package/dist/layout/generated.js.map +1 -0
- package/dist/layout/glue.d.ts +18 -0
- package/dist/layout/glue.js +48 -0
- package/dist/layout/glue.js.map +1 -0
- package/dist/layout/index.d.ts +17 -0
- package/dist/layout/index.js +18 -0
- package/dist/layout/index.js.map +1 -0
- package/dist/layout/lists.d.ts +91 -0
- package/dist/layout/lists.js +1068 -0
- package/dist/layout/lists.js.map +1 -0
- package/dist/layout/margin-boxes.d.ts +114 -0
- package/dist/layout/margin-boxes.js +429 -0
- package/dist/layout/margin-boxes.js.map +1 -0
- package/dist/layout/minipage.d.ts +85 -0
- package/dist/layout/minipage.js +83 -0
- package/dist/layout/minipage.js.map +1 -0
- package/dist/layout/page-box.d.ts +34 -0
- package/dist/layout/page-box.js +112 -0
- package/dist/layout/page-box.js.map +1 -0
- package/dist/layout/page-rules.d.ts +49 -0
- package/dist/layout/page-rules.js +205 -0
- package/dist/layout/page-rules.js.map +1 -0
- package/dist/layout/page.d.ts +51 -0
- package/dist/layout/page.js +133 -0
- package/dist/layout/page.js.map +1 -0
- package/dist/layout/pagebuilder.d.ts +243 -0
- package/dist/layout/pagebuilder.js +591 -0
- package/dist/layout/pagebuilder.js.map +1 -0
- package/dist/layout/pages.d.ts +77 -0
- package/dist/layout/pages.js +772 -0
- package/dist/layout/pages.js.map +1 -0
- package/dist/layout/paragraph.d.ts +194 -0
- package/dist/layout/paragraph.js +1148 -0
- package/dist/layout/paragraph.js.map +1 -0
- package/dist/layout/pre.d.ts +8 -0
- package/dist/layout/pre.js +151 -0
- package/dist/layout/pre.js.map +1 -0
- package/dist/layout/region.d.ts +66 -0
- package/dist/layout/region.js +200 -0
- package/dist/layout/region.js.map +1 -0
- package/dist/layout/vlist.d.ts +218 -0
- package/dist/layout/vlist.js +72 -0
- package/dist/layout/vlist.js.map +1 -0
- package/dist/linebreak/items.d.ts +69 -0
- package/dist/linebreak/items.js +44 -0
- package/dist/linebreak/items.js.map +1 -0
- package/dist/linebreak/knuth-plass.d.ts +149 -0
- package/dist/linebreak/knuth-plass.js +461 -0
- package/dist/linebreak/knuth-plass.js.map +1 -0
- package/dist/lint/config.d.ts +48 -0
- package/dist/lint/config.js +185 -0
- package/dist/lint/config.js.map +1 -0
- package/dist/lint/context.d.ts +64 -0
- package/dist/lint/context.js +37 -0
- package/dist/lint/context.js.map +1 -0
- package/dist/lint/fix.d.ts +40 -0
- package/dist/lint/fix.js +86 -0
- package/dist/lint/fix.js.map +1 -0
- package/dist/lint/index.d.ts +14 -0
- package/dist/lint/index.js +15 -0
- package/dist/lint/index.js.map +1 -0
- package/dist/lint/linter.d.ts +59 -0
- package/dist/lint/linter.js +239 -0
- package/dist/lint/linter.js.map +1 -0
- package/dist/lint/presets.d.ts +20 -0
- package/dist/lint/presets.js +65 -0
- package/dist/lint/presets.js.map +1 -0
- package/dist/lint/project.d.ts +31 -0
- package/dist/lint/project.js +100 -0
- package/dist/lint/project.js.map +1 -0
- package/dist/lint/rules/html.d.ts +30 -0
- package/dist/lint/rules/html.js +163 -0
- package/dist/lint/rules/html.js.map +1 -0
- package/dist/lint/rules/layout.d.ts +42 -0
- package/dist/lint/rules/layout.js +428 -0
- package/dist/lint/rules/layout.js.map +1 -0
- package/dist/lint/rules/source.d.ts +67 -0
- package/dist/lint/rules/source.js +339 -0
- package/dist/lint/rules/source.js.map +1 -0
- package/dist/lint/testing.d.ts +7 -0
- package/dist/lint/testing.js +77 -0
- package/dist/lint/testing.js.map +1 -0
- package/dist/math/hast.d.ts +46 -0
- package/dist/math/hast.js +297 -0
- package/dist/math/hast.js.map +1 -0
- package/dist/math/index.d.ts +9 -0
- package/dist/math/index.js +10 -0
- package/dist/math/index.js.map +1 -0
- package/dist/math/mathjax/LICENSE-mathjax +202 -0
- package/dist/math/mathjax/LICENSE-speech-rule-engine +177 -0
- package/dist/math/mathjax/sre/af.json +146 -0
- package/dist/math/mathjax/sre/base.json +140 -0
- package/dist/math/mathjax/sre/ca.json +140 -0
- package/dist/math/mathjax/sre/da.json +140 -0
- package/dist/math/mathjax/sre/de.json +146 -0
- package/dist/math/mathjax/sre/en.json +158 -0
- package/dist/math/mathjax/sre/es.json +140 -0
- package/dist/math/mathjax/sre/euro.json +32 -0
- package/dist/math/mathjax/sre/fr.json +146 -0
- package/dist/math/mathjax/sre/hi.json +146 -0
- package/dist/math/mathjax/sre/it.json +146 -0
- package/dist/math/mathjax/sre/ko.json +146 -0
- package/dist/math/mathjax/sre/nb.json +146 -0
- package/dist/math/mathjax/sre/nemeth.json +125 -0
- package/dist/math/mathjax/sre/nn.json +146 -0
- package/dist/math/mathjax/sre/sv.json +146 -0
- package/dist/math/mathjax/svg/PUA.json +1 -0
- package/dist/math/mathjax/svg/accents-b-i.json +1 -0
- package/dist/math/mathjax/svg/accents.json +1 -0
- package/dist/math/mathjax/svg/arabic.json +1 -0
- package/dist/math/mathjax/svg/arrows.json +1 -0
- package/dist/math/mathjax/svg/braille-d.json +1 -0
- package/dist/math/mathjax/svg/braille.json +1 -0
- package/dist/math/mathjax/svg/calligraphic.json +1 -0
- package/dist/math/mathjax/svg/cherokee.json +1 -0
- package/dist/math/mathjax/svg/cyrillic-ss.json +1 -0
- package/dist/math/mathjax/svg/cyrillic.json +1 -0
- package/dist/math/mathjax/svg/devanagari.json +1 -0
- package/dist/math/mathjax/svg/double-struck.json +1 -0
- package/dist/math/mathjax/svg/fraktur.json +1 -0
- package/dist/math/mathjax/svg/greek-ss.json +1 -0
- package/dist/math/mathjax/svg/greek.json +1 -0
- package/dist/math/mathjax/svg/hebrew.json +1 -0
- package/dist/math/mathjax/svg/latin-b.json +1 -0
- package/dist/math/mathjax/svg/latin-bi.json +1 -0
- package/dist/math/mathjax/svg/latin-i.json +1 -0
- package/dist/math/mathjax/svg/latin.json +1 -0
- package/dist/math/mathjax/svg/marrows.json +1 -0
- package/dist/math/mathjax/svg/math.json +1 -0
- package/dist/math/mathjax/svg/monospace-ex.json +1 -0
- package/dist/math/mathjax/svg/monospace-l.json +1 -0
- package/dist/math/mathjax/svg/monospace.json +1 -0
- package/dist/math/mathjax/svg/mshapes.json +1 -0
- package/dist/math/mathjax/svg/phonetics-ss.json +1 -0
- package/dist/math/mathjax/svg/phonetics.json +1 -0
- package/dist/math/mathjax/svg/sans-serif-b.json +1 -0
- package/dist/math/mathjax/svg/sans-serif-bi.json +1 -0
- package/dist/math/mathjax/svg/sans-serif-ex.json +1 -0
- package/dist/math/mathjax/svg/sans-serif-i.json +1 -0
- package/dist/math/mathjax/svg/sans-serif-r.json +1 -0
- package/dist/math/mathjax/svg/sans-serif.json +1 -0
- package/dist/math/mathjax/svg/script.json +1 -0
- package/dist/math/mathjax/svg/shapes.json +1 -0
- package/dist/math/mathjax/svg/symbols-b-i.json +1 -0
- package/dist/math/mathjax/svg/symbols.json +1 -0
- package/dist/math/mathjax/svg/variants.json +1 -0
- package/dist/math/mathjax.d.ts +67 -0
- package/dist/math/mathjax.js +162 -0
- package/dist/math/mathjax.js.map +1 -0
- package/dist/math/speech.d.ts +27 -0
- package/dist/math/speech.js +87 -0
- package/dist/math/speech.js.map +1 -0
- package/dist/math/typeset.d.ts +75 -0
- package/dist/math/typeset.js +108 -0
- package/dist/math/typeset.js.map +1 -0
- package/dist/measure/css.d.ts +44 -0
- package/dist/measure/css.js +158 -0
- package/dist/measure/css.js.map +1 -0
- package/dist/measure/index.d.ts +3 -0
- package/dist/measure/index.js +4 -0
- package/dist/measure/index.js.map +1 -0
- package/dist/measure/measurer.d.ts +159 -0
- package/dist/measure/measurer.js +300 -0
- package/dist/measure/measurer.js.map +1 -0
- package/dist/measure/model.d.ts +46 -0
- package/dist/measure/model.js +47 -0
- package/dist/measure/model.js.map +1 -0
- package/dist/output/assets.d.ts +10 -0
- package/dist/output/assets.js +65 -0
- package/dist/output/assets.js.map +1 -0
- package/dist/output/index.d.ts +4 -0
- package/dist/output/index.js +5 -0
- package/dist/output/index.js.map +1 -0
- package/dist/output/output.d.ts +103 -0
- package/dist/output/output.js +86 -0
- package/dist/output/output.js.map +1 -0
- package/dist/output/stylesheets.d.ts +45 -0
- package/dist/output/stylesheets.js +50 -0
- package/dist/output/stylesheets.js.map +1 -0
- package/dist/paint/backgrounds.d.ts +56 -0
- package/dist/paint/backgrounds.js +261 -0
- package/dist/paint/backgrounds.js.map +1 -0
- package/dist/paint/blend.d.ts +61 -0
- package/dist/paint/blend.js +157 -0
- package/dist/paint/blend.js.map +1 -0
- package/dist/paint/border-image.d.ts +13 -0
- package/dist/paint/border-image.js +149 -0
- package/dist/paint/border-image.js.map +1 -0
- package/dist/paint/borders.d.ts +47 -0
- package/dist/paint/borders.js +329 -0
- package/dist/paint/borders.js.map +1 -0
- package/dist/paint/canvas.d.ts +52 -0
- package/dist/paint/canvas.js +274 -0
- package/dist/paint/canvas.js.map +1 -0
- package/dist/paint/colours.d.ts +55 -0
- package/dist/paint/colours.js +380 -0
- package/dist/paint/colours.js.map +1 -0
- package/dist/paint/columns.d.ts +11 -0
- package/dist/paint/columns.js +42 -0
- package/dist/paint/columns.js.map +1 -0
- package/dist/paint/context.d.ts +47 -0
- package/dist/paint/context.js +2 -0
- package/dist/paint/context.js.map +1 -0
- package/dist/paint/decoration.d.ts +97 -0
- package/dist/paint/decoration.js +280 -0
- package/dist/paint/decoration.js.map +1 -0
- package/dist/paint/effects.d.ts +64 -0
- package/dist/paint/effects.js +342 -0
- package/dist/paint/effects.js.map +1 -0
- package/dist/paint/emphasis.d.ts +13 -0
- package/dist/paint/emphasis.js +95 -0
- package/dist/paint/emphasis.js.map +1 -0
- package/dist/paint/flatten.d.ts +33 -0
- package/dist/paint/flatten.js +968 -0
- package/dist/paint/flatten.js.map +1 -0
- package/dist/paint/geometry.d.ts +62 -0
- package/dist/paint/geometry.js +170 -0
- package/dist/paint/geometry.js.map +1 -0
- package/dist/paint/gradients.d.ts +31 -0
- package/dist/paint/gradients.js +394 -0
- package/dist/paint/gradients.js.map +1 -0
- package/dist/paint/images.d.ts +17 -0
- package/dist/paint/images.js +80 -0
- package/dist/paint/images.js.map +1 -0
- package/dist/paint/lint.d.ts +46 -0
- package/dist/paint/lint.js +105 -0
- package/dist/paint/lint.js.map +1 -0
- package/dist/paint/overprint.d.ts +13 -0
- package/dist/paint/overprint.js +12 -0
- package/dist/paint/overprint.js.map +1 -0
- package/dist/paint/painter.d.ts +92 -0
- package/dist/paint/painter.js +281 -0
- package/dist/paint/painter.js.map +1 -0
- package/dist/paint/path.d.ts +9 -0
- package/dist/paint/path.js +173 -0
- package/dist/paint/path.js.map +1 -0
- package/dist/paint/raster.d.ts +32 -0
- package/dist/paint/raster.js +180 -0
- package/dist/paint/raster.js.map +1 -0
- package/dist/paint/shadows.d.ts +28 -0
- package/dist/paint/shadows.js +104 -0
- package/dist/paint/shadows.js.map +1 -0
- package/dist/paint/sources.d.ts +13 -0
- package/dist/paint/sources.js +17 -0
- package/dist/paint/sources.js.map +1 -0
- package/dist/paint/stacking.d.ts +75 -0
- package/dist/paint/stacking.js +327 -0
- package/dist/paint/stacking.js.map +1 -0
- package/dist/paint/svg-lint.d.ts +57 -0
- package/dist/paint/svg-lint.js +119 -0
- package/dist/paint/svg-lint.js.map +1 -0
- package/dist/paint/svg.d.ts +95 -0
- package/dist/paint/svg.js +728 -0
- package/dist/paint/svg.js.map +1 -0
- package/dist/paint/tables.d.ts +18 -0
- package/dist/paint/tables.js +178 -0
- package/dist/paint/tables.js.map +1 -0
- package/dist/paint/text-shadow.d.ts +26 -0
- package/dist/paint/text-shadow.js +187 -0
- package/dist/paint/text-shadow.js.map +1 -0
- package/dist/paint/text.d.ts +144 -0
- package/dist/paint/text.js +713 -0
- package/dist/paint/text.js.map +1 -0
- package/dist/paint/values.d.ts +24 -0
- package/dist/paint/values.js +160 -0
- package/dist/paint/values.js.map +1 -0
- package/dist/paint/vertical.d.ts +19 -0
- package/dist/paint/vertical.js +236 -0
- package/dist/paint/vertical.js.map +1 -0
- package/dist/pdf/index.d.ts +6 -0
- package/dist/pdf/index.js +7 -0
- package/dist/pdf/index.js.map +1 -0
- package/dist/pdf/pdfx.d.ts +30 -0
- package/dist/pdf/pdfx.js +18 -0
- package/dist/pdf/pdfx.js.map +1 -0
- package/dist/pdf/structure/index.d.ts +53 -0
- package/dist/pdf/structure/index.js +52 -0
- package/dist/pdf/structure/index.js.map +1 -0
- package/dist/pdf/structure/labels.d.ts +16 -0
- package/dist/pdf/structure/labels.js +45 -0
- package/dist/pdf/structure/labels.js.map +1 -0
- package/dist/pdf/structure/links.d.ts +49 -0
- package/dist/pdf/structure/links.js +136 -0
- package/dist/pdf/structure/links.js.map +1 -0
- package/dist/pdf/structure/tags.d.ts +79 -0
- package/dist/pdf/structure/tags.js +314 -0
- package/dist/pdf/structure/tags.js.map +1 -0
- package/dist/pdf/types.d.ts +551 -0
- package/dist/pdf/types.js +16 -0
- package/dist/pdf/types.js.map +1 -0
- package/dist/pdf/wasm/pulpweaver4_pdf.d.ts +41 -0
- package/dist/pdf/wasm/pulpweaver4_pdf.js +286 -0
- package/dist/pdf/wasm/pulpweaver4_pdf_bg.wasm +0 -0
- package/dist/pdf/writer.d.ts +41 -0
- package/dist/pdf/writer.js +78 -0
- package/dist/pdf/writer.js.map +1 -0
- package/dist/plugin/attributes.d.ts +10 -0
- package/dist/plugin/attributes.js +63 -0
- package/dist/plugin/attributes.js.map +1 -0
- package/dist/plugin/define.d.ts +425 -0
- package/dist/plugin/define.js +311 -0
- package/dist/plugin/define.js.map +1 -0
- package/dist/plugin/failure.d.ts +80 -0
- package/dist/plugin/failure.js +97 -0
- package/dist/plugin/failure.js.map +1 -0
- package/dist/plugin/index.d.ts +11 -0
- package/dist/plugin/index.js +12 -0
- package/dist/plugin/index.js.map +1 -0
- package/dist/plugin/load.d.ts +105 -0
- package/dist/plugin/load.js +197 -0
- package/dist/plugin/load.js.map +1 -0
- package/dist/plugin/register.d.ts +166 -0
- package/dist/plugin/register.js +306 -0
- package/dist/plugin/register.js.map +1 -0
- package/dist/plugin/render.d.ts +4 -0
- package/dist/plugin/render.js +28 -0
- package/dist/plugin/render.js.map +1 -0
- package/dist/preflight/index.d.ts +3 -0
- package/dist/preflight/index.js +4 -0
- package/dist/preflight/index.js.map +1 -0
- package/dist/preflight/pdfx.d.ts +440 -0
- package/dist/preflight/pdfx.js +1781 -0
- package/dist/preflight/pdfx.js.map +1 -0
- package/dist/preflight/reader.d.ts +126 -0
- package/dist/preflight/reader.js +832 -0
- package/dist/preflight/reader.js.map +1 -0
- package/dist/preflight/xmp.d.ts +30 -0
- package/dist/preflight/xmp.js +145 -0
- package/dist/preflight/xmp.js.map +1 -0
- package/dist/print/index.d.ts +2 -0
- package/dist/print/index.js +3 -0
- package/dist/print/index.js.map +1 -0
- package/dist/print/output.d.ts +5 -0
- package/dist/print/output.js +215 -0
- package/dist/print/output.js.map +1 -0
- package/dist/problem.d.ts +142 -0
- package/dist/problem.js +234 -0
- package/dist/problem.js.map +1 -0
- package/dist/profile/index.d.ts +10 -0
- package/dist/profile/index.js +11 -0
- package/dist/profile/index.js.map +1 -0
- package/dist/profile/lint.d.ts +69 -0
- package/dist/profile/lint.js +282 -0
- package/dist/profile/lint.js.map +1 -0
- package/dist/profile/metadata.d.ts +27 -0
- package/dist/profile/metadata.js +38 -0
- package/dist/profile/metadata.js.map +1 -0
- package/dist/profile/profile.d.ts +92 -0
- package/dist/profile/profile.js +282 -0
- package/dist/profile/profile.js.map +1 -0
- package/dist/project.d.ts +56 -0
- package/dist/project.js +137 -0
- package/dist/project.js.map +1 -0
- package/dist/reproducible/clock.d.ts +46 -0
- package/dist/reproducible/clock.js +173 -0
- package/dist/reproducible/clock.js.map +1 -0
- package/dist/reproducible/date.d.ts +42 -0
- package/dist/reproducible/date.js +82 -0
- package/dist/reproducible/date.js.map +1 -0
- package/dist/reproducible/index.d.ts +8 -0
- package/dist/reproducible/index.js +9 -0
- package/dist/reproducible/index.js.map +1 -0
- package/dist/spike/spike-page.chromium.json +330 -0
- package/dist/spike/spike.d.ts +75 -0
- package/dist/spike/spike.js +106 -0
- package/dist/spike/spike.js.map +1 -0
- package/dist/style/borders.d.ts +25 -0
- package/dist/style/borders.js +177 -0
- package/dist/style/borders.js.map +1 -0
- package/dist/style/colours.d.ts +34 -0
- package/dist/style/colours.js +138 -0
- package/dist/style/colours.js.map +1 -0
- package/dist/style/compile.d.ts +79 -0
- package/dist/style/compile.js +325 -0
- package/dist/style/compile.js.map +1 -0
- package/dist/style/defaults.d.ts +20 -0
- package/dist/style/defaults.js +45 -0
- package/dist/style/defaults.js.map +1 -0
- package/dist/style/gcpm.d.ts +22 -0
- package/dist/style/gcpm.js +86 -0
- package/dist/style/gcpm.js.map +1 -0
- package/dist/style/index.d.ts +4 -0
- package/dist/style/index.js +5 -0
- package/dist/style/index.js.map +1 -0
- package/dist/style/media.d.ts +22 -0
- package/dist/style/media.js +342 -0
- package/dist/style/media.js.map +1 -0
- package/dist/style/properties.d.ts +44 -0
- package/dist/style/properties.js +497 -0
- package/dist/style/properties.js.map +1 -0
- package/dist/style/scope.d.ts +6 -0
- package/dist/style/scope.js +134 -0
- package/dist/style/scope.js.map +1 -0
- package/dist/style/values.d.ts +45 -0
- package/dist/style/values.js +106 -0
- package/dist/style/values.js.map +1 -0
- package/dist/test/book.d.ts +180 -0
- package/dist/test/book.js +314 -0
- package/dist/test/book.js.map +1 -0
- package/dist/test/build.d.ts +58 -0
- package/dist/test/build.js +222 -0
- package/dist/test/build.js.map +1 -0
- package/dist/test/environment.d.ts +63 -0
- package/dist/test/environment.js +46 -0
- package/dist/test/environment.js.map +1 -0
- package/dist/test/index.d.ts +17 -0
- package/dist/test/index.js +18 -0
- package/dist/test/index.js.map +1 -0
- package/dist/test/indexes.d.ts +4 -0
- package/dist/test/indexes.js +48 -0
- package/dist/test/indexes.js.map +1 -0
- package/dist/test/layout.d.ts +8 -0
- package/dist/test/layout.js +121 -0
- package/dist/test/layout.js.map +1 -0
- package/dist/test/matchers.d.ts +80 -0
- package/dist/test/matchers.js +177 -0
- package/dist/test/matchers.js.map +1 -0
- package/dist/test/pipeline.d.ts +231 -0
- package/dist/test/pipeline.js +75 -0
- package/dist/test/pipeline.js.map +1 -0
- package/dist/test/plugins.d.ts +13 -0
- package/dist/test/plugins.js +22 -0
- package/dist/test/plugins.js.map +1 -0
- package/dist/test/render.d.ts +46 -0
- package/dist/test/render.js +149 -0
- package/dist/test/render.js.map +1 -0
- package/dist/test/runner.d.ts +61 -0
- package/dist/test/runner.js +256 -0
- package/dist/test/runner.js.map +1 -0
- package/dist/test/select.d.ts +54 -0
- package/dist/test/select.js +193 -0
- package/dist/test/select.js.map +1 -0
- package/dist/test/snapshot.d.ts +52 -0
- package/dist/test/snapshot.js +175 -0
- package/dist/test/snapshot.js.map +1 -0
- package/dist/test/text.d.ts +7 -0
- package/dist/test/text.js +46 -0
- package/dist/test/text.js.map +1 -0
- package/dist/test/vitest.d.ts +3 -0
- package/dist/test/vitest.js +39 -0
- package/dist/test/vitest.js.map +1 -0
- package/dist/text/index.d.ts +5 -0
- package/dist/text/index.js +6 -0
- package/dist/text/index.js.map +1 -0
- package/dist/text/output.d.ts +5 -0
- package/dist/text/output.js +39 -0
- package/dist/text/output.js.map +1 -0
- package/dist/text/render.d.ts +82 -0
- package/dist/text/render.js +583 -0
- package/dist/text/render.js.map +1 -0
- package/dist/text/width.d.ts +16 -0
- package/dist/text/width.js +90 -0
- package/dist/text/width.js.map +1 -0
- package/dist/text/wrap.d.ts +19 -0
- package/dist/text/wrap.js +151 -0
- package/dist/text/wrap.js.map +1 -0
- package/dist/transform/core.d.ts +19 -0
- package/dist/transform/core.js +22 -0
- package/dist/transform/core.js.map +1 -0
- package/dist/transform/index.d.ts +10 -0
- package/dist/transform/index.js +11 -0
- package/dist/transform/index.js.map +1 -0
- package/dist/transform/numbering.d.ts +47 -0
- package/dist/transform/numbering.js +142 -0
- package/dist/transform/numbering.js.map +1 -0
- package/dist/transform/references.d.ts +38 -0
- package/dist/transform/references.js +182 -0
- package/dist/transform/references.js.map +1 -0
- package/dist/transform/run.d.ts +32 -0
- package/dist/transform/run.js +210 -0
- package/dist/transform/run.js.map +1 -0
- package/dist/transform/store.d.ts +111 -0
- package/dist/transform/store.js +331 -0
- package/dist/transform/store.js.map +1 -0
- package/dist/transform/testing.d.ts +31 -0
- package/dist/transform/testing.js +76 -0
- package/dist/transform/testing.js.map +1 -0
- package/dist/transform/transform.d.ts +104 -0
- package/dist/transform/transform.js +89 -0
- package/dist/transform/transform.js.map +1 -0
- package/dist/vfs/fsa.d.ts +14 -0
- package/dist/vfs/fsa.js +123 -0
- package/dist/vfs/fsa.js.map +1 -0
- package/dist/vfs/index.d.ts +7 -0
- package/dist/vfs/index.js +8 -0
- package/dist/vfs/index.js.map +1 -0
- package/dist/vfs/memory.d.ts +15 -0
- package/dist/vfs/memory.js +101 -0
- package/dist/vfs/memory.js.map +1 -0
- package/dist/vfs/path.d.ts +30 -0
- package/dist/vfs/path.js +67 -0
- package/dist/vfs/path.js.map +1 -0
- package/dist/vfs/vfs.d.ts +66 -0
- package/dist/vfs/vfs.js +68 -0
- package/dist/vfs/vfs.js.map +1 -0
- package/dist/vfs/zip.d.ts +27 -0
- package/dist/vfs/zip.js +67 -0
- package/dist/vfs/zip.js.map +1 -0
- package/dist/web/css.d.ts +15 -0
- package/dist/web/css.js +80 -0
- package/dist/web/css.js.map +1 -0
- package/dist/web/hast.d.ts +44 -0
- package/dist/web/hast.js +175 -0
- package/dist/web/hast.js.map +1 -0
- package/dist/web/index.d.ts +11 -0
- package/dist/web/index.js +12 -0
- package/dist/web/index.js.map +1 -0
- package/dist/web/justify-main.d.ts +1 -0
- package/dist/web/justify-main.js +38 -0
- package/dist/web/justify-main.js.map +1 -0
- package/dist/web/justify.d.ts +46 -0
- package/dist/web/justify.js +147 -0
- package/dist/web/justify.js.map +1 -0
- package/dist/web/output.d.ts +28 -0
- package/dist/web/output.js +251 -0
- package/dist/web/output.js.map +1 -0
- package/dist/web/runtime/LICENSE-harfbuzzjs.txt +19 -0
- package/dist/web/runtime/NOTICE-patterns.txt +429 -0
- package/dist/web/runtime/harfbuzz.wasm +0 -0
- package/dist/web/runtime/justify.js.txt +2 -0
- package/dist/web/site.d.ts +53 -0
- package/dist/web/site.js +219 -0
- package/dist/web/site.js.map +1 -0
- package/docs/README.md +16 -0
- package/docs/reference/css-properties/index.md +94 -0
- package/docs/reference/css-properties/pw-adj-demerits.md +22 -0
- package/docs/reference/css-properties/pw-border-bottom-width.md +24 -0
- package/docs/reference/css-properties/pw-border-left-width.md +24 -0
- package/docs/reference/css-properties/pw-border-right-width.md +24 -0
- package/docs/reference/css-properties/pw-border-top-width.md +24 -0
- package/docs/reference/css-properties/pw-box.md +28 -0
- package/docs/reference/css-properties/pw-broken-penalty.md +22 -0
- package/docs/reference/css-properties/pw-club-penalty.md +24 -0
- package/docs/reference/css-properties/pw-column-rule-width.md +23 -0
- package/docs/reference/css-properties/pw-content-after.md +31 -0
- package/docs/reference/css-properties/pw-content-before.md +31 -0
- package/docs/reference/css-properties/pw-double-hyphen-demerits.md +23 -0
- package/docs/reference/css-properties/pw-emergency-stretch.md +28 -0
- package/docs/reference/css-properties/pw-ex-hyphen-penalty.md +22 -0
- package/docs/reference/css-properties/pw-final-hyphen-demerits.md +22 -0
- package/docs/reference/css-properties/pw-float-skip.md +22 -0
- package/docs/reference/css-properties/pw-float.md +33 -0
- package/docs/reference/css-properties/pw-footnote-max-height.md +22 -0
- package/docs/reference/css-properties/pw-footnote-skip.md +23 -0
- package/docs/reference/css-properties/pw-hyphen-penalty.md +24 -0
- package/docs/reference/css-properties/pw-inter-line-penalty.md +24 -0
- package/docs/reference/css-properties/pw-leader-space.md +22 -0
- package/docs/reference/css-properties/pw-leader.md +29 -0
- package/docs/reference/css-properties/pw-left-hyphen-min.md +23 -0
- package/docs/reference/css-properties/pw-line-breaking.md +29 -0
- package/docs/reference/css-properties/pw-line-penalty.md +23 -0
- package/docs/reference/css-properties/pw-list-indent.md +18 -0
- package/docs/reference/css-properties/pw-looseness.md +30 -0
- package/docs/reference/css-properties/pw-max-depth.md +22 -0
- package/docs/reference/css-properties/pw-minipage-footnotes.md +23 -0
- package/docs/reference/css-properties/pw-orphans.md +24 -0
- package/docs/reference/css-properties/pw-outline-width.md +23 -0
- package/docs/reference/css-properties/pw-overprint.md +26 -0
- package/docs/reference/css-properties/pw-padding-bottom.md +22 -0
- package/docs/reference/css-properties/pw-padding-left.md +22 -0
- package/docs/reference/css-properties/pw-padding-right.md +22 -0
- package/docs/reference/css-properties/pw-padding-top.md +22 -0
- package/docs/reference/css-properties/pw-page-prefix.md +28 -0
- package/docs/reference/css-properties/pw-page.md +32 -0
- package/docs/reference/css-properties/pw-penalty-after.md +23 -0
- package/docs/reference/css-properties/pw-penalty-before.md +30 -0
- package/docs/reference/css-properties/pw-pretolerance.md +23 -0
- package/docs/reference/css-properties/pw-right-hyphen-min.md +22 -0
- package/docs/reference/css-properties/pw-running.md +23 -0
- package/docs/reference/css-properties/pw-site-background.md +21 -0
- package/docs/reference/css-properties/pw-site-link.md +17 -0
- package/docs/reference/css-properties/pw-site-measure.md +17 -0
- package/docs/reference/css-properties/pw-site-muted.md +21 -0
- package/docs/reference/css-properties/pw-site-rule.md +17 -0
- package/docs/reference/css-properties/pw-site-text.md +22 -0
- package/docs/reference/css-properties/pw-space-after.md +23 -0
- package/docs/reference/css-properties/pw-space-before.md +29 -0
- package/docs/reference/css-properties/pw-string-set.md +32 -0
- package/docs/reference/css-properties/pw-tolerance.md +33 -0
- package/docs/reference/css-properties/pw-top-skip.md +22 -0
- package/docs/reference/css-properties/pw-widow-penalty.md +32 -0
- package/docs/reference/css-properties/pw-widows.md +24 -0
- package/docs/reference/css-properties/pw-word-space.md +22 -0
- package/docs/reference/css-properties/pw-xspace.md +22 -0
- package/docs/reference/index.md +17 -0
- package/docs/reference/lint-rules/black-text.md +31 -0
- package/docs/reference/lint-rules/blank-page.md +35 -0
- package/docs/reference/lint-rules/chapter-verso.md +34 -0
- package/docs/reference/lint-rules/citation-in-heading.md +24 -0
- package/docs/reference/lint-rules/consecutive-hyphens.md +34 -0
- package/docs/reference/lint-rules/empty-link.md +32 -0
- package/docs/reference/lint-rules/figure-distance.md +34 -0
- package/docs/reference/lint-rules/fonts.md +24 -0
- package/docs/reference/lint-rules/generated-text.md +24 -0
- package/docs/reference/lint-rules/heading-levels.md +30 -0
- package/docs/reference/lint-rules/ibid-across-page.md +30 -0
- package/docs/reference/lint-rules/image-alt.md +30 -0
- package/docs/reference/lint-rules/image-resolution.md +34 -0
- package/docs/reference/lint-rules/index.md +120 -0
- package/docs/reference/lint-rules/ink-limit.md +30 -0
- package/docs/reference/lint-rules/missing-field.md +37 -0
- package/docs/reference/lint-rules/orphan.md +34 -0
- package/docs/reference/lint-rules/overfull-line.md +28 -0
- package/docs/reference/lint-rules/profile.md +24 -0
- package/docs/reference/lint-rules/raw-html.md +30 -0
- package/docs/reference/lint-rules/signature.md +34 -0
- package/docs/reference/lint-rules/straight-quotes.md +33 -0
- package/docs/reference/lint-rules/svg-use-css.md +24 -0
- package/docs/reference/lint-rules/underfull-line.md +35 -0
- package/docs/reference/lint-rules/unknown-citation.md +30 -0
- package/docs/reference/lint-rules/unknown-label.md +31 -0
- package/docs/reference/lint-rules/unpaintable.md +24 -0
- package/docs/reference/lint-rules/unplaced-index.md +31 -0
- package/docs/reference/lint-rules/unused-entry.md +38 -0
- package/docs/reference/lint-rules/widow.md +34 -0
- package/docs/reference/plugin-api/assert-no-errors.md +18 -0
- package/docs/reference/plugin-api/asset-processor.md +28 -0
- package/docs/reference/plugin-api/attribute-problem.md +26 -0
- package/docs/reference/plugin-api/attribute-type.md +18 -0
- package/docs/reference/plugin-api/capabilities.md +18 -0
- package/docs/reference/plugin-api/capability.md +22 -0
- package/docs/reference/plugin-api/check-attributes.md +18 -0
- package/docs/reference/plugin-api/claim-kind.md +20 -0
- package/docs/reference/plugin-api/combine-penalties.md +17 -0
- package/docs/reference/plugin-api/command-context.md +30 -0
- package/docs/reference/plugin-api/command-definition.md +34 -0
- package/docs/reference/plugin-api/core-claims.md +18 -0
- package/docs/reference/plugin-api/define-plugin.md +20 -0
- package/docs/reference/plugin-api/define-rule.md +19 -0
- package/docs/reference/plugin-api/describe-error.md +14 -0
- package/docs/reference/plugin-api/describe-node.md +14 -0
- package/docs/reference/plugin-api/empty-registry.md +18 -0
- package/docs/reference/plugin-api/failed-on.md +32 -0
- package/docs/reference/plugin-api/fails-as.md +18 -0
- package/docs/reference/plugin-api/import-plugins.md +20 -0
- package/docs/reference/plugin-api/import-text.md +14 -0
- package/docs/reference/plugin-api/index.md +123 -0
- package/docs/reference/plugin-api/layout-definition.md +42 -0
- package/docs/reference/plugin-api/layout-slot.md +28 -0
- package/docs/reference/plugin-api/line-breaker.md +18 -0
- package/docs/reference/plugin-api/lint-context.md +48 -0
- package/docs/reference/plugin-api/lint-definition.md +32 -0
- package/docs/reference/plugin-api/lint-edition.md +38 -0
- package/docs/reference/plugin-api/lint-fix.md +36 -0
- package/docs/reference/plugin-api/lint-level.md +20 -0
- package/docs/reference/plugin-api/lint-preset.md +30 -0
- package/docs/reference/plugin-api/lint-rule.md +42 -0
- package/docs/reference/plugin-api/load-failure.md +32 -0
- package/docs/reference/plugin-api/load-plugins-options.md +32 -0
- package/docs/reference/plugin-api/load-plugins.md +20 -0
- package/docs/reference/plugin-api/loaded-plugin.md +32 -0
- package/docs/reference/plugin-api/node-claim.md +34 -0
- package/docs/reference/plugin-api/output-definition.md +28 -0
- package/docs/reference/plugin-api/owned.md +28 -0
- package/docs/reference/plugin-api/page-builder-hook.md +18 -0
- package/docs/reference/plugin-api/penalty-rule.md +34 -0
- package/docs/reference/plugin-api/plugin-api.md +18 -0
- package/docs/reference/plugin-api/plugin-definition.md +66 -0
- package/docs/reference/plugin-api/plugin-error.md +22 -0
- package/docs/reference/plugin-api/plugin-failure.md +30 -0
- package/docs/reference/plugin-api/plugin-importer.md +34 -0
- package/docs/reference/plugin-api/plugin-problem.md +30 -0
- package/docs/reference/plugin-api/plugin-registry.md +83 -0
- package/docs/reference/plugin-api/plugin-scope.md +15 -0
- package/docs/reference/plugin-api/plugin-stage.md +18 -0
- package/docs/reference/plugin-api/plugin-threw-problem.md +34 -0
- package/docs/reference/plugin-api/plugin-threw.md +21 -0
- package/docs/reference/plugin-api/plugin.md +69 -0
- package/docs/reference/plugin-api/project-with-plugins.md +36 -0
- package/docs/reference/plugin-api/read-context.md +30 -0
- package/docs/reference/plugin-api/read-failure.md +18 -0
- package/docs/reference/plugin-api/read-plugin-styles.md +22 -0
- package/docs/reference/plugin-api/reader.md +22 -0
- package/docs/reference/plugin-api/register-options.md +28 -0
- package/docs/reference/plugin-api/register-plugins.md +20 -0
- package/docs/reference/plugin-api/render-format.md +18 -0
- package/docs/reference/plugin-api/render-formats.md +18 -0
- package/docs/reference/plugin-api/renderer-registry.md +18 -0
- package/docs/reference/plugin-api/renderer-set.md +34 -0
- package/docs/reference/plugin-api/renderers.md +34 -0
- package/docs/reference/plugin-api/specifier-kind.md +14 -0
- package/docs/reference/plugin-api/style-source.md +18 -0
- package/docs/reference/plugin-api/text-context.md +28 -0
- package/docs/reference/plugin-api/text-edit.md +28 -0
- package/docs/reference/plugin-api/text-renderer.md +24 -0
- package/docs/reference/plugin-api/try-plugin-async.md +18 -0
- package/docs/reference/plugin-api/try-plugin.md +20 -0
- package/docs/reference/pulpweaver4-toml/editions.md +208 -0
- package/docs/reference/pulpweaver4-toml/index.md +195 -0
- package/docs/reference/pulpweaver4-toml/inks.md +50 -0
- package/docs/reference/pulpweaver4-toml/lint.md +36 -0
- package/docs/reference/test-matchers/index.md +33 -0
- package/docs/reference/test-matchers/to-be-recto.md +20 -0
- package/docs/reference/test-matchers/to-cite.md +22 -0
- package/docs/reference/test-matchers/to-fit-on-one-page.md +20 -0
- package/docs/reference/test-matchers/to-have-no-overfull-lines.md +20 -0
- package/docs/reference/test-matchers/to-match-html-snapshot.md +20 -0
- package/docs/reference/test-matchers/to-match-page-snapshot.md +20 -0
- package/docs/reference/test-matchers/to-match-text-snapshot.md +21 -0
- package/docs/reference/test-matchers/to-start-page.md +20 -0
- package/package.json +75 -4
- package/README.md +0 -3
|
@@ -0,0 +1,1068 @@
|
|
|
1
|
+
import { combinePenalties } from '../plugin/register.js';
|
|
2
|
+
import { BIGSKIP, parseGlue, parseLength } from './glue.js';
|
|
3
|
+
import { buildMinipage, isMinipage, minipageFootnotes, packMinipage } from './minipage.js';
|
|
4
|
+
import { isAtomicInline, layoutParagraph } from './paragraph.js';
|
|
5
|
+
import { isPreformatted, splitPreLines } from './pre.js';
|
|
6
|
+
import { EJECT_PENALTY, INFINITE_VPENALTY, naturalHeight, } from './vlist.js';
|
|
7
|
+
/** The TeX parameters for the penalties between lines, with plain TeX's defaults. */
|
|
8
|
+
const LINE_PENALTIES = {
|
|
9
|
+
'--pw-inter-line-penalty': 0,
|
|
10
|
+
'--pw-club-penalty': 150,
|
|
11
|
+
'--pw-widow-penalty': 150,
|
|
12
|
+
'--pw-broken-penalty': 100,
|
|
13
|
+
};
|
|
14
|
+
const AVOID = /^avoid/;
|
|
15
|
+
/** Converts `root`'s content into TeX's vertical list, laying out its paragraphs. */
|
|
16
|
+
export function buildVerticalList(root, opts) {
|
|
17
|
+
const { minipages, floats } = boxesOf(root);
|
|
18
|
+
const conversion = new Conversion(root, opts, minipages, floats);
|
|
19
|
+
const items = conversion.list(root);
|
|
20
|
+
return { items, ...(conversion.held ? { held: conversion.held } : {}) };
|
|
21
|
+
}
|
|
22
|
+
const emptyBoundary = () => ({ negative: 0, avoid: false, penalties: [], marks: [], floats: [], clearance: 0 });
|
|
23
|
+
/** How near two positions must be to be the same: a 1/100 px. */
|
|
24
|
+
const EPSILON = 0.01;
|
|
25
|
+
/** One conversion: the held elements are shared by every list it makes. */
|
|
26
|
+
class Conversion {
|
|
27
|
+
root;
|
|
28
|
+
opts;
|
|
29
|
+
minipages;
|
|
30
|
+
floats;
|
|
31
|
+
held;
|
|
32
|
+
/** While a minipage whose notes stay inside is converted: the minipage, and where its notes wait. */
|
|
33
|
+
notes;
|
|
34
|
+
constructor(root, opts,
|
|
35
|
+
/** Every minipage under the root, so that a box with none in it isn't searched. */
|
|
36
|
+
minipages = [],
|
|
37
|
+
/** Every CSS float under the root, so that a paragraph with none in it isn't searched. */
|
|
38
|
+
floats = []) {
|
|
39
|
+
this.root = root;
|
|
40
|
+
this.opts = opts;
|
|
41
|
+
this.minipages = minipages;
|
|
42
|
+
this.floats = floats;
|
|
43
|
+
}
|
|
44
|
+
/** The CSS floats in a paragraph's text (`innerFloats`). */
|
|
45
|
+
floatsIn(el) {
|
|
46
|
+
return this.floats.some((f) => el.contains(f)) ? innerFloats(el) : [];
|
|
47
|
+
}
|
|
48
|
+
/** The vertical list of `el`'s content, positions relative to its content box. */
|
|
49
|
+
list(el) {
|
|
50
|
+
const builder = new Builder(this, el);
|
|
51
|
+
if (el instanceof HTMLTableElement)
|
|
52
|
+
builder.table(el, []);
|
|
53
|
+
else if (isParagraph(el) && hasText(el) && isPreformatted(getComputedStyle(el)))
|
|
54
|
+
builder.pre(el, [], getComputedStyle(el), true);
|
|
55
|
+
else if (isParagraph(el) && hasText(el))
|
|
56
|
+
builder.paragraph(el, []);
|
|
57
|
+
else if (isParagraph(el))
|
|
58
|
+
builder.leaf(el);
|
|
59
|
+
else
|
|
60
|
+
builder.contents(el, []);
|
|
61
|
+
builder.finish();
|
|
62
|
+
return builder.items;
|
|
63
|
+
}
|
|
64
|
+
/** Whether a plugin keeps the element whole (`ListOptions.boxes`). */
|
|
65
|
+
isBox(el) {
|
|
66
|
+
return this.opts.boxes?.some((s) => el.matches(s)) ?? false;
|
|
67
|
+
}
|
|
68
|
+
/** The plugins' penalty at a break by the element, added to a boundary. */
|
|
69
|
+
addPenalty(b, el, at) {
|
|
70
|
+
const p = this.opts.penalty?.(el, at);
|
|
71
|
+
if (p !== undefined)
|
|
72
|
+
b.penalties.push(p);
|
|
73
|
+
}
|
|
74
|
+
/** The plugins' penalties at every break inside the elements. */
|
|
75
|
+
inside(containers) {
|
|
76
|
+
return this.opts.penalty ? containers.flatMap((c) => this.opts.penalty(c, 'inside') ?? []) : [];
|
|
77
|
+
}
|
|
78
|
+
/** The element, out of the flow, moved where held elements wait: after the root's content, so it keeps the root's inherited styles. */
|
|
79
|
+
hold(el) {
|
|
80
|
+
if (!this.held) {
|
|
81
|
+
this.held = document.createElement('div');
|
|
82
|
+
this.held.className = 'pw-held';
|
|
83
|
+
const cs = getComputedStyle(this.root);
|
|
84
|
+
this.held.style.cssText = `display:block;width:${contentBox(this.root, cs).width}px;margin:0;padding:0;border:0`;
|
|
85
|
+
if (isParagraph(this.root))
|
|
86
|
+
this.root.after(this.held);
|
|
87
|
+
else
|
|
88
|
+
this.root.append(this.held);
|
|
89
|
+
}
|
|
90
|
+
this.held.append(el);
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* An insert: the element moved out of the flow and laid out on its own, at
|
|
94
|
+
* the flow's measure, or a footnote in a minipage that keeps its notes at
|
|
95
|
+
* the minipage's.
|
|
96
|
+
*/
|
|
97
|
+
insert(el, cls) {
|
|
98
|
+
let held;
|
|
99
|
+
if (cls === 'footnote' && this.notes) {
|
|
100
|
+
held = this.notes.held ??= heldIn(this.notes.minipage);
|
|
101
|
+
held.append(el);
|
|
102
|
+
}
|
|
103
|
+
else {
|
|
104
|
+
this.hold(el);
|
|
105
|
+
held = this.held;
|
|
106
|
+
}
|
|
107
|
+
if (isInlineLevel(getComputedStyle(el).display))
|
|
108
|
+
el.style.display = 'block';
|
|
109
|
+
const builder = new Builder(this, held);
|
|
110
|
+
builder.block(el, [], true);
|
|
111
|
+
builder.finish();
|
|
112
|
+
// Space before the insert's first box or after its last isn't its own.
|
|
113
|
+
const list = trimGlue(builder.items);
|
|
114
|
+
return { type: 'insert', class: cls, element: el, list, height: naturalHeight(list) };
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* A minipage (`minipage.ts`): its own list, built and stacked inside it,
|
|
118
|
+
* its footnotes at its foot unless they go out.
|
|
119
|
+
*/
|
|
120
|
+
minipage(el) {
|
|
121
|
+
const cs = getComputedStyle(el);
|
|
122
|
+
const footnotes = minipageFootnotes(cs);
|
|
123
|
+
// Text straight inside it goes in an anonymous block, so that its notes
|
|
124
|
+
// can wait beside the paragraph, which its layout takes the whole of.
|
|
125
|
+
if (isParagraph(el)) {
|
|
126
|
+
const anon = document.createElement('div');
|
|
127
|
+
anon.className = 'pw-anonymous';
|
|
128
|
+
anon.append(...el.childNodes);
|
|
129
|
+
el.append(anon);
|
|
130
|
+
}
|
|
131
|
+
const outer = this.notes;
|
|
132
|
+
if (footnotes === 'inside')
|
|
133
|
+
this.notes = { minipage: el };
|
|
134
|
+
let items;
|
|
135
|
+
try {
|
|
136
|
+
items = this.list(el);
|
|
137
|
+
}
|
|
138
|
+
finally {
|
|
139
|
+
this.notes = outer;
|
|
140
|
+
}
|
|
141
|
+
const skip = parseGlue(cs.getPropertyValue('--pw-footnote-skip').trim() || BIGSKIP, Number.parseFloat(cs.fontSize) || 16);
|
|
142
|
+
const packed = packMinipage(items, { footnotes, skip });
|
|
143
|
+
buildMinipage(el, packed);
|
|
144
|
+
return packed;
|
|
145
|
+
}
|
|
146
|
+
/** The minipages in `el` that its box holds (in its lines, or in a block the browser lays out), each built; what leaves them, in order. */
|
|
147
|
+
minipagesIn(el) {
|
|
148
|
+
const boxes = new Map();
|
|
149
|
+
if (!this.minipages.some((m) => m !== el && el.contains(m)))
|
|
150
|
+
return { boxes, out: [] };
|
|
151
|
+
for (const m of innerMinipages(el))
|
|
152
|
+
boxes.set(m, this.minipage(m));
|
|
153
|
+
return { boxes, out: [...boxes.values()].flatMap((p) => p.out) };
|
|
154
|
+
}
|
|
155
|
+
/**
|
|
156
|
+
* The paragraph's lines, laid out by the engine: footnotes, floats and
|
|
157
|
+
* running elements migrate out, and `migrated` says what each is, read
|
|
158
|
+
* before it left the document.
|
|
159
|
+
*/
|
|
160
|
+
layout(el, migrated, shape) {
|
|
161
|
+
const { fonts, hyphenator, lineBreaker } = this.opts;
|
|
162
|
+
return layoutParagraph(el, {
|
|
163
|
+
fonts,
|
|
164
|
+
...(hyphenator ? { hyphenator } : {}),
|
|
165
|
+
...(lineBreaker ? { lineBreaker } : {}),
|
|
166
|
+
...(shape ? { shape } : {}),
|
|
167
|
+
migrate: (e, cs) => {
|
|
168
|
+
if (cssFloatOf(cs)) {
|
|
169
|
+
migrated.set(e, { cssFloat: true });
|
|
170
|
+
return 'hold';
|
|
171
|
+
}
|
|
172
|
+
const float = floatOf(cs);
|
|
173
|
+
const running = runningOf(cs);
|
|
174
|
+
if (float)
|
|
175
|
+
migrated.set(e, { float });
|
|
176
|
+
else if (running)
|
|
177
|
+
migrated.set(e, { running });
|
|
178
|
+
else if (stringSetOf(cs))
|
|
179
|
+
migrated.set(e, { marks: marksOf(e, cs) });
|
|
180
|
+
else
|
|
181
|
+
return undefined;
|
|
182
|
+
return float || running ? 'remove' : 'keep';
|
|
183
|
+
},
|
|
184
|
+
});
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
/** Builds one vertical list. */
|
|
188
|
+
class Builder {
|
|
189
|
+
conversion;
|
|
190
|
+
items = [];
|
|
191
|
+
boundary = emptyBoundary();
|
|
192
|
+
left;
|
|
193
|
+
/** The CSS floats whose lines are still being set: those that reach below the last box. */
|
|
194
|
+
exclusions = [];
|
|
195
|
+
constructor(conversion, root) {
|
|
196
|
+
this.conversion = conversion;
|
|
197
|
+
this.left = contentBox(root, getComputedStyle(root)).left;
|
|
198
|
+
}
|
|
199
|
+
/** A container's children, in order, each a block. */
|
|
200
|
+
contents(el, containers) {
|
|
201
|
+
for (const child of blockChildren(el))
|
|
202
|
+
this.block(child, containers);
|
|
203
|
+
}
|
|
204
|
+
/** An element in the flow, at block level; `floated` when it is an insert's own element. */
|
|
205
|
+
block(el, containers, floated = false) {
|
|
206
|
+
const cs = getComputedStyle(el);
|
|
207
|
+
if (cs.display === 'none')
|
|
208
|
+
return;
|
|
209
|
+
if (cs.display === 'contents') {
|
|
210
|
+
this.contents(el, containers);
|
|
211
|
+
return;
|
|
212
|
+
}
|
|
213
|
+
const running = floated ? undefined : runningOf(cs);
|
|
214
|
+
if (running) {
|
|
215
|
+
this.boundary.marks.push({ type: 'mark', kind: 'running', name: running, element: el });
|
|
216
|
+
this.conversion.hold(el);
|
|
217
|
+
return;
|
|
218
|
+
}
|
|
219
|
+
const float = floated ? undefined : floatOf(cs);
|
|
220
|
+
if (float) {
|
|
221
|
+
this.items.push(this.conversion.insert(el, float));
|
|
222
|
+
return;
|
|
223
|
+
}
|
|
224
|
+
const side = floated ? undefined : cssFloatOf(cs);
|
|
225
|
+
if (side) {
|
|
226
|
+
// It waits at the boundary, to go before the next box.
|
|
227
|
+
const { box, out } = this.cssFloat(el, side, containers);
|
|
228
|
+
this.boundary.floats.push({ box, at: (this.boundary.positive?.width ?? 0) + this.boundary.negative, out });
|
|
229
|
+
return;
|
|
230
|
+
}
|
|
231
|
+
this.before(el, cs);
|
|
232
|
+
if (cs.clear !== 'none' && this.exclusions.length)
|
|
233
|
+
this.clear(el, cs.clear);
|
|
234
|
+
this.stringMarks(el, cs);
|
|
235
|
+
const inside = [...containers, el];
|
|
236
|
+
const count = columnCount(cs);
|
|
237
|
+
if (count > 1) {
|
|
238
|
+
this.columns(el, containers, cs, count);
|
|
239
|
+
}
|
|
240
|
+
else if (isMinipage(cs)) {
|
|
241
|
+
// One box; what leaves it follows it, as a \vbox's inserts do.
|
|
242
|
+
this.flush();
|
|
243
|
+
const packed = this.conversion.minipage(el);
|
|
244
|
+
this.items.push(this.minipageBox(el, packed, containers), ...packed.out);
|
|
245
|
+
}
|
|
246
|
+
else if (AVOID.test(cs.breakInside) || this.conversion.isBox(el)) {
|
|
247
|
+
this.flush();
|
|
248
|
+
const inner = this.conversion.list(el);
|
|
249
|
+
// Its inserts and marks migrate out, after it, for the page builder
|
|
250
|
+
// to find; as TeX's \vbox, it has its last line's depth.
|
|
251
|
+
const list = inner.filter((i) => i.type !== 'insert' && i.type !== 'mark');
|
|
252
|
+
const rect = el.getBoundingClientRect();
|
|
253
|
+
const last = [...list].reverse().find((i) => i.type === 'box');
|
|
254
|
+
const depth = last?.type === 'box' && last.kind === 'line' &&
|
|
255
|
+
Math.abs(last.element.getBoundingClientRect().bottom - rect.bottom) < 0.01 ? last.depth : 0;
|
|
256
|
+
this.items.push({ type: 'box', kind: 'vbox', list, ...this.size(rect, depth), element: el, containers });
|
|
257
|
+
this.items.push(...inner.filter((i) => i.type === 'insert' || i.type === 'mark'));
|
|
258
|
+
}
|
|
259
|
+
else if (el instanceof HTMLTableElement && /table$/.test(cs.display)) {
|
|
260
|
+
this.table(el, containers);
|
|
261
|
+
}
|
|
262
|
+
else if (isLeaf(el, cs)) {
|
|
263
|
+
const inner = this.conversion.minipagesIn(el);
|
|
264
|
+
const rect = el.getBoundingClientRect();
|
|
265
|
+
// An empty block is its margins, which collapse through it.
|
|
266
|
+
if (rect.height > 0 || isAtomicInline(el, cs)) {
|
|
267
|
+
this.flush();
|
|
268
|
+
this.items.push({ type: 'box', kind: 'block', ...this.size(rect, 0), element: el, containers, ...this.inner(inner.boxes) }, ...inner.out);
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
else if (isParagraph(el) && isPreformatted(cs)) {
|
|
272
|
+
this.pre(el, containers, cs);
|
|
273
|
+
}
|
|
274
|
+
else if (isParagraph(el)) {
|
|
275
|
+
this.paragraph(el, inside);
|
|
276
|
+
}
|
|
277
|
+
else {
|
|
278
|
+
// A container: its edges, if it has any, keep with its content; with
|
|
279
|
+
// none, its margins collapse with its children's.
|
|
280
|
+
const top = edge(cs, 'top');
|
|
281
|
+
const bfc = top > 0 || isFormattingContext(cs);
|
|
282
|
+
if (bfc)
|
|
283
|
+
this.edge(el, containers, 'start', top);
|
|
284
|
+
this.contents(el, inside);
|
|
285
|
+
const bottom = edge(cs, 'bottom');
|
|
286
|
+
if (bfc || bottom > 0)
|
|
287
|
+
this.edge(el, containers, 'end', bottom);
|
|
288
|
+
}
|
|
289
|
+
this.after(el, cs);
|
|
290
|
+
}
|
|
291
|
+
/**
|
|
292
|
+
* A CSS float (`float: left` or `right`): its content laid out in it, as
|
|
293
|
+
* a kept box's, and its margin box, which the lines after it are set
|
|
294
|
+
* beside (`parshape`) until the flow passes its foot. What leaves it
|
|
295
|
+
* follows it.
|
|
296
|
+
*/
|
|
297
|
+
cssFloat(el, side, containers) {
|
|
298
|
+
const inner = this.conversion.list(el);
|
|
299
|
+
const cs = getComputedStyle(el);
|
|
300
|
+
const r = el.getBoundingClientRect();
|
|
301
|
+
const px = (p) => Number.parseFloat(cs.getPropertyValue(p)) || 0;
|
|
302
|
+
const top = r.top - px('margin-top');
|
|
303
|
+
const bottom = r.bottom + px('margin-bottom');
|
|
304
|
+
const left = r.left - px('margin-left');
|
|
305
|
+
const right = r.right + px('margin-right');
|
|
306
|
+
this.exclusions.push({ side, top, bottom, left, right });
|
|
307
|
+
return {
|
|
308
|
+
box: {
|
|
309
|
+
type: 'box', kind: 'float', side, list: inner.filter((i) => i.type !== 'insert' && i.type !== 'mark'),
|
|
310
|
+
height: bottom - top, depth: 0, width: right - left, shift: left - this.left, element: el, containers,
|
|
311
|
+
},
|
|
312
|
+
out: inner.filter((i) => i.type === 'insert' || i.type === 'mark'),
|
|
313
|
+
top,
|
|
314
|
+
};
|
|
315
|
+
}
|
|
316
|
+
/** A CSS float in the list: before the box it hangs beside, taking no room, with no break after it. */
|
|
317
|
+
floatItems(box) {
|
|
318
|
+
return [box, { type: 'penalty', penalty: INFINITE_VPENALTY }, { type: 'glue', width: -box.height, stretch: 0, shrink: 0 }];
|
|
319
|
+
}
|
|
320
|
+
/**
|
|
321
|
+
* `clear`: the next box goes below the floats it clears, as far as the
|
|
322
|
+
* browser moved it (clearance), and their lines are done.
|
|
323
|
+
*/
|
|
324
|
+
clear(el, clear) {
|
|
325
|
+
const b = this.boundary;
|
|
326
|
+
const above = this.lastBottom();
|
|
327
|
+
if (above !== undefined) {
|
|
328
|
+
const clearance = el.getBoundingClientRect().top - (above + (b.positive?.width ?? 0) + b.negative);
|
|
329
|
+
if (clearance > EPSILON)
|
|
330
|
+
b.clearance = clearance;
|
|
331
|
+
}
|
|
332
|
+
const ltr = getComputedStyle(el).direction !== 'rtl';
|
|
333
|
+
const side = clear === 'inline-start' ? (ltr ? 'left' : 'right') : clear === 'inline-end' ? (ltr ? 'right' : 'left') : clear;
|
|
334
|
+
this.exclusions = this.exclusions.filter((e) => side !== 'both' && e.side !== side);
|
|
335
|
+
}
|
|
336
|
+
/**
|
|
337
|
+
* TeX's `\parshape` for a paragraph beside CSS floats: each line's
|
|
338
|
+
* measure and indent, from the floats' margin boxes, as CSS shortens a
|
|
339
|
+
* line box that overlaps one. Lines are taken to be `line-height` apart,
|
|
340
|
+
* as TeX takes them `\baselineskip` apart. Undefined if no line is beside
|
|
341
|
+
* a float.
|
|
342
|
+
*/
|
|
343
|
+
parshape(el, cs) {
|
|
344
|
+
if (!this.exclusions.length)
|
|
345
|
+
return undefined;
|
|
346
|
+
const box = contentBox(el, cs);
|
|
347
|
+
const top = el.getBoundingClientRect().top + edge(cs, 'top');
|
|
348
|
+
const pitch = lineHeight(el, cs);
|
|
349
|
+
const foot = Math.max(...this.exclusions.map((e) => e.bottom));
|
|
350
|
+
const out = [];
|
|
351
|
+
for (let n = 0; pitch > 0 && top + n * pitch < foot - EPSILON; n++) {
|
|
352
|
+
const t = top + n * pitch;
|
|
353
|
+
let left = box.left;
|
|
354
|
+
let right = box.left + box.width;
|
|
355
|
+
for (const e of this.exclusions) {
|
|
356
|
+
if (e.top >= t + pitch - EPSILON || e.bottom <= t + EPSILON)
|
|
357
|
+
continue;
|
|
358
|
+
if (e.side === 'left')
|
|
359
|
+
left = Math.max(left, e.right);
|
|
360
|
+
else
|
|
361
|
+
right = Math.min(right, e.left);
|
|
362
|
+
}
|
|
363
|
+
out.push({ measure: Math.max(0, right - left), left: left - box.left });
|
|
364
|
+
}
|
|
365
|
+
if (!out.some((l) => l.left > EPSILON || l.measure < box.width - EPSILON))
|
|
366
|
+
return undefined;
|
|
367
|
+
out.push({ measure: box.width, left: 0 });
|
|
368
|
+
return out;
|
|
369
|
+
}
|
|
370
|
+
/** Whether a break between a box ending at `above` and the next starting at `below` would part a float from a line beside it. */
|
|
371
|
+
beside(above, below) {
|
|
372
|
+
return this.exclusions.some((e) => e.top < above - EPSILON && e.bottom > below + EPSILON);
|
|
373
|
+
}
|
|
374
|
+
/** Where the last box ends, in viewport px. */
|
|
375
|
+
lastBottom() {
|
|
376
|
+
const last = this.items.findLast((i) => i.type === 'box' && i.kind !== 'float');
|
|
377
|
+
if (!last)
|
|
378
|
+
return undefined;
|
|
379
|
+
const r = last.element.getBoundingClientRect();
|
|
380
|
+
return last.kind === 'edge' && last.side === 'start' ? r.top + last.height : r.bottom;
|
|
381
|
+
}
|
|
382
|
+
/**
|
|
383
|
+
* A multi-column element: its content laid out at one column's width,
|
|
384
|
+
* as one list for the page layout to break into columns. Its marks come
|
|
385
|
+
* before it and its inserts after it. Its own border and padding, and
|
|
386
|
+
* `column-span`, aren't handled.
|
|
387
|
+
*/
|
|
388
|
+
columns(el, containers, cs, count) {
|
|
389
|
+
this.flush();
|
|
390
|
+
const em = Number.parseFloat(cs.fontSize) || 16;
|
|
391
|
+
const gap = cs.columnGap === 'normal' || cs.columnGap === '' ? em : parseLength(cs.columnGap, em);
|
|
392
|
+
const columnWidth = Math.max(0, (contentBox(el, cs).width - gap * (count - 1)) / count);
|
|
393
|
+
// Laid out in one column, at a column's width, so every box is measured where it will be.
|
|
394
|
+
const style = el.getAttribute('style');
|
|
395
|
+
el.style.setProperty('column-count', 'auto');
|
|
396
|
+
el.style.setProperty('column-width', 'auto');
|
|
397
|
+
el.style.setProperty('box-sizing', 'content-box');
|
|
398
|
+
el.style.setProperty('width', `${columnWidth}px`);
|
|
399
|
+
const inner = this.conversion.list(el);
|
|
400
|
+
if (style === null)
|
|
401
|
+
el.removeAttribute('style');
|
|
402
|
+
else
|
|
403
|
+
el.setAttribute('style', style);
|
|
404
|
+
const rect = el.getBoundingClientRect();
|
|
405
|
+
const list = inner.filter((i) => i.type !== 'insert' && i.type !== 'mark');
|
|
406
|
+
this.items.push(...inner.filter((i) => i.type === 'mark'));
|
|
407
|
+
this.items.push({
|
|
408
|
+
type: 'box', kind: 'columns', count, columnWidth, gap, list, height: naturalHeight(list), depth: 0, width: rect.width,
|
|
409
|
+
shift: rect.left - this.left, element: el, containers,
|
|
410
|
+
});
|
|
411
|
+
this.items.push(...inner.filter((i) => i.type === 'insert'));
|
|
412
|
+
}
|
|
413
|
+
/** Content the browser lays out, as one box: a paragraph of atomic inlines alone. */
|
|
414
|
+
leaf(el) {
|
|
415
|
+
const inner = this.conversion.minipagesIn(el);
|
|
416
|
+
const rect = el.getBoundingClientRect();
|
|
417
|
+
if (rect.height > 0)
|
|
418
|
+
this.items.push({ type: 'box', kind: 'block', ...this.size(rect, 0), element: el, containers: [], ...this.inner(inner.boxes) }, ...inner.out);
|
|
419
|
+
}
|
|
420
|
+
/** A minipage's box, as it now stands: as a `\vbox`, it has its last line's depth, if that line is at its foot. */
|
|
421
|
+
minipageBox(el, packed, containers) {
|
|
422
|
+
const rect = el.getBoundingClientRect();
|
|
423
|
+
const stacked = packed.footnotes.length ? packed.footnotes.at(-1).list : packed.list;
|
|
424
|
+
const last = stacked.findLast((i) => i.type === 'box');
|
|
425
|
+
const depth = last?.type === 'box' && last.kind === 'line' &&
|
|
426
|
+
Math.abs(last.element.getBoundingClientRect().bottom - rect.bottom) < 0.01 ? last.depth : 0;
|
|
427
|
+
return {
|
|
428
|
+
type: 'box', kind: 'minipage', list: packed.list, footnotes: packed.footnotes, ...(packed.skip ? { skip: packed.skip } : {}),
|
|
429
|
+
...this.size(rect, depth), element: el, containers,
|
|
430
|
+
};
|
|
431
|
+
}
|
|
432
|
+
/** The `minipages` of a box that holds them. */
|
|
433
|
+
inner(boxes, within) {
|
|
434
|
+
const list = [...boxes].filter(([m]) => !within || within.contains(m)).map(([m, p]) => this.minipageBox(m, p, []));
|
|
435
|
+
return list.length ? { minipages: list } : {};
|
|
436
|
+
}
|
|
437
|
+
/**
|
|
438
|
+
* Preformatted text (`pre.ts`): its edges, kept with its first and last
|
|
439
|
+
* lines, and its lines as the browser set them, each a box, with the
|
|
440
|
+
* penalties between a paragraph's lines (`linePenalty`), as CSS's
|
|
441
|
+
* `widows` and `orphans` apply to a `pre`'s lines; LaTeX's `verbatim`
|
|
442
|
+
* would break between any two. The root of a list has no edges in it.
|
|
443
|
+
*/
|
|
444
|
+
pre(el, containers, cs, root = false) {
|
|
445
|
+
const top = root ? 0 : edge(cs, 'top');
|
|
446
|
+
if (top > 0)
|
|
447
|
+
this.edge(el, containers, 'start', top);
|
|
448
|
+
const inside = root ? containers : [...containers, el];
|
|
449
|
+
const lines = splitPreLines(el);
|
|
450
|
+
this.flush();
|
|
451
|
+
const penalty = this.linePenalty(el, cs, inside, lines.length, () => false);
|
|
452
|
+
const rects = lines.map((l) => l.getBoundingClientRect());
|
|
453
|
+
for (const [n, line] of lines.entries()) {
|
|
454
|
+
if (n > 0)
|
|
455
|
+
this.items.push({ type: 'penalty', penalty: this.beside(rects[n - 1].bottom, rects[n].top) ? INFINITE_VPENALTY : penalty(n) });
|
|
456
|
+
this.items.push({ type: 'box', kind: 'block', ...this.size(line.getBoundingClientRect(), 0), element: line, containers: inside });
|
|
457
|
+
}
|
|
458
|
+
const bottom = root ? 0 : edge(cs, 'bottom');
|
|
459
|
+
if (bottom > 0)
|
|
460
|
+
this.edge(el, containers, 'end', bottom);
|
|
461
|
+
}
|
|
462
|
+
/**
|
|
463
|
+
* The penalty at a break after line n − 1 of a block of `count` lines, as
|
|
464
|
+
* TeX's between a paragraph's lines (tex.web §890): it leaves n lines above
|
|
465
|
+
* and count − n below.
|
|
466
|
+
*/
|
|
467
|
+
linePenalty(el, cs, containers, count, hyphenated) {
|
|
468
|
+
const p = Object.fromEntries(Object.entries(LINE_PENALTIES).map(([k, v]) => [k, intProperty(cs, k, v)]));
|
|
469
|
+
const widows = intProperty(cs, '--pw-widows', Number.parseInt(cs.getPropertyValue('widows'), 10) || 2);
|
|
470
|
+
const orphans = intProperty(cs, '--pw-orphans', Number.parseInt(cs.getPropertyValue('orphans'), 10) || 2);
|
|
471
|
+
const insidePenalties = this.conversion.inside(containers);
|
|
472
|
+
return (n) => {
|
|
473
|
+
let pen = p['--pw-inter-line-penalty'];
|
|
474
|
+
if (n < orphans)
|
|
475
|
+
pen += p['--pw-club-penalty'];
|
|
476
|
+
if (count - n < widows)
|
|
477
|
+
pen += p['--pw-widow-penalty'];
|
|
478
|
+
if (hyphenated(n - 1))
|
|
479
|
+
pen += p['--pw-broken-penalty'];
|
|
480
|
+
return combinePenalties([Math.max(EJECT_PENALTY, Math.min(INFINITE_VPENALTY, pen)), ...insidePenalties]);
|
|
481
|
+
};
|
|
482
|
+
}
|
|
483
|
+
/** A paragraph: its lines, the penalties between them, and what migrates out of it after its line. */
|
|
484
|
+
paragraph(el, containers) {
|
|
485
|
+
const migrants = new Map();
|
|
486
|
+
// Its minipages first, which it measures as atomic inlines; then the
|
|
487
|
+
// floats in its text, where the browser put them, and the lines' shape.
|
|
488
|
+
const inner = this.conversion.minipagesIn(el);
|
|
489
|
+
const floats = this.conversion.floatsIn(el).map((f) => this.cssFloat(f.el, f.side, containers));
|
|
490
|
+
const layout = this.conversion.layout(el, migrants, this.parshape(el, getComputedStyle(el)));
|
|
491
|
+
this.flush();
|
|
492
|
+
const lines = layout.lines;
|
|
493
|
+
const rects = lines.map((l) => l.element.getBoundingClientRect());
|
|
494
|
+
// Each float in its text hangs from the first line at or below its top, as the browser hung it.
|
|
495
|
+
const hung = new Map();
|
|
496
|
+
for (const f of floats) {
|
|
497
|
+
const n = rects.findIndex((r) => r.bottom > f.top + EPSILON);
|
|
498
|
+
const at = n < 0 ? lines.length : n;
|
|
499
|
+
if (n < 0)
|
|
500
|
+
el.append(f.box.element);
|
|
501
|
+
else
|
|
502
|
+
lines[n].element.before(f.box.element);
|
|
503
|
+
hung.set(at, [...(hung.get(at) ?? []), f]);
|
|
504
|
+
}
|
|
505
|
+
const penalty = this.linePenalty(el, getComputedStyle(el), containers, lines.length, (n) => lines[n].hyphenated);
|
|
506
|
+
const migrated = new Map();
|
|
507
|
+
for (const m of layout.migrated) {
|
|
508
|
+
const e = m.element;
|
|
509
|
+
const what = migrants.get(e);
|
|
510
|
+
if ('cssFloat' in what)
|
|
511
|
+
continue;
|
|
512
|
+
const items = migrated.get(m.line) ?? [];
|
|
513
|
+
migrated.set(m.line, items);
|
|
514
|
+
if ('float' in what)
|
|
515
|
+
items.push(this.conversion.insert(e, what.float));
|
|
516
|
+
else if ('running' in what) {
|
|
517
|
+
items.push({ type: 'mark', kind: 'running', name: what.running, element: e });
|
|
518
|
+
this.conversion.hold(e);
|
|
519
|
+
}
|
|
520
|
+
else
|
|
521
|
+
items.push(...what.marks);
|
|
522
|
+
}
|
|
523
|
+
// What leaves a minipage set in a line follows that line.
|
|
524
|
+
for (const [m, packed] of inner.boxes) {
|
|
525
|
+
const n = Math.max(0, lines.findIndex((l) => l.element.contains(m)));
|
|
526
|
+
migrated.set(n, [...(migrated.get(n) ?? []), ...packed.out]);
|
|
527
|
+
}
|
|
528
|
+
const baselines = baselinesOf(lines.map((l) => l.element));
|
|
529
|
+
for (const [n, line] of lines.entries()) {
|
|
530
|
+
if (n > 0)
|
|
531
|
+
this.items.push({ type: 'penalty', penalty: this.beside(rects[n - 1].bottom, rects[n].top) ? INFINITE_VPENALTY : penalty(n) });
|
|
532
|
+
for (const f of hung.get(n) ?? [])
|
|
533
|
+
this.items.push(...this.floatItems(f.box), ...f.out);
|
|
534
|
+
const rect = rects[n];
|
|
535
|
+
const height = baselines[n] - rect.top;
|
|
536
|
+
this.items.push({
|
|
537
|
+
type: 'box', kind: 'line', height, depth: rect.bottom - baselines[n], width: rect.width, shift: rect.left - this.left,
|
|
538
|
+
element: line.element, containers, paragraph: layout, line: n, ...this.inner(inner.boxes, line.element),
|
|
539
|
+
});
|
|
540
|
+
this.items.push(...(migrated.get(n) ?? []));
|
|
541
|
+
}
|
|
542
|
+
for (const f of hung.get(lines.length) ?? [])
|
|
543
|
+
this.items.push(...this.floatItems(f.box), ...f.out);
|
|
544
|
+
}
|
|
545
|
+
/** A table, broken between its rows; its captions and edges stay with the rows next to them. */
|
|
546
|
+
table(table, containers) {
|
|
547
|
+
this.flush();
|
|
548
|
+
const inside = [...containers, table];
|
|
549
|
+
const rect = table.getBoundingClientRect();
|
|
550
|
+
const rows = [...table.rows];
|
|
551
|
+
const captions = [...table.children].filter((c) => c.localName === 'caption' && getComputedStyle(c).display !== 'none');
|
|
552
|
+
const above = captions.filter((c) => getComputedStyle(c).captionSide !== 'bottom');
|
|
553
|
+
const below = captions.filter((c) => getComputedStyle(c).captionSide === 'bottom');
|
|
554
|
+
let y = rect.top;
|
|
555
|
+
for (const c of above) {
|
|
556
|
+
const r = c.getBoundingClientRect();
|
|
557
|
+
this.items.push({ type: 'box', kind: 'block', ...this.size(r, 0), element: c, containers: inside });
|
|
558
|
+
y = r.bottom;
|
|
559
|
+
}
|
|
560
|
+
if (!rows.length) {
|
|
561
|
+
// A table of no rows is its edges alone.
|
|
562
|
+
const r = new DOMRect(rect.left, y, rect.width, (below[0]?.getBoundingClientRect().top ?? rect.bottom) - y);
|
|
563
|
+
if (r.height > 0)
|
|
564
|
+
this.items.push({ type: 'box', kind: 'block', ...this.size(r, 0), element: table, containers });
|
|
565
|
+
}
|
|
566
|
+
else {
|
|
567
|
+
this.edge(table, containers, 'start', rows[0].getBoundingClientRect().top - y, false);
|
|
568
|
+
let previous;
|
|
569
|
+
for (const row of rows) {
|
|
570
|
+
const r = row.getBoundingClientRect();
|
|
571
|
+
const header = row.parentElement?.localName === 'thead';
|
|
572
|
+
if (previous) {
|
|
573
|
+
// A break between rows, unless it would leave a header row at
|
|
574
|
+
// the foot of a page; the spacing between rows goes at a break.
|
|
575
|
+
const before = previous.getBoundingClientRect();
|
|
576
|
+
const pcs = getComputedStyle(previous);
|
|
577
|
+
const rcs = getComputedStyle(row);
|
|
578
|
+
const b = emptyBoundary();
|
|
579
|
+
addBreak(b, pcs.breakAfter, intProperty(pcs, '--pw-penalty-after', 0));
|
|
580
|
+
addBreak(b, rcs.breakBefore, intProperty(rcs, '--pw-penalty-before', 0));
|
|
581
|
+
this.conversion.addPenalty(b, previous, 'after');
|
|
582
|
+
this.conversion.addPenalty(b, row, 'before');
|
|
583
|
+
b.penalties.push(...this.conversion.inside(inside));
|
|
584
|
+
if (previous.parentElement?.localName === 'thead')
|
|
585
|
+
b.avoid = true;
|
|
586
|
+
this.items.push(penaltyOf(b) ?? { type: 'penalty', penalty: 0 });
|
|
587
|
+
if (r.top - before.bottom > 0)
|
|
588
|
+
this.items.push({ type: 'glue', width: r.top - before.bottom, stretch: 0, shrink: 0 });
|
|
589
|
+
}
|
|
590
|
+
const rowContainers = row.parentElement && row.parentElement !== table ? [...inside, row.parentElement] : inside;
|
|
591
|
+
this.items.push({ type: 'box', kind: 'row', header, ...this.size(r, 0), element: row, containers: rowContainers });
|
|
592
|
+
previous = row;
|
|
593
|
+
}
|
|
594
|
+
const end = below[0]?.getBoundingClientRect().top ?? rect.bottom;
|
|
595
|
+
this.edge(table, containers, 'end', end - previous.getBoundingClientRect().bottom, false);
|
|
596
|
+
}
|
|
597
|
+
for (const c of below)
|
|
598
|
+
this.items.push({ type: 'box', kind: 'block', ...this.size(c.getBoundingClientRect(), 0), element: c, containers: inside });
|
|
599
|
+
}
|
|
600
|
+
/**
|
|
601
|
+
* The list's end: what waits at the last boundary, and room for a float
|
|
602
|
+
* that reaches below the last box, which would otherwise hang past it.
|
|
603
|
+
*/
|
|
604
|
+
finish() {
|
|
605
|
+
this.flush();
|
|
606
|
+
const above = this.lastBottom();
|
|
607
|
+
const foot = Math.max(-Infinity, ...this.exclusions.map((e) => e.bottom));
|
|
608
|
+
if (above !== undefined && foot > above + EPSILON) {
|
|
609
|
+
this.items.push({ type: 'penalty', penalty: INFINITE_VPENALTY }, { type: 'glue', width: foot - above, stretch: 0, shrink: 0 });
|
|
610
|
+
}
|
|
611
|
+
this.exclusions = [];
|
|
612
|
+
}
|
|
613
|
+
/** The space and break before a block: its own, collapsed with what is waiting. */
|
|
614
|
+
before(el, cs) {
|
|
615
|
+
addSpace(this.boundary, spaceOf(cs, 'before'));
|
|
616
|
+
addBreak(this.boundary, cs.breakBefore, intProperty(cs, '--pw-penalty-before', 0));
|
|
617
|
+
this.conversion.addPenalty(this.boundary, el, 'before');
|
|
618
|
+
}
|
|
619
|
+
after(el, cs) {
|
|
620
|
+
addBreak(this.boundary, cs.breakAfter, intProperty(cs, '--pw-penalty-after', 0));
|
|
621
|
+
this.conversion.addPenalty(this.boundary, el, 'after');
|
|
622
|
+
addSpace(this.boundary, spaceOf(cs, 'after'));
|
|
623
|
+
}
|
|
624
|
+
stringMarks(el, cs) {
|
|
625
|
+
this.boundary.marks.push(...marksOf(el, cs));
|
|
626
|
+
}
|
|
627
|
+
/** A container's border and padding, kept with what is inside it by a +10000 penalty. */
|
|
628
|
+
edge(el, containers, side, height, keep = true) {
|
|
629
|
+
if (side === 'start')
|
|
630
|
+
this.flush();
|
|
631
|
+
else if (keep) {
|
|
632
|
+
this.boundary.avoid = true;
|
|
633
|
+
this.flush();
|
|
634
|
+
}
|
|
635
|
+
if (height > 0) {
|
|
636
|
+
const rect = el.getBoundingClientRect();
|
|
637
|
+
this.items.push({ type: 'box', kind: 'edge', side, height, depth: 0, width: rect.width, shift: rect.left - this.left, element: el, containers });
|
|
638
|
+
}
|
|
639
|
+
if (side === 'start' && keep)
|
|
640
|
+
this.boundary.avoid = true;
|
|
641
|
+
}
|
|
642
|
+
/**
|
|
643
|
+
* Writes out what waits at the boundary: its penalty, then its glue, with
|
|
644
|
+
* any CSS float in it where it stands, then its marks. No page breaks
|
|
645
|
+
* here if a float above reaches the next box.
|
|
646
|
+
*/
|
|
647
|
+
flush() {
|
|
648
|
+
const b = this.boundary;
|
|
649
|
+
const g = b.positive ?? { type: 'glue', width: 0, stretch: 0, shrink: 0 };
|
|
650
|
+
const width = g.width + b.negative + b.clearance;
|
|
651
|
+
if (this.exclusions.length) {
|
|
652
|
+
const above = this.lastBottom();
|
|
653
|
+
if (above !== undefined) {
|
|
654
|
+
if (this.beside(above, above + width))
|
|
655
|
+
b.avoid = true;
|
|
656
|
+
this.exclusions = this.exclusions.filter((e) => e.bottom > above + width + EPSILON);
|
|
657
|
+
}
|
|
658
|
+
}
|
|
659
|
+
const pen = penaltyOf(b);
|
|
660
|
+
if (pen)
|
|
661
|
+
this.items.push(pen);
|
|
662
|
+
let done = 0;
|
|
663
|
+
for (const f of b.floats) {
|
|
664
|
+
if (f.at - done)
|
|
665
|
+
this.items.push({ type: 'glue', width: f.at - done, stretch: 0, shrink: 0 });
|
|
666
|
+
done = f.at;
|
|
667
|
+
this.items.push(...this.floatItems(f.box), ...f.out);
|
|
668
|
+
}
|
|
669
|
+
if (b.positive || width || done)
|
|
670
|
+
this.items.push({ ...g, width: width - done });
|
|
671
|
+
this.items.push(...b.marks);
|
|
672
|
+
this.boundary = emptyBoundary();
|
|
673
|
+
}
|
|
674
|
+
size(rect, depth) {
|
|
675
|
+
return { height: rect.height - depth, depth, width: rect.width, shift: rect.left - this.left };
|
|
676
|
+
}
|
|
677
|
+
}
|
|
678
|
+
/** An element's `string-set`, as marks. */
|
|
679
|
+
function marksOf(el, cs) {
|
|
680
|
+
const value = stringSetOf(cs);
|
|
681
|
+
return value ? parseStringSet(value).map(({ name, parts }) => ({ type: 'mark', kind: 'string', name, text: resolveString(parts, el), element: el })) : [];
|
|
682
|
+
}
|
|
683
|
+
function penaltyOf(b) {
|
|
684
|
+
if (b.forced)
|
|
685
|
+
return { type: 'penalty', penalty: EJECT_PENALTY, ...(b.forced !== 'page' ? { side: b.forced } : {}) };
|
|
686
|
+
if (b.avoid)
|
|
687
|
+
return { type: 'penalty', penalty: INFINITE_VPENALTY };
|
|
688
|
+
const p = combinePenalties(b.penalties);
|
|
689
|
+
if (p)
|
|
690
|
+
return { type: 'penalty', penalty: p };
|
|
691
|
+
return undefined;
|
|
692
|
+
}
|
|
693
|
+
/** Adds a `break-before` or `break-after` and a `--pw-penalty-*` to a boundary: a forced break wins, then an avoided one. */
|
|
694
|
+
function addBreak(b, value, penalty) {
|
|
695
|
+
switch (value) {
|
|
696
|
+
case 'page':
|
|
697
|
+
case 'always':
|
|
698
|
+
b.forced ??= 'page';
|
|
699
|
+
break;
|
|
700
|
+
case 'left':
|
|
701
|
+
case 'verso':
|
|
702
|
+
b.forced = 'left';
|
|
703
|
+
break;
|
|
704
|
+
case 'right':
|
|
705
|
+
case 'recto':
|
|
706
|
+
b.forced = 'right';
|
|
707
|
+
break;
|
|
708
|
+
case 'avoid':
|
|
709
|
+
case 'avoid-page':
|
|
710
|
+
b.avoid = true;
|
|
711
|
+
break;
|
|
712
|
+
}
|
|
713
|
+
if (penalty)
|
|
714
|
+
b.penalties.push(penalty);
|
|
715
|
+
}
|
|
716
|
+
/** Collapses a space into a boundary's: the largest positive (with its stretch and shrink) and the most negative. */
|
|
717
|
+
function addSpace(b, g) {
|
|
718
|
+
if (!g)
|
|
719
|
+
return;
|
|
720
|
+
if (g.width < 0)
|
|
721
|
+
b.negative = Math.min(b.negative, g.width);
|
|
722
|
+
else if (!b.positive || g.width > b.positive.width || (g.width === b.positive.width && g.stretch + g.shrink > b.positive.stretch + b.positive.shrink))
|
|
723
|
+
b.positive = g;
|
|
724
|
+
}
|
|
725
|
+
/** A block's space before or after it: `--pw-space-before`/`-after` where set, else its margin, as fixed glue. */
|
|
726
|
+
function spaceOf(cs, side) {
|
|
727
|
+
const custom = cs.getPropertyValue(`--pw-space-${side}`).trim();
|
|
728
|
+
if (custom)
|
|
729
|
+
return { type: 'glue', ...parseGlue(custom, Number.parseFloat(cs.fontSize)) };
|
|
730
|
+
const margin = Number.parseFloat(side === 'before' ? cs.marginTop : cs.marginBottom) || 0;
|
|
731
|
+
return { type: 'glue', width: margin, stretch: 0, shrink: 0 };
|
|
732
|
+
}
|
|
733
|
+
/** A box's border and padding on one side, in px. In print the border's width is in the padding (`style/borders.ts`). */
|
|
734
|
+
function edge(cs, side) {
|
|
735
|
+
return (Number.parseFloat(cs.getPropertyValue(`padding-${side}`)) || 0) + (Number.parseFloat(cs.getPropertyValue(`border-${side}-width`)) || 0);
|
|
736
|
+
}
|
|
737
|
+
/** Whether a block's margins stay inside it: a new block formatting context. */
|
|
738
|
+
function isFormattingContext(cs) {
|
|
739
|
+
return cs.display === 'flow-root' || (cs.overflowY !== 'visible' && cs.overflowY !== 'clip');
|
|
740
|
+
}
|
|
741
|
+
/**
|
|
742
|
+
* Whether the engine leaves a block to the browser, as one box: replaced
|
|
743
|
+
* elements (an image, SVG, MathML, video), anything whose content isn't
|
|
744
|
+
* block flow (flex, grid, a table that isn't an HTML table), and a block
|
|
745
|
+
* whose inline content is atomic inlines alone.
|
|
746
|
+
*/
|
|
747
|
+
function isLeaf(el, cs) {
|
|
748
|
+
if (isAtomicInline(el, cs))
|
|
749
|
+
return true;
|
|
750
|
+
if (!/^(block|list-item|flow-root|block flow|block flow-root|table)$/.test(cs.display))
|
|
751
|
+
return true;
|
|
752
|
+
if (isParagraph(el))
|
|
753
|
+
return !hasText(el);
|
|
754
|
+
// An empty block is its margins and its height, if it has one.
|
|
755
|
+
return blockChildren(el).length === 0 && !hasText(el);
|
|
756
|
+
}
|
|
757
|
+
/** Whether every child in the flow is inline-level: a block of lines. */
|
|
758
|
+
function isParagraph(el) {
|
|
759
|
+
for (const child of el.children) {
|
|
760
|
+
const cs = getComputedStyle(child);
|
|
761
|
+
if (cs.display === 'none' || floatOf(cs) || runningOf(cs) || cssFloatOf(cs))
|
|
762
|
+
continue;
|
|
763
|
+
if (cs.display === 'contents') {
|
|
764
|
+
if (!isParagraph(child))
|
|
765
|
+
return false;
|
|
766
|
+
}
|
|
767
|
+
else if (!isInlineLevel(cs.display)) {
|
|
768
|
+
return false;
|
|
769
|
+
}
|
|
770
|
+
}
|
|
771
|
+
return true;
|
|
772
|
+
}
|
|
773
|
+
/** Whether a `display` is inline-level: `inline`, `inline-block`, `ruby`, inline MathML (`math` in Chromium). */
|
|
774
|
+
function isInlineLevel(display) {
|
|
775
|
+
return /^inline/.test(display) || display === 'ruby' || display === 'math';
|
|
776
|
+
}
|
|
777
|
+
/** Text in a block's lines, beyond white space. */
|
|
778
|
+
function hasText(el) {
|
|
779
|
+
const walker = document.createTreeWalker(el, NodeFilter.SHOW_TEXT);
|
|
780
|
+
for (let n = walker.nextNode(); n; n = walker.nextNode()) {
|
|
781
|
+
if (!/\S/.test(n.data))
|
|
782
|
+
continue;
|
|
783
|
+
let hidden = false;
|
|
784
|
+
for (let p = n.parentElement; p && p !== el; p = p.parentElement) {
|
|
785
|
+
const cs = getComputedStyle(p);
|
|
786
|
+
if (cs.display === 'none' || isAtomicInline(p, cs) || floatOf(cs) || runningOf(cs) || cssFloatOf(cs))
|
|
787
|
+
hidden = true;
|
|
788
|
+
}
|
|
789
|
+
if (!hidden)
|
|
790
|
+
return true;
|
|
791
|
+
}
|
|
792
|
+
return false;
|
|
793
|
+
}
|
|
794
|
+
/**
|
|
795
|
+
* A container's children as blocks, in order. Inline content beside blocks
|
|
796
|
+
* goes into an anonymous block, `.pw-anonymous`, as CSS boxes it.
|
|
797
|
+
*/
|
|
798
|
+
function blockChildren(el) {
|
|
799
|
+
const out = [];
|
|
800
|
+
let run = [];
|
|
801
|
+
const end = () => {
|
|
802
|
+
// CSS floats between blocks, with no text beside them, are blocks of their own.
|
|
803
|
+
if (run.every((n) => n.nodeType !== Node.ELEMENT_NODE ? !/\S/.test(n.textContent ?? '') : cssFloatOf(getComputedStyle(n)))) {
|
|
804
|
+
out.push(...run.filter((n) => n instanceof HTMLElement));
|
|
805
|
+
run = [];
|
|
806
|
+
return;
|
|
807
|
+
}
|
|
808
|
+
if (run.some((n) => n.nodeType === Node.ELEMENT_NODE || /\S/.test(n.textContent ?? ''))) {
|
|
809
|
+
const anon = document.createElement('div');
|
|
810
|
+
anon.className = 'pw-anonymous';
|
|
811
|
+
run[0].parentNode.insertBefore(anon, run[0]);
|
|
812
|
+
anon.append(...run);
|
|
813
|
+
out.push(anon);
|
|
814
|
+
}
|
|
815
|
+
run = [];
|
|
816
|
+
};
|
|
817
|
+
for (const child of [...el.childNodes]) {
|
|
818
|
+
if (child instanceof HTMLElement && child.classList.contains('pw-held'))
|
|
819
|
+
continue;
|
|
820
|
+
if (child.nodeType === Node.TEXT_NODE) {
|
|
821
|
+
run.push(child);
|
|
822
|
+
continue;
|
|
823
|
+
}
|
|
824
|
+
if (!(child instanceof HTMLElement || child instanceof SVGElement || child instanceof MathMLElement))
|
|
825
|
+
continue;
|
|
826
|
+
const cs = getComputedStyle(child);
|
|
827
|
+
if (cs.display === 'none')
|
|
828
|
+
continue;
|
|
829
|
+
// A CSS float in text stays in its paragraph, which sets its lines beside it.
|
|
830
|
+
const inline = (isInlineLevel(cs.display) || !!cssFloatOf(cs)) && !floatOf(cs) && !runningOf(cs);
|
|
831
|
+
if (inline) {
|
|
832
|
+
run.push(child);
|
|
833
|
+
continue;
|
|
834
|
+
}
|
|
835
|
+
end();
|
|
836
|
+
out.push(child);
|
|
837
|
+
}
|
|
838
|
+
end();
|
|
839
|
+
return out;
|
|
840
|
+
}
|
|
841
|
+
/**
|
|
842
|
+
* The minipages and the CSS floats under the root. A minipage is a box: one
|
|
843
|
+
* that is `display: inline` is made an `inline-block`, so that its width
|
|
844
|
+
* applies and its line holds it whole.
|
|
845
|
+
*/
|
|
846
|
+
function boxesOf(root) {
|
|
847
|
+
const minipages = [];
|
|
848
|
+
const floats = [];
|
|
849
|
+
for (const el of root.querySelectorAll('*')) {
|
|
850
|
+
if (!(el instanceof HTMLElement))
|
|
851
|
+
continue;
|
|
852
|
+
const cs = getComputedStyle(el);
|
|
853
|
+
if (cssFloatOf(cs))
|
|
854
|
+
floats.push(el);
|
|
855
|
+
if (!isMinipage(cs))
|
|
856
|
+
continue;
|
|
857
|
+
if (cs.display === 'inline')
|
|
858
|
+
el.style.display = 'inline-block';
|
|
859
|
+
minipages.push(el);
|
|
860
|
+
}
|
|
861
|
+
return { minipages, floats };
|
|
862
|
+
}
|
|
863
|
+
/** The minipages inside `el`, not inside one another, nor in what leaves the flow (a note's are laid out with it). */
|
|
864
|
+
function innerMinipages(el) {
|
|
865
|
+
const out = [];
|
|
866
|
+
const visit = (parent) => {
|
|
867
|
+
for (const child of parent.children) {
|
|
868
|
+
if (!(child instanceof HTMLElement) || child.classList.contains('pw-held'))
|
|
869
|
+
continue;
|
|
870
|
+
const cs = getComputedStyle(child);
|
|
871
|
+
if (cs.display === 'none' || floatOf(cs) || runningOf(cs))
|
|
872
|
+
continue;
|
|
873
|
+
if (isMinipage(cs))
|
|
874
|
+
out.push(child);
|
|
875
|
+
else
|
|
876
|
+
visit(child);
|
|
877
|
+
}
|
|
878
|
+
};
|
|
879
|
+
visit(el);
|
|
880
|
+
return out;
|
|
881
|
+
}
|
|
882
|
+
/** Where a minipage's notes wait while they are laid out: a `.pw-held` at the end of it, at its measure. */
|
|
883
|
+
function heldIn(minipage) {
|
|
884
|
+
const held = document.createElement('div');
|
|
885
|
+
held.className = 'pw-held';
|
|
886
|
+
held.style.cssText = `display:block;width:${contentBox(minipage, getComputedStyle(minipage)).width}px;margin:0;padding:0;border:0`;
|
|
887
|
+
minipage.append(held);
|
|
888
|
+
return held;
|
|
889
|
+
}
|
|
890
|
+
/** The baseline of each line, in viewport px: where a zero-size inline block at its end sits. */
|
|
891
|
+
function baselinesOf(lines) {
|
|
892
|
+
const probes = lines.map((line) => {
|
|
893
|
+
const probe = document.createElement('span');
|
|
894
|
+
probe.style.cssText = 'display:inline-block;width:0;height:0;vertical-align:baseline;margin:0;padding:0;border:0';
|
|
895
|
+
line.append(probe);
|
|
896
|
+
return probe;
|
|
897
|
+
});
|
|
898
|
+
const out = probes.map((p) => p.getBoundingClientRect().bottom);
|
|
899
|
+
for (const p of probes)
|
|
900
|
+
p.remove();
|
|
901
|
+
return out;
|
|
902
|
+
}
|
|
903
|
+
function contentBox(el, cs) {
|
|
904
|
+
const r = el.getBoundingClientRect();
|
|
905
|
+
const px = (p) => Number.parseFloat(cs.getPropertyValue(p)) || 0;
|
|
906
|
+
const left = r.left + px('border-left-width') + px('padding-left');
|
|
907
|
+
return { left, width: r.width - px('border-left-width') - px('padding-left') - px('padding-right') - px('border-right-width') };
|
|
908
|
+
}
|
|
909
|
+
/** How many columns an element's content is set in: its `column-count`, 1 if `auto`. */
|
|
910
|
+
function columnCount(cs) {
|
|
911
|
+
const n = Number.parseInt(cs.columnCount, 10);
|
|
912
|
+
return Number.isNaN(n) ? 1 : n;
|
|
913
|
+
}
|
|
914
|
+
function intProperty(cs, prop, fallback) {
|
|
915
|
+
const v = Number.parseInt(cs.getPropertyValue(prop).trim(), 10);
|
|
916
|
+
return Number.isNaN(v) ? fallback : v;
|
|
917
|
+
}
|
|
918
|
+
/** A CSS float's side: `float: left` or `right` (or `inline-start`, `inline-end`, by the direction). */
|
|
919
|
+
function cssFloatOf(cs) {
|
|
920
|
+
const f = cs.getPropertyValue('float');
|
|
921
|
+
if (f === 'left' || f === 'right')
|
|
922
|
+
return f;
|
|
923
|
+
const ltr = cs.direction !== 'rtl';
|
|
924
|
+
if (f === 'inline-start')
|
|
925
|
+
return ltr ? 'left' : 'right';
|
|
926
|
+
if (f === 'inline-end')
|
|
927
|
+
return ltr ? 'right' : 'left';
|
|
928
|
+
return undefined;
|
|
929
|
+
}
|
|
930
|
+
/** The CSS floats in a paragraph's text, not inside one another nor in an atomic inline. */
|
|
931
|
+
function innerFloats(el) {
|
|
932
|
+
const out = [];
|
|
933
|
+
const visit = (parent) => {
|
|
934
|
+
for (const child of parent.children) {
|
|
935
|
+
if (!(child instanceof HTMLElement))
|
|
936
|
+
continue;
|
|
937
|
+
const cs = getComputedStyle(child);
|
|
938
|
+
if (cs.display === 'none' || floatOf(cs) || runningOf(cs))
|
|
939
|
+
continue;
|
|
940
|
+
const side = cssFloatOf(cs);
|
|
941
|
+
if (side)
|
|
942
|
+
out.push({ el: child, side });
|
|
943
|
+
else if (!isAtomicInline(child, cs))
|
|
944
|
+
visit(child);
|
|
945
|
+
}
|
|
946
|
+
};
|
|
947
|
+
visit(el);
|
|
948
|
+
return out;
|
|
949
|
+
}
|
|
950
|
+
/** A paragraph's line pitch, in px: its `line-height`, or, if `normal`, the height of a line of its text. */
|
|
951
|
+
function lineHeight(el, cs) {
|
|
952
|
+
const v = Number.parseFloat(cs.lineHeight);
|
|
953
|
+
if (!Number.isNaN(v))
|
|
954
|
+
return v;
|
|
955
|
+
const probe = document.createElement('span');
|
|
956
|
+
probe.style.cssText = 'display:block;margin:0;padding:0;border:0';
|
|
957
|
+
probe.textContent = 'x';
|
|
958
|
+
el.prepend(probe);
|
|
959
|
+
const h = probe.getBoundingClientRect().height;
|
|
960
|
+
probe.remove();
|
|
961
|
+
return h;
|
|
962
|
+
}
|
|
963
|
+
/** GCPM's `float: footnote`, `top` or `bottom`, as the compiler lowers it to `--pw-float`. */
|
|
964
|
+
function floatOf(cs) {
|
|
965
|
+
const v = cs.getPropertyValue('--pw-float').trim();
|
|
966
|
+
return v === 'footnote' || v === 'top' || v === 'bottom' ? v : undefined;
|
|
967
|
+
}
|
|
968
|
+
/** GCPM's `position: running(name)`, as the compiler lowers it to `--pw-running: name`. */
|
|
969
|
+
function runningOf(cs) {
|
|
970
|
+
return cs.getPropertyValue('--pw-running').trim() || undefined;
|
|
971
|
+
}
|
|
972
|
+
function stringSetOf(cs) {
|
|
973
|
+
const v = cs.getPropertyValue('--pw-string-set').trim();
|
|
974
|
+
return v && v !== 'none' ? v : undefined;
|
|
975
|
+
}
|
|
976
|
+
/** Glue and penalties at either end of an insert's list. */
|
|
977
|
+
function trimGlue(list) {
|
|
978
|
+
let a = 0;
|
|
979
|
+
let b = list.length;
|
|
980
|
+
while (a < b && (list[a].type === 'glue' || list[a].type === 'penalty'))
|
|
981
|
+
a++;
|
|
982
|
+
while (b > a && (list[b - 1].type === 'glue' || list[b - 1].type === 'penalty'))
|
|
983
|
+
b--;
|
|
984
|
+
return list.slice(a, b);
|
|
985
|
+
}
|
|
986
|
+
/**
|
|
987
|
+
* GCPM's `string-set` value: `<name> <part>+` pairs, separated by commas,
|
|
988
|
+
* each part a string, `content()` (`text`, `first-letter`; `before`,
|
|
989
|
+
* `after` and `marker` are empty, since the core writes no generated
|
|
990
|
+
* content) or `attr()`. Counters aren't CSS's in the core: numbers are in
|
|
991
|
+
* the text.
|
|
992
|
+
*/
|
|
993
|
+
export function parseStringSet(value) {
|
|
994
|
+
const out = [];
|
|
995
|
+
const re = /\s*(?:(,)|"((?:[^"\\]|\\.)*)"|'((?:[^'\\]|\\.)*)'|([-\w]+)\(\s*([-\w]*)\s*\)|(-?[_a-zA-Z][-\w]*))/y;
|
|
996
|
+
let current;
|
|
997
|
+
let at = 0;
|
|
998
|
+
while (at < value.length) {
|
|
999
|
+
re.lastIndex = at;
|
|
1000
|
+
const m = re.exec(value);
|
|
1001
|
+
if (!m || m[0].length === 0) {
|
|
1002
|
+
if (/^\s*$/.test(value.slice(at)))
|
|
1003
|
+
break;
|
|
1004
|
+
throw new Error(`string-set: can't read ${JSON.stringify(value.slice(at))} in ${JSON.stringify(value)}`);
|
|
1005
|
+
}
|
|
1006
|
+
at = re.lastIndex;
|
|
1007
|
+
const unescape = (s) => s.replace(/\\(.)/g, '$1');
|
|
1008
|
+
if (m[1])
|
|
1009
|
+
current = undefined;
|
|
1010
|
+
else if (m[2] !== undefined || m[3] !== undefined) {
|
|
1011
|
+
if (!current)
|
|
1012
|
+
throw new Error(`string-set: a string with no name in ${JSON.stringify(value)}`);
|
|
1013
|
+
current.parts.push({ kind: 'string', value: unescape(m[2] ?? m[3]) });
|
|
1014
|
+
}
|
|
1015
|
+
else if (m[4]) {
|
|
1016
|
+
if (!current)
|
|
1017
|
+
throw new Error(`string-set: ${m[4]}() with no name in ${JSON.stringify(value)}`);
|
|
1018
|
+
const fn = m[4].toLowerCase();
|
|
1019
|
+
if (fn === 'content')
|
|
1020
|
+
current.parts.push({ kind: 'content', which: m[5] || 'text' });
|
|
1021
|
+
else if (fn === 'attr')
|
|
1022
|
+
current.parts.push({ kind: 'attr', name: m[5] });
|
|
1023
|
+
else
|
|
1024
|
+
throw new Error(`string-set: ${fn}() isn't supported: the core's numbers are in the text, so take them with content()`);
|
|
1025
|
+
}
|
|
1026
|
+
else if (m[6]) {
|
|
1027
|
+
if (current)
|
|
1028
|
+
throw new Error(`string-set: ${m[6]} where a value was expected in ${JSON.stringify(value)}`);
|
|
1029
|
+
current = { name: m[6], parts: [] };
|
|
1030
|
+
out.push(current);
|
|
1031
|
+
}
|
|
1032
|
+
}
|
|
1033
|
+
return out;
|
|
1034
|
+
}
|
|
1035
|
+
function resolveString(parts, el) {
|
|
1036
|
+
return parts.map((p) => {
|
|
1037
|
+
if (p.kind === 'string')
|
|
1038
|
+
return p.value;
|
|
1039
|
+
if (p.kind === 'attr')
|
|
1040
|
+
return el.getAttribute(p.name) ?? '';
|
|
1041
|
+
const text = textOf(el);
|
|
1042
|
+
if (p.which === 'text')
|
|
1043
|
+
return text;
|
|
1044
|
+
if (p.which === 'first-letter')
|
|
1045
|
+
return /^[\p{P}\s]*\P{P}?/u.exec(text)?.[0].trim() ?? '';
|
|
1046
|
+
return '';
|
|
1047
|
+
}).join('');
|
|
1048
|
+
}
|
|
1049
|
+
/** An element's text as a running head shows it: white space collapsed, soft hyphens and what leaves the flow left out. */
|
|
1050
|
+
function textOf(el) {
|
|
1051
|
+
let out = '';
|
|
1052
|
+
const visit = (node) => {
|
|
1053
|
+
for (const child of node.childNodes) {
|
|
1054
|
+
if (child.nodeType === Node.TEXT_NODE)
|
|
1055
|
+
out += child.data;
|
|
1056
|
+
else if (child.nodeType === Node.ELEMENT_NODE) {
|
|
1057
|
+
const e = child;
|
|
1058
|
+
const cs = getComputedStyle(e);
|
|
1059
|
+
if (cs.display === 'none' || floatOf(cs) || runningOf(cs) || e.classList.contains('pw-hyphen'))
|
|
1060
|
+
continue;
|
|
1061
|
+
visit(e);
|
|
1062
|
+
}
|
|
1063
|
+
}
|
|
1064
|
+
};
|
|
1065
|
+
visit(el);
|
|
1066
|
+
return out.replaceAll('', '').replace(/\s+/g, ' ').trim();
|
|
1067
|
+
}
|
|
1068
|
+
//# sourceMappingURL=lists.js.map
|