pulpweaver4 0.0.91 → 0.0.185
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.js +23 -0
- package/dist/ast/djot.js.map +1 -1
- package/dist/ast/index.d.ts +1 -0
- package/dist/ast/index.js +1 -0
- package/dist/ast/index.js.map +1 -1
- package/dist/ast/nodes.d.ts +59 -5
- package/dist/ast/nodes.js.map +1 -1
- package/dist/ast/table.d.ts +27 -0
- package/dist/ast/table.js +32 -0
- package/dist/ast/table.js.map +1 -0
- package/dist/browser.js +2420 -0
- package/dist/citations/index.d.ts +1 -1
- package/dist/citations/index.js +1 -1
- package/dist/citations/index.js.map +1 -1
- package/dist/citations/project.d.ts +12 -2
- package/dist/citations/project.js +21 -7
- package/dist/citations/project.js.map +1 -1
- package/dist/colour/images.d.ts +11 -2
- package/dist/colour/images.js +53 -3
- package/dist/colour/images.js.map +1 -1
- package/dist/colour/ink-limit.d.ts +2 -2
- package/dist/colour/ink-limit.js +6 -0
- package/dist/colour/ink-limit.js.map +1 -1
- package/dist/colour/previews.d.ts +8 -4
- package/dist/colour/previews.js +11 -8
- package/dist/colour/previews.js.map +1 -1
- package/dist/config/config.d.ts +91 -3
- package/dist/config/config.js +200 -3
- package/dist/config/config.js.map +1 -1
- package/dist/config/project-schema.d.ts +0 -8
- package/dist/config/project-schema.js +207 -12
- package/dist/config/project-schema.js.map +1 -1
- package/dist/config/schema.js +10 -0
- package/dist/config/schema.js.map +1 -1
- package/dist/config/secrets.d.ts +11 -0
- package/dist/config/secrets.js +19 -0
- package/dist/config/secrets.js.map +1 -0
- package/dist/csl/project.d.ts +19 -4
- package/dist/csl/project.js +23 -10
- package/dist/csl/project.js.map +1 -1
- package/dist/fonts/index.d.ts +1 -1
- package/dist/fonts/index.js +1 -1
- package/dist/fonts/index.js.map +1 -1
- package/dist/fonts/lint.d.ts +51 -0
- package/dist/fonts/lint.js +101 -16
- package/dist/fonts/lint.js.map +1 -1
- package/dist/fonts/walk.d.ts +13 -0
- package/dist/fonts/walk.js +50 -33
- package/dist/fonts/walk.js.map +1 -1
- package/dist/html/css.d.ts +4 -0
- package/dist/html/css.js +11 -3
- package/dist/html/css.js.map +1 -1
- package/dist/html/dom.d.ts +6 -1
- package/dist/html/dom.js +28 -6
- package/dist/html/dom.js.map +1 -1
- package/dist/html/generated.d.ts +17 -0
- package/dist/html/generated.js +21 -0
- package/dist/html/generated.js.map +1 -0
- package/dist/html/images.d.ts +18 -0
- package/dist/html/images.js +49 -2
- package/dist/html/images.js.map +1 -1
- package/dist/html/index.d.ts +1 -0
- package/dist/html/index.js +1 -0
- package/dist/html/index.js.map +1 -1
- package/dist/html/render.d.ts +5 -4
- package/dist/html/render.js +24 -6
- package/dist/html/render.js.map +1 -1
- package/dist/hyphenation/exceptions.d.ts +5 -0
- package/dist/hyphenation/exceptions.js +11 -0
- package/dist/hyphenation/exceptions.js.map +1 -1
- package/dist/hyphenation/index.d.ts +1 -1
- package/dist/hyphenation/index.js +1 -1
- package/dist/hyphenation/index.js.map +1 -1
- package/dist/import/convert.d.ts +21 -0
- package/dist/import/convert.js +65 -0
- package/dist/import/convert.js.map +1 -0
- package/dist/incremental/cache.d.ts +59 -0
- package/dist/incremental/cache.js +64 -0
- package/dist/incremental/cache.js.map +1 -0
- package/dist/incremental/index.d.ts +3 -0
- package/dist/incremental/index.js +4 -0
- package/dist/incremental/index.js.map +1 -0
- package/dist/incremental/keys.d.ts +27 -0
- package/dist/incremental/keys.js +89 -0
- package/dist/incremental/keys.js.map +1 -0
- package/dist/incremental/session.d.ts +180 -0
- package/dist/incremental/session.js +401 -0
- package/dist/incremental/session.js.map +1 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.js +6 -0
- package/dist/index.js.map +1 -1
- package/dist/indexes/layout.d.ts +8 -2
- package/dist/indexes/layout.js +6 -4
- package/dist/indexes/layout.js.map +1 -1
- package/dist/layout/cache.d.ts +174 -0
- package/dist/layout/cache.js +150 -0
- package/dist/layout/cache.js.map +1 -0
- package/dist/layout/converge.d.ts +28 -0
- package/dist/layout/converge.js +102 -9
- package/dist/layout/converge.js.map +1 -1
- package/dist/layout/counters.d.ts +4 -0
- package/dist/layout/counters.js +15 -0
- package/dist/layout/counters.js.map +1 -1
- package/dist/layout/index.d.ts +5 -2
- package/dist/layout/index.js +3 -0
- package/dist/layout/index.js.map +1 -1
- package/dist/layout/lists.d.ts +52 -3
- package/dist/layout/lists.js +513 -46
- package/dist/layout/lists.js.map +1 -1
- package/dist/layout/lookahead.d.ts +151 -0
- package/dist/layout/lookahead.js +581 -0
- package/dist/layout/lookahead.js.map +1 -0
- package/dist/layout/margin-boxes.d.ts +11 -1
- package/dist/layout/margin-boxes.js +24 -1
- package/dist/layout/margin-boxes.js.map +1 -1
- package/dist/layout/page-rules.d.ts +6 -1
- package/dist/layout/page-rules.js +42 -1
- package/dist/layout/page-rules.js.map +1 -1
- package/dist/layout/page.js +4 -2
- package/dist/layout/page.js.map +1 -1
- package/dist/layout/pagebuilder.d.ts +248 -3
- package/dist/layout/pagebuilder.js +512 -19
- package/dist/layout/pagebuilder.js.map +1 -1
- package/dist/layout/pages.d.ts +108 -1
- package/dist/layout/pages.js +1362 -159
- package/dist/layout/pages.js.map +1 -1
- package/dist/layout/paragraph.d.ts +14 -0
- package/dist/layout/paragraph.js +304 -31
- package/dist/layout/paragraph.js.map +1 -1
- package/dist/layout/pre.js +4 -0
- package/dist/layout/pre.js.map +1 -1
- package/dist/layout/protrusion.d.ts +26 -0
- package/dist/layout/protrusion.js +39 -0
- package/dist/layout/protrusion.js.map +1 -0
- package/dist/layout/ranges.d.ts +2 -0
- package/dist/layout/ranges.js +22 -0
- package/dist/layout/ranges.js.map +1 -0
- package/dist/layout/region.d.ts +2 -1
- package/dist/layout/region.js +9 -5
- package/dist/layout/region.js.map +1 -1
- package/dist/layout/templates.d.ts +71 -0
- package/dist/layout/templates.js +290 -0
- package/dist/layout/templates.js.map +1 -0
- package/dist/layout/vlist.d.ts +3 -3
- package/dist/linebreak/items.d.ts +27 -2
- package/dist/linebreak/items.js +10 -3
- package/dist/linebreak/items.js.map +1 -1
- package/dist/linebreak/knuth-plass.d.ts +20 -0
- package/dist/linebreak/knuth-plass.js +68 -16
- package/dist/linebreak/knuth-plass.js.map +1 -1
- package/dist/lint/book.d.ts +13 -0
- package/dist/lint/book.js +52 -0
- package/dist/lint/book.js.map +1 -0
- package/dist/lint/config.d.ts +9 -0
- package/dist/lint/config.js +40 -6
- package/dist/lint/config.js.map +1 -1
- package/dist/lint/linter.js +1 -0
- package/dist/lint/linter.js.map +1 -1
- package/dist/lint/project.js +1 -1
- package/dist/lint/project.js.map +1 -1
- package/dist/lint/rules/layout.d.ts +3 -1
- package/dist/lint/rules/layout.js +8 -6
- package/dist/lint/rules/layout.js.map +1 -1
- package/dist/lint/rules/source.js +1 -1
- package/dist/lint/rules/source.js.map +1 -1
- package/dist/lint/testing.js +1 -0
- package/dist/lint/testing.js.map +1 -1
- package/dist/measure/bidi-data.d.ts +14 -0
- package/dist/measure/bidi-data.js +69 -0
- package/dist/measure/bidi-data.js.map +1 -0
- package/dist/measure/bidi.d.ts +70 -0
- package/dist/measure/bidi.js +225 -0
- package/dist/measure/bidi.js.map +1 -0
- package/dist/measure/css.d.ts +5 -0
- package/dist/measure/css.js +2 -0
- package/dist/measure/css.js.map +1 -1
- package/dist/measure/measurer.d.ts +36 -2
- package/dist/measure/measurer.js +220 -22
- package/dist/measure/measurer.js.map +1 -1
- package/dist/measure/model.d.ts +20 -2
- package/dist/measure/model.js +13 -6
- package/dist/measure/model.js.map +1 -1
- package/dist/measure/script-data.d.ts +6 -0
- package/dist/measure/script-data.js +34 -0
- package/dist/measure/script-data.js.map +1 -0
- package/dist/measure/scripts.d.ts +36 -0
- package/dist/measure/scripts.js +293 -0
- package/dist/measure/scripts.js.map +1 -0
- package/dist/output/output.d.ts +35 -3
- package/dist/output/output.js +26 -4
- package/dist/output/output.js.map +1 -1
- package/dist/paint/backgrounds.js +7 -20
- package/dist/paint/backgrounds.js.map +1 -1
- package/dist/paint/blend.d.ts +33 -13
- package/dist/paint/blend.js +73 -21
- package/dist/paint/blend.js.map +1 -1
- package/dist/paint/cache.d.ts +80 -0
- package/dist/paint/cache.js +537 -0
- package/dist/paint/cache.js.map +1 -0
- package/dist/paint/canvas.d.ts +4 -13
- package/dist/paint/canvas.js +45 -5
- package/dist/paint/canvas.js.map +1 -1
- package/dist/paint/context.d.ts +2 -0
- package/dist/paint/emphasis.js +1 -1
- package/dist/paint/emphasis.js.map +1 -1
- package/dist/paint/flatten.d.ts +24 -2
- package/dist/paint/flatten.js +55 -12
- package/dist/paint/flatten.js.map +1 -1
- package/dist/paint/forms.d.ts +64 -0
- package/dist/paint/forms.js +319 -0
- package/dist/paint/forms.js.map +1 -0
- package/dist/paint/images.d.ts +4 -1
- package/dist/paint/images.js +13 -2
- package/dist/paint/images.js.map +1 -1
- package/dist/paint/layers.d.ts +64 -0
- package/dist/paint/layers.js +137 -0
- package/dist/paint/layers.js.map +1 -0
- package/dist/paint/painter.d.ts +19 -6
- package/dist/paint/painter.js +15 -135
- package/dist/paint/painter.js.map +1 -1
- package/dist/paint/stacking.d.ts +1 -1
- package/dist/paint/stacking.js +9 -2
- package/dist/paint/stacking.js.map +1 -1
- package/dist/paint/text.d.ts +14 -3
- package/dist/paint/text.js +25 -4
- package/dist/paint/text.js.map +1 -1
- package/dist/paint/vertical.js +2 -2
- package/dist/paint/vertical.js.map +1 -1
- package/dist/pdf/encoded.d.ts +16 -0
- package/dist/pdf/encoded.js +35 -0
- package/dist/pdf/encoded.js.map +1 -0
- package/dist/pdf/include/colour.d.ts +105 -0
- package/dist/pdf/include/colour.js +349 -0
- package/dist/pdf/include/colour.js.map +1 -0
- package/dist/pdf/include/functions.d.ts +17 -0
- package/dist/pdf/include/functions.js +389 -0
- package/dist/pdf/include/functions.js.map +1 -0
- package/dist/pdf/include/pages.d.ts +14 -0
- package/dist/pdf/include/pages.js +27 -0
- package/dist/pdf/include/pages.js.map +1 -0
- package/dist/pdf/include/pdfjs/LICENSE +177 -0
- package/dist/pdf/include/pdfjs/pdf.min.mjs +27 -0
- package/dist/pdf/include/pdfjs/pdf.worker.min.mjs +27 -0
- package/dist/pdf/include/pdfjs/standard_fonts/FoxitDingbats.pfb +0 -0
- package/dist/pdf/include/pdfjs/standard_fonts/FoxitFixed.pfb +0 -0
- package/dist/pdf/include/pdfjs/standard_fonts/FoxitFixedBold.pfb +0 -0
- package/dist/pdf/include/pdfjs/standard_fonts/FoxitFixedBoldItalic.pfb +0 -0
- package/dist/pdf/include/pdfjs/standard_fonts/FoxitFixedItalic.pfb +0 -0
- package/dist/pdf/include/pdfjs/standard_fonts/FoxitSerif.pfb +0 -0
- package/dist/pdf/include/pdfjs/standard_fonts/FoxitSerifBold.pfb +0 -0
- package/dist/pdf/include/pdfjs/standard_fonts/FoxitSerifBoldItalic.pfb +0 -0
- package/dist/pdf/include/pdfjs/standard_fonts/FoxitSerifItalic.pfb +0 -0
- package/dist/pdf/include/pdfjs/standard_fonts/FoxitSymbol.pfb +0 -0
- package/dist/pdf/include/pdfjs/standard_fonts/LICENSE_FOXIT +27 -0
- package/dist/pdf/include/pdfjs/standard_fonts/LICENSE_LIBERATION +363 -0
- package/dist/pdf/include/pdfjs/standard_fonts/LiberationSans-Bold.ttf +0 -0
- package/dist/pdf/include/pdfjs/standard_fonts/LiberationSans-BoldItalic.ttf +0 -0
- package/dist/pdf/include/pdfjs/standard_fonts/LiberationSans-Italic.ttf +0 -0
- package/dist/pdf/include/pdfjs/standard_fonts/LiberationSans-Regular.ttf +0 -0
- package/dist/pdf/include/pdfjs/wasm/LICENSE_JBIG2 +196 -0
- package/dist/pdf/include/pdfjs/wasm/LICENSE_OPENJPEG +39 -0
- package/dist/pdf/include/pdfjs/wasm/LICENSE_PDFJS_JBIG2 +13 -0
- package/dist/pdf/include/pdfjs/wasm/LICENSE_PDFJS_OPENJPEG +22 -0
- package/dist/pdf/include/pdfjs/wasm/LICENSE_PDFJS_QCMS +19 -0
- package/dist/pdf/include/pdfjs/wasm/LICENSE_QCMS +21 -0
- package/dist/pdf/include/pdfjs/wasm/jbig2.wasm +0 -0
- package/dist/pdf/include/pdfjs/wasm/openjpeg.wasm +0 -0
- package/dist/pdf/include/pdfjs/wasm/qcms_bg.wasm +0 -0
- package/dist/pdf/include/pdfjs/wasm/quickjs-eval.wasm +0 -0
- package/dist/pdf/include/prepare.d.ts +58 -0
- package/dist/pdf/include/prepare.js +266 -0
- package/dist/pdf/include/prepare.js.map +1 -0
- package/dist/pdf/include/preview.d.ts +38 -0
- package/dist/pdf/include/preview.js +101 -0
- package/dist/pdf/include/preview.js.map +1 -0
- package/dist/pdf/include/rewrite.d.ts +57 -0
- package/dist/pdf/include/rewrite.js +803 -0
- package/dist/pdf/include/rewrite.js.map +1 -0
- package/dist/pdf/include/serialize.d.ts +32 -0
- package/dist/pdf/include/serialize.js +158 -0
- package/dist/pdf/include/serialize.js.map +1 -0
- package/dist/pdf/include/testing.d.ts +26 -0
- package/dist/pdf/include/testing.js +50 -0
- package/dist/pdf/include/testing.js.map +1 -0
- package/dist/pdf/index.d.ts +1 -0
- package/dist/pdf/index.js +1 -0
- package/dist/pdf/index.js.map +1 -1
- package/dist/pdf/structure/annotations.d.ts +33 -0
- package/dist/pdf/structure/annotations.js +112 -0
- package/dist/pdf/structure/annotations.js.map +1 -0
- package/dist/pdf/structure/forms.d.ts +10 -0
- package/dist/pdf/structure/forms.js +46 -0
- package/dist/pdf/structure/forms.js.map +1 -0
- package/dist/pdf/structure/index.d.ts +41 -5
- package/dist/pdf/structure/index.js +40 -5
- package/dist/pdf/structure/index.js.map +1 -1
- package/dist/pdf/structure/links.d.ts +2 -0
- package/dist/pdf/structure/links.js +1 -1
- package/dist/pdf/structure/links.js.map +1 -1
- package/dist/pdf/structure/presentation.d.ts +28 -0
- package/dist/pdf/structure/presentation.js +79 -0
- package/dist/pdf/structure/presentation.js.map +1 -0
- package/dist/pdf/structure/tags.d.ts +34 -2
- package/dist/pdf/structure/tags.js +117 -14
- package/dist/pdf/structure/tags.js.map +1 -1
- package/dist/pdf/types.d.ts +357 -11
- package/dist/pdf/wasm/pulpweaver4_pdf.d.ts +44 -2
- package/dist/pdf/wasm/pulpweaver4_pdf.js +191 -2
- package/dist/pdf/wasm/pulpweaver4_pdf_bg.wasm +0 -0
- package/dist/pdf/writer.d.ts +13 -1
- package/dist/pdf/writer.js +26 -1
- package/dist/pdf/writer.js.map +1 -1
- package/dist/plugin/define.d.ts +200 -15
- package/dist/plugin/define.js +124 -15
- package/dist/plugin/define.js.map +1 -1
- package/dist/plugin/failure.d.ts +1 -1
- package/dist/plugin/index.d.ts +5 -4
- package/dist/plugin/index.js +5 -4
- package/dist/plugin/index.js.map +1 -1
- package/dist/plugin/reference.d.ts +38 -0
- package/dist/plugin/reference.js +287 -0
- package/dist/plugin/reference.js.map +1 -0
- package/dist/plugin/register.d.ts +39 -7
- package/dist/plugin/register.js +83 -2
- package/dist/plugin/register.js.map +1 -1
- package/dist/preflight/index.d.ts +1 -1
- package/dist/preflight/index.js +1 -1
- package/dist/preflight/index.js.map +1 -1
- package/dist/preflight/pdfx.d.ts +35 -0
- package/dist/preflight/pdfx.js +33 -2
- package/dist/preflight/pdfx.js.map +1 -1
- package/dist/preflight/reader.d.ts +10 -3
- package/dist/preflight/reader.js +86 -5
- package/dist/preflight/reader.js.map +1 -1
- package/dist/print/impose.d.ts +66 -0
- package/dist/print/impose.js +331 -0
- package/dist/print/impose.js.map +1 -0
- package/dist/print/output.js +400 -50
- package/dist/print/output.js.map +1 -1
- package/dist/problem.js +4 -3
- package/dist/problem.js.map +1 -1
- package/dist/profile/index.d.ts +1 -0
- package/dist/profile/index.js +1 -0
- package/dist/profile/index.js.map +1 -1
- package/dist/profile/lint.d.ts +1 -1
- package/dist/profile/lint.js +29 -1
- package/dist/profile/lint.js.map +1 -1
- package/dist/profile/list-table.d.ts +51 -0
- package/dist/profile/list-table.js +137 -0
- package/dist/profile/list-table.js.map +1 -0
- package/dist/profile/metadata.js +3 -0
- package/dist/profile/metadata.js.map +1 -1
- package/dist/profile/profile.d.ts +3 -0
- package/dist/profile/profile.js +9 -1
- package/dist/profile/profile.js.map +1 -1
- package/dist/project.js +3 -0
- package/dist/project.js.map +1 -1
- package/dist/qpdf/index.d.ts +2 -0
- package/dist/qpdf/index.js +3 -0
- package/dist/qpdf/index.js.map +1 -0
- package/dist/qpdf/qpdf.d.ts +125 -0
- package/dist/qpdf/qpdf.js +205 -0
- package/dist/qpdf/qpdf.js.map +1 -0
- package/dist/qpdf/testing.d.ts +12 -0
- package/dist/qpdf/testing.js +9 -0
- package/dist/qpdf/testing.js.map +1 -0
- package/dist/qpdf/wasm/LICENSE-qpdf +202 -0
- package/dist/qpdf/wasm/LICENSE-zlib +22 -0
- package/dist/qpdf/wasm/NOTICE-qpdf.md +42 -0
- package/dist/qpdf/wasm/qpdf.wasm +0 -0
- package/dist/render/index.d.ts +3 -0
- package/dist/render/index.js +2 -0
- package/dist/render/index.js.map +1 -0
- package/dist/render/render.d.ts +98 -0
- package/dist/render/render.js +243 -0
- package/dist/render/render.js.map +1 -0
- package/dist/reproducible/clock.d.ts +4 -5
- package/dist/reproducible/clock.js +4 -5
- package/dist/reproducible/clock.js.map +1 -1
- package/dist/spike/spike-page.chromium.json +4 -4
- package/dist/style/colours.d.ts +7 -2
- package/dist/style/colours.js +24 -2
- package/dist/style/colours.js.map +1 -1
- package/dist/style/compile.js +1 -1
- package/dist/style/compile.js.map +1 -1
- package/dist/style/defaults.d.ts +9 -3
- package/dist/style/defaults.js +14 -2
- package/dist/style/defaults.js.map +1 -1
- package/dist/style/gcpm.d.ts +1 -1
- package/dist/style/gcpm.js +17 -5
- package/dist/style/gcpm.js.map +1 -1
- package/dist/style/properties.js +84 -0
- package/dist/style/properties.js.map +1 -1
- package/dist/test/book.d.ts +22 -2
- package/dist/test/book.js +35 -2
- package/dist/test/book.js.map +1 -1
- package/dist/test/build.d.ts +23 -0
- package/dist/test/build.js +86 -33
- package/dist/test/build.js.map +1 -1
- package/dist/test/layout.js +128 -19
- package/dist/test/layout.js.map +1 -1
- package/dist/test/limits.d.ts +8 -0
- package/dist/test/limits.js +9 -0
- package/dist/test/limits.js.map +1 -0
- package/dist/test/pipeline.d.ts +23 -0
- package/dist/test/pipeline.js.map +1 -1
- package/dist/test/render.d.ts +26 -3
- package/dist/test/render.js +151 -23
- package/dist/test/render.js.map +1 -1
- package/dist/test/runner.d.ts +6 -3
- package/dist/test/runner.js +172 -105
- package/dist/test/runner.js.map +1 -1
- package/dist/test/text.js +2 -2
- package/dist/test/text.js.map +1 -1
- package/dist/text/output.js +2 -2
- package/dist/text/output.js.map +1 -1
- package/dist/text/render.d.ts +4 -3
- package/dist/text/render.js +126 -4
- package/dist/text/render.js.map +1 -1
- package/dist/transform/index.d.ts +1 -1
- package/dist/transform/index.js +1 -1
- package/dist/transform/index.js.map +1 -1
- package/dist/transform/run.d.ts +2 -0
- package/dist/transform/run.js +32 -16
- package/dist/transform/run.js.map +1 -1
- package/dist/web/output.js +116 -10
- package/dist/web/output.js.map +1 -1
- package/dist/web/runtime/justify.js.txt +2 -2
- package/dist/web/site.d.ts +2 -0
- package/dist/web/site.js +8 -1
- package/dist/web/site.js.map +1 -1
- package/docs/README.md +6 -1
- package/docs/manual/chapters/front.dj +34 -0
- package/docs/manual/chapters/guides/citations.dj +426 -0
- package/docs/manual/chapters/guides/colour-and-prepress.dj +261 -0
- package/docs/manual/chapters/guides/editions.dj +329 -0
- package/docs/manual/chapters/guides/in-a-web-page.dj +143 -0
- package/docs/manual/chapters/guides/lines-and-pages.dj +681 -0
- package/docs/manual/chapters/guides/lint-rules.dj +355 -0
- package/docs/manual/chapters/guides/pdfs.dj +501 -0
- package/docs/manual/chapters/guides/plugins.dj +425 -0
- package/docs/manual/chapters/guides/testing.dj +264 -0
- package/docs/manual/chapters/guides/writing-in-djot.dj +537 -0
- package/docs/manual/chapters/start/for-latex-users.dj +256 -0
- package/docs/manual/chapters/start/getting-started.dj +167 -0
- package/docs/manual/chapters/start/your-first-book.dj +426 -0
- package/docs/manual/fonts/CrimsonPro-Italic-VF.ttf +0 -0
- package/docs/manual/fonts/CrimsonPro-VF.ttf +0 -0
- package/docs/manual/fonts/JetBrainsMono-Regular.otf +0 -0
- package/docs/manual/fonts/NotoSansSymbols2-Boxes.ttf +0 -0
- package/docs/manual/fonts/OFL.txt +95 -0
- package/docs/manual/pulpweaver4.toml +39 -0
- package/docs/manual/styles/manual.css +137 -0
- package/docs/reference/css-properties/index.md +9 -0
- package/docs/reference/css-properties/pw-expansion.md +31 -0
- package/docs/reference/css-properties/pw-flow-into.md +31 -0
- package/docs/reference/css-properties/pw-knockout.md +26 -0
- package/docs/reference/css-properties/pw-layer.md +24 -0
- package/docs/reference/css-properties/pw-page-breaking.md +30 -0
- package/docs/reference/css-properties/pw-page-duration.md +28 -0
- package/docs/reference/css-properties/pw-page-rotate.md +29 -0
- package/docs/reference/css-properties/pw-page-transition.md +29 -0
- package/docs/reference/css-properties/pw-protrusion.md +31 -0
- package/docs/reference/lint-rules/ibid-across-page.md +2 -2
- package/docs/reference/plugin-api/capabilities.md +2 -2
- package/docs/reference/plugin-api/claim-kind.md +1 -1
- package/docs/reference/plugin-api/combine-exceptions.md +19 -0
- package/docs/reference/plugin-api/element-break-context.md +34 -0
- package/docs/reference/plugin-api/element-break-item.md +24 -0
- package/docs/reference/plugin-api/element-breaker.md +24 -0
- package/docs/reference/plugin-api/flow-definition.md +30 -0
- package/docs/reference/plugin-api/generated-reference.md +32 -0
- package/docs/reference/plugin-api/index-definition.md +32 -0
- package/docs/reference/plugin-api/index-titles.md +18 -0
- package/docs/reference/plugin-api/index.md +27 -3
- package/docs/reference/plugin-api/insert-class-definition.md +46 -0
- package/docs/reference/plugin-api/insert-placement.md +22 -0
- package/docs/reference/plugin-api/insert-placements.md +18 -0
- package/docs/reference/plugin-api/layout-definition.md +9 -5
- package/docs/reference/plugin-api/layout-slot.md +6 -16
- package/docs/reference/plugin-api/lint-context.md +3 -1
- package/docs/reference/plugin-api/lint-definition.md +1 -1
- package/docs/reference/plugin-api/lint-edition.md +2 -0
- package/docs/reference/plugin-api/page-builder-event.md +22 -0
- package/docs/reference/plugin-api/page-builder-hook.md +7 -3
- package/docs/reference/plugin-api/page-builder-page-event.md +30 -0
- package/docs/reference/plugin-api/page-template-definition.md +34 -0
- package/docs/reference/plugin-api/page-template-region-definition.md +46 -0
- package/docs/reference/plugin-api/plugin-definition.md +5 -1
- package/docs/reference/plugin-api/plugin-reference-options.md +32 -0
- package/docs/reference/plugin-api/plugin-reference.md +22 -0
- package/docs/reference/plugin-api/plugin-registry.md +15 -5
- package/docs/reference/plugin-api/plugin-stage.md +1 -1
- package/docs/reference/plugin-api/plugin.md +9 -2
- package/docs/reference/plugin-api/reference-page.md +34 -0
- package/docs/reference/plugin-api/render-reference-page.md +18 -0
- package/docs/reference/plugin-api/renderers.md +1 -1
- package/docs/reference/pulpweaver4-toml/editions.md +239 -2
- package/docs/reference/pulpweaver4-toml/index.md +44 -1
- package/docs/reference/pulpweaver4-toml/inks.md +15 -4
- package/docs/reference/pulpweaver4-toml/lint.md +1 -1
- package/package.json +5 -1
package/dist/layout/lists.js
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { combinePenalties } from '../plugin/register.js';
|
|
2
|
+
import { containerKey, paragraphKey, styleKey } from './cache.js';
|
|
3
|
+
import { pageCounterOf } from './counters.js';
|
|
2
4
|
import { BIGSKIP, parseGlue, parseLength } from './glue.js';
|
|
3
5
|
import { buildMinipage, isMinipage, minipageFootnotes, packMinipage } from './minipage.js';
|
|
4
6
|
import { isAtomicInline, layoutParagraph } from './paragraph.js';
|
|
@@ -14,12 +16,57 @@ const LINE_PENALTIES = {
|
|
|
14
16
|
const AVOID = /^avoid/;
|
|
15
17
|
/** Converts `root`'s content into TeX's vertical list, laying out its paragraphs. */
|
|
16
18
|
export function buildVerticalList(root, opts) {
|
|
19
|
+
// Before anything is styled or measured, what is reused is emptied, so
|
|
20
|
+
// the browser styles and lays out only what is new: whole containers by
|
|
21
|
+
// their HTML, then, once styled, paragraphs by their style too.
|
|
22
|
+
const containers = opts.cache && opts.reuseContainers !== false ? stashContainers(root, opts.cache) : undefined;
|
|
17
23
|
const { minipages, floats } = boxesOf(root);
|
|
18
|
-
const conversion = new Conversion(root, opts, minipages, floats);
|
|
24
|
+
const conversion = new Conversion(root, opts, minipages, floats, containers);
|
|
25
|
+
if (opts.cache && !isParagraph(root))
|
|
26
|
+
conversion.stashParagraphs(root);
|
|
19
27
|
const items = conversion.list(root);
|
|
20
28
|
return { items, ...(conversion.held ? { held: conversion.held } : {}) };
|
|
21
29
|
}
|
|
22
30
|
const emptyBoundary = () => ({ negative: 0, avoid: false, penalties: [], marks: [], floats: [], clearance: 0 });
|
|
31
|
+
const copyBoundary = (b) => ({ ...b, penalties: [...b.penalties], marks: [...b.marks], floats: [...b.floats] });
|
|
32
|
+
/** Whether two boundaries hold the same, as far as what follows them is concerned (none with a CSS float waiting). */
|
|
33
|
+
function sameBoundary(a, b) {
|
|
34
|
+
const glue = (g) => (g ? `${g.width},${g.stretch},${g.stretchOrder ?? 0},${g.shrink}` : '');
|
|
35
|
+
const marks = (ms) => ms.map((m) => (m.kind === 'string' ? `s${m.name}\0${m.text}` : `r${m.name}\0${m.element.dataset.pwKey}`)).join('\0');
|
|
36
|
+
return glue(a.positive) === glue(b.positive) && a.negative === b.negative && a.forced === b.forced && a.avoid === b.avoid &&
|
|
37
|
+
a.clearance === b.clearance && !a.floats.length && !b.floats.length && a.penalties.join() === b.penalties.join() && marks(a.marks) === marks(b.marks);
|
|
38
|
+
}
|
|
39
|
+
/** The style that says what a container is, beyond what its lines depend on. */
|
|
40
|
+
const CONTAINER_STYLE = ['break-inside', 'float', 'column-count', 'position', '--pw-float', '--pw-running', '--pw-box', '--pw-string-set'];
|
|
41
|
+
/**
|
|
42
|
+
* Finds the containers the cache has as they are, among the root's
|
|
43
|
+
* children and theirs, by their HTML ({@link containerKey}), read before
|
|
44
|
+
* anything is styled, and empties each; the keys of those it hasn't are
|
|
45
|
+
* kept for the list to keep them under.
|
|
46
|
+
*/
|
|
47
|
+
function stashContainers(root, cache) {
|
|
48
|
+
const stashed = new Map();
|
|
49
|
+
const keys = new Map();
|
|
50
|
+
const visit = (el, depth) => {
|
|
51
|
+
for (const child of el.children) {
|
|
52
|
+
if (!(child instanceof HTMLElement) || !child.firstElementChild || child.dataset['pwKey'] === undefined)
|
|
53
|
+
continue;
|
|
54
|
+
const key = containerKey(child, root);
|
|
55
|
+
const entry = cache.find(child, 'container', key);
|
|
56
|
+
if (entry) {
|
|
57
|
+
stashed.set(child, { entry, children: [...child.childNodes] });
|
|
58
|
+
child.replaceChildren();
|
|
59
|
+
}
|
|
60
|
+
else {
|
|
61
|
+
keys.set(child, key);
|
|
62
|
+
if (depth < 2)
|
|
63
|
+
visit(child, depth + 1);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
};
|
|
67
|
+
visit(root, 1);
|
|
68
|
+
return { stashed, keys };
|
|
69
|
+
}
|
|
23
70
|
/** How near two positions must be to be the same: a 1/100 px. */
|
|
24
71
|
const EPSILON = 0.01;
|
|
25
72
|
/** One conversion: the held elements are shared by every list it makes. */
|
|
@@ -29,17 +76,28 @@ class Conversion {
|
|
|
29
76
|
minipages;
|
|
30
77
|
floats;
|
|
31
78
|
held;
|
|
79
|
+
/** The paragraphs in the flow the cache has, emptied (`stash`). */
|
|
80
|
+
stashed = new Map();
|
|
81
|
+
/** Paragraphs' keys (`paragraphKey`), worked out before they were laid out. */
|
|
82
|
+
keys = new Map();
|
|
83
|
+
/** The containers the cache has, emptied, and the keys of those it may keep (`stashContainers`). */
|
|
84
|
+
containers;
|
|
85
|
+
containerKeys;
|
|
86
|
+
/** Every element held (`hold`), in order. */
|
|
87
|
+
heldElements = [];
|
|
32
88
|
/** While a minipage whose notes stay inside is converted: the minipage, and where its notes wait. */
|
|
33
89
|
notes;
|
|
34
90
|
constructor(root, opts,
|
|
35
91
|
/** Every minipage under the root, so that a box with none in it isn't searched. */
|
|
36
92
|
minipages = [],
|
|
37
93
|
/** Every CSS float under the root, so that a paragraph with none in it isn't searched. */
|
|
38
|
-
floats = []) {
|
|
94
|
+
floats = [], containers) {
|
|
39
95
|
this.root = root;
|
|
40
96
|
this.opts = opts;
|
|
41
97
|
this.minipages = minipages;
|
|
42
98
|
this.floats = floats;
|
|
99
|
+
this.containers = containers?.stashed ?? new Map();
|
|
100
|
+
this.containerKeys = containers?.keys ?? new Map();
|
|
43
101
|
}
|
|
44
102
|
/** The CSS floats in a paragraph's text (`innerFloats`). */
|
|
45
103
|
floatsIn(el) {
|
|
@@ -47,7 +105,11 @@ class Conversion {
|
|
|
47
105
|
}
|
|
48
106
|
/** The vertical list of `el`'s content, positions relative to its content box. */
|
|
49
107
|
list(el) {
|
|
50
|
-
|
|
108
|
+
return this.build(el).items;
|
|
109
|
+
}
|
|
110
|
+
/** The builder of `el`'s list, done; `multicol` when `el` is a multi-column element, at its content box. */
|
|
111
|
+
build(el, multicol) {
|
|
112
|
+
const builder = new Builder(this, el, el === this.root, multicol);
|
|
51
113
|
if (el instanceof HTMLTableElement)
|
|
52
114
|
builder.table(el, []);
|
|
53
115
|
else if (isParagraph(el) && hasText(el) && isPreformatted(getComputedStyle(el)))
|
|
@@ -59,7 +121,139 @@ class Conversion {
|
|
|
59
121
|
else
|
|
60
122
|
builder.contents(el, []);
|
|
61
123
|
builder.finish();
|
|
62
|
-
return builder
|
|
124
|
+
return builder;
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* Finds the paragraphs in the flow under `el` that the cache has as they
|
|
128
|
+
* are (`cache.ts`), as `Builder.block` will meet them, and empties each,
|
|
129
|
+
* keeping its children and its own marks, so that laying out what is new
|
|
130
|
+
* doesn't lay out what is reused.
|
|
131
|
+
*/
|
|
132
|
+
stashParagraphs(root) {
|
|
133
|
+
const cache = this.opts.cache;
|
|
134
|
+
const found = [];
|
|
135
|
+
// Found first, then emptied, so that no style is worked out again between.
|
|
136
|
+
const visit = (el) => {
|
|
137
|
+
for (const child of blockChildren(el)) {
|
|
138
|
+
if (this.containers.has(child))
|
|
139
|
+
continue;
|
|
140
|
+
const cs = getComputedStyle(child);
|
|
141
|
+
if (cs.display === 'contents') {
|
|
142
|
+
visit(child);
|
|
143
|
+
continue;
|
|
144
|
+
}
|
|
145
|
+
const kind = this.kindOf(child, cs);
|
|
146
|
+
if (kind === 'container')
|
|
147
|
+
visit(child);
|
|
148
|
+
if (kind !== 'paragraph' || !cache.has(child, 'paragraph') || !this.reusable(child))
|
|
149
|
+
continue;
|
|
150
|
+
const entry = cache.find(child, 'paragraph', paragraphKey(child, cs, this.root));
|
|
151
|
+
if (!entry)
|
|
152
|
+
continue;
|
|
153
|
+
this.stashed.set(child, { entry, children: [...child.childNodes], marks: marksOf(child, cs) });
|
|
154
|
+
found.push(child);
|
|
155
|
+
}
|
|
156
|
+
};
|
|
157
|
+
visit(root);
|
|
158
|
+
for (const el of found)
|
|
159
|
+
el.replaceChildren();
|
|
160
|
+
}
|
|
161
|
+
/**
|
|
162
|
+
* Whether a container the cache has may be reused where the list meets
|
|
163
|
+
* it: its own style and its measure as they were, no float beside it.
|
|
164
|
+
* If not, it is filled again, and its paragraphs looked for.
|
|
165
|
+
*/
|
|
166
|
+
fits(el, cs, floating) {
|
|
167
|
+
const stashed = this.containers.get(el);
|
|
168
|
+
if (!stashed)
|
|
169
|
+
return undefined;
|
|
170
|
+
const { entry } = stashed;
|
|
171
|
+
if (!floating && containerStyle(cs) === entry.style && Math.abs(contentBox(el, cs).width - entry.measure) <= EPSILON / 100)
|
|
172
|
+
return stashed;
|
|
173
|
+
this.unstash(el);
|
|
174
|
+
return undefined;
|
|
175
|
+
}
|
|
176
|
+
/** A container the cache had, filled again, its paragraphs looked for. */
|
|
177
|
+
unstash(el) {
|
|
178
|
+
const stashed = this.containers.get(el);
|
|
179
|
+
if (!stashed)
|
|
180
|
+
return;
|
|
181
|
+
this.containers.delete(el);
|
|
182
|
+
el.replaceChildren(...stashed.children);
|
|
183
|
+
this.stashParagraphs(el);
|
|
184
|
+
}
|
|
185
|
+
/** Whether the cache may keep a container whole: one of the flow's, with nothing in it the list sizes from where it stands. */
|
|
186
|
+
containable(el) {
|
|
187
|
+
return this.opts.reuseContainers !== false && this.containerKeys.has(el) &&
|
|
188
|
+
!this.floats.some((f) => el.contains(f)) && !this.minipages.some((m) => el.contains(m)) && !el.querySelector('table') &&
|
|
189
|
+
!this.breaksInside(el);
|
|
190
|
+
}
|
|
191
|
+
/** Whether a plugin's element breaker claims `el` or something in it. */
|
|
192
|
+
breaksInside(el) {
|
|
193
|
+
const sels = this.opts.elementBreaks;
|
|
194
|
+
if (!sels?.length)
|
|
195
|
+
return false;
|
|
196
|
+
for (const s of sels) {
|
|
197
|
+
try {
|
|
198
|
+
if (el.matches(s) || el.querySelector(s))
|
|
199
|
+
return true;
|
|
200
|
+
}
|
|
201
|
+
catch {
|
|
202
|
+
// A selector that isn't one matches nothing.
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
return false;
|
|
206
|
+
}
|
|
207
|
+
/** Whether a plugin's element breaker claims `el` itself. */
|
|
208
|
+
matchesBreak(el) {
|
|
209
|
+
const sels = this.opts.elementBreaks;
|
|
210
|
+
if (!sels?.length)
|
|
211
|
+
return false;
|
|
212
|
+
for (const s of sels) {
|
|
213
|
+
try {
|
|
214
|
+
if (el.matches(s))
|
|
215
|
+
return true;
|
|
216
|
+
}
|
|
217
|
+
catch {
|
|
218
|
+
// A selector that isn't one matches nothing.
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
return false;
|
|
222
|
+
}
|
|
223
|
+
/** A paragraph's key, as it was before its layout changed it, which it is read before. */
|
|
224
|
+
keyOf(el) {
|
|
225
|
+
return this.keys.get(el) ?? paragraphKey(el, getComputedStyle(el), this.root);
|
|
226
|
+
}
|
|
227
|
+
/** Whether a paragraph in the flow may be reused or kept: no floats or minipages in it or beside it, no plugin's breaker. */
|
|
228
|
+
reusable(el) {
|
|
229
|
+
const parent = el.parentElement ?? el;
|
|
230
|
+
return !this.floats.some((f) => parent.contains(f)) && !this.minipages.some((m) => el.contains(m)) && !this.opts.lineBreaker?.(el) && !this.breaksInside(el);
|
|
231
|
+
}
|
|
232
|
+
/** What `Builder.block` makes of an element in the flow, by its style. */
|
|
233
|
+
kindOf(el, cs, floated = false) {
|
|
234
|
+
if (cs.display === 'none')
|
|
235
|
+
return 'none';
|
|
236
|
+
if (cs.display === 'contents')
|
|
237
|
+
return 'contents';
|
|
238
|
+
if (!floated && runningOf(cs))
|
|
239
|
+
return 'running';
|
|
240
|
+
if (!floated && this.floatOf(cs))
|
|
241
|
+
return 'insert';
|
|
242
|
+
if (!floated && cssFloatOf(cs))
|
|
243
|
+
return 'float';
|
|
244
|
+
if (columnCount(cs) > 1)
|
|
245
|
+
return 'columns';
|
|
246
|
+
if (isMinipage(cs))
|
|
247
|
+
return 'minipage';
|
|
248
|
+
if (AVOID.test(cs.breakInside) || this.isBox(el))
|
|
249
|
+
return 'vbox';
|
|
250
|
+
if (el instanceof HTMLTableElement && /table$/.test(cs.display))
|
|
251
|
+
return 'table';
|
|
252
|
+
if (isLeaf(el, cs))
|
|
253
|
+
return 'leaf';
|
|
254
|
+
if (isParagraph(el))
|
|
255
|
+
return isPreformatted(cs) ? 'pre' : 'paragraph';
|
|
256
|
+
return 'container';
|
|
63
257
|
}
|
|
64
258
|
/** Whether a plugin keeps the element whole (`ListOptions.boxes`). */
|
|
65
259
|
isBox(el) {
|
|
@@ -77,6 +271,7 @@ class Conversion {
|
|
|
77
271
|
}
|
|
78
272
|
/** 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
273
|
hold(el) {
|
|
274
|
+
this.heldElements.push(el);
|
|
80
275
|
if (!this.held) {
|
|
81
276
|
this.held = document.createElement('div');
|
|
82
277
|
this.held.className = 'pw-held';
|
|
@@ -96,10 +291,19 @@ class Conversion {
|
|
|
96
291
|
*/
|
|
97
292
|
insert(el, cls) {
|
|
98
293
|
let held;
|
|
294
|
+
const customWidth = this.opts.insertWidths?.get(cls);
|
|
99
295
|
if (cls === 'footnote' && this.notes) {
|
|
100
296
|
held = this.notes.held ??= heldIn(this.notes.minipage);
|
|
101
297
|
held.append(el);
|
|
102
298
|
}
|
|
299
|
+
else if (customWidth !== undefined) {
|
|
300
|
+
const box = document.createElement('div');
|
|
301
|
+
box.className = 'pw-held-insert';
|
|
302
|
+
box.style.cssText = `display:block;width:${customWidth}px;margin:0;padding:0;border:0`;
|
|
303
|
+
this.hold(box);
|
|
304
|
+
box.append(el);
|
|
305
|
+
held = box;
|
|
306
|
+
}
|
|
103
307
|
else {
|
|
104
308
|
this.hold(el);
|
|
105
309
|
held = this.held;
|
|
@@ -113,6 +317,10 @@ class Conversion {
|
|
|
113
317
|
const list = trimGlue(builder.items);
|
|
114
318
|
return { type: 'insert', class: cls, element: el, list, height: naturalHeight(list) };
|
|
115
319
|
}
|
|
320
|
+
/** Whether `cs` names a recognized insert class (`footnote`, `top`, `bottom`, or a plugin-registered class). */
|
|
321
|
+
floatOf(cs) {
|
|
322
|
+
return floatOf(cs, this.opts.insertClasses);
|
|
323
|
+
}
|
|
116
324
|
/**
|
|
117
325
|
* A minipage (`minipage.ts`): its own list, built and stacked inside it,
|
|
118
326
|
* its footnotes at its foot unless they go out.
|
|
@@ -169,7 +377,7 @@ class Conversion {
|
|
|
169
377
|
migrated.set(e, { cssFloat: true });
|
|
170
378
|
return 'hold';
|
|
171
379
|
}
|
|
172
|
-
const float = floatOf(cs);
|
|
380
|
+
const float = this.floatOf(cs);
|
|
173
381
|
const running = runningOf(cs);
|
|
174
382
|
if (float)
|
|
175
383
|
migrated.set(e, { float });
|
|
@@ -184,16 +392,38 @@ class Conversion {
|
|
|
184
392
|
});
|
|
185
393
|
}
|
|
186
394
|
}
|
|
395
|
+
/** A container's style, as its cache entry has it: what its lines depend on, and what makes it a container. */
|
|
396
|
+
function containerStyle(cs) {
|
|
397
|
+
return `${styleKey(cs)}\n${CONTAINER_STYLE.map((p) => cs.getPropertyValue(p)).join('\n')}`;
|
|
398
|
+
}
|
|
187
399
|
/** Builds one vertical list. */
|
|
188
400
|
class Builder {
|
|
189
401
|
conversion;
|
|
402
|
+
flow;
|
|
403
|
+
multicol;
|
|
190
404
|
items = [];
|
|
191
405
|
boundary = emptyBoundary();
|
|
192
406
|
left;
|
|
193
407
|
/** The CSS floats whose lines are still being set: those that reach below the last box. */
|
|
194
408
|
exclusions = [];
|
|
195
|
-
|
|
409
|
+
/** How many multi-column boxes it has made, which a container the cache keeps has none of. */
|
|
410
|
+
columnRows = 0;
|
|
411
|
+
/**
|
|
412
|
+
* Where the list of a multi-column element's content (`multicol`) turns
|
|
413
|
+
* from its columns to a spanner (`column-span: all`) or back: each part's
|
|
414
|
+
* first item.
|
|
415
|
+
*/
|
|
416
|
+
cuts = [];
|
|
417
|
+
/** Whether the last box was a spanner's. */
|
|
418
|
+
spanning = false;
|
|
419
|
+
constructor(conversion, root,
|
|
420
|
+
/** Whether this is the flow's own list, whose paragraphs a cache may keep. */
|
|
421
|
+
flow = false,
|
|
422
|
+
/** When the list is a multi-column element's content: that element's content box, which a spanner is set across. */
|
|
423
|
+
multicol) {
|
|
196
424
|
this.conversion = conversion;
|
|
425
|
+
this.flow = flow;
|
|
426
|
+
this.multicol = multicol;
|
|
197
427
|
this.left = contentBox(root, getComputedStyle(root)).left;
|
|
198
428
|
}
|
|
199
429
|
/** A container's children, in order, each a block. */
|
|
@@ -201,49 +431,139 @@ class Builder {
|
|
|
201
431
|
for (const child of blockChildren(el))
|
|
202
432
|
this.block(child, containers);
|
|
203
433
|
}
|
|
434
|
+
/**
|
|
435
|
+
* A container's content: reused whole if the cache has it and the same
|
|
436
|
+
* waits before it, else made, and kept if the cache may keep it, with
|
|
437
|
+
* what was kept in it.
|
|
438
|
+
*/
|
|
439
|
+
containerContents(el, inside, cs) {
|
|
440
|
+
const stashed = this.conversion.containers.get(el);
|
|
441
|
+
if (stashed) {
|
|
442
|
+
if (sameBoundary(this.boundary, stashed.entry.before)) {
|
|
443
|
+
this.conversion.containers.delete(el);
|
|
444
|
+
this.replay(inside, stashed.entry);
|
|
445
|
+
this.opts.cache.keep(el, stashed.entry, true);
|
|
446
|
+
return;
|
|
447
|
+
}
|
|
448
|
+
this.conversion.unstash(el);
|
|
449
|
+
}
|
|
450
|
+
const cache = this.opts.cache;
|
|
451
|
+
const key = this.conversion.containerKeys.get(el);
|
|
452
|
+
if (!cache || !this.flow || this.exclusions.length || key === undefined || !this.conversion.containable(el)) {
|
|
453
|
+
this.contents(el, inside);
|
|
454
|
+
return;
|
|
455
|
+
}
|
|
456
|
+
const before = copyBoundary(this.boundary);
|
|
457
|
+
const from = this.items.length;
|
|
458
|
+
const mark = cache.mark();
|
|
459
|
+
const held = this.conversion.heldElements.length;
|
|
460
|
+
const columns = this.columnRows;
|
|
461
|
+
const marks = marksOf(el, cs);
|
|
462
|
+
const measure = contentBox(el, cs).width;
|
|
463
|
+
this.contents(el, inside);
|
|
464
|
+
if (this.exclusions.length || this.columnRows !== columns)
|
|
465
|
+
return;
|
|
466
|
+
const items = this.items.slice(from);
|
|
467
|
+
// The page counters its elements set, read while they are in the document.
|
|
468
|
+
const seen = new Set();
|
|
469
|
+
for (const item of items) {
|
|
470
|
+
if (item.type !== 'box')
|
|
471
|
+
continue;
|
|
472
|
+
for (const e of [...item.containers.slice(inside.length), ...(item.kind === 'line' ? [] : [item.element])]) {
|
|
473
|
+
if (seen.has(e))
|
|
474
|
+
continue;
|
|
475
|
+
seen.add(e);
|
|
476
|
+
const n = pageCounterOf(getComputedStyle(e));
|
|
477
|
+
if (n !== undefined)
|
|
478
|
+
cache.resets.set(e, n);
|
|
479
|
+
}
|
|
480
|
+
}
|
|
481
|
+
cache.keep(el, {
|
|
482
|
+
kind: 'container', key, style: containerStyle(cs), measure, depth: inside.length, before, after: copyBoundary(this.boundary), items,
|
|
483
|
+
held: this.conversion.heldElements.slice(held), inside: cache.since(mark), marks,
|
|
484
|
+
}, false);
|
|
485
|
+
}
|
|
486
|
+
/** A container's content as the cache has it: its items, sitting in this list's containers, and what waits after it. */
|
|
487
|
+
replay(inside, entry) {
|
|
488
|
+
const chains = new Map();
|
|
489
|
+
const chain = (c) => {
|
|
490
|
+
let out = chains.get(c);
|
|
491
|
+
if (!out)
|
|
492
|
+
chains.set(c, (out = [...inside, ...c.slice(entry.depth)]));
|
|
493
|
+
return out;
|
|
494
|
+
};
|
|
495
|
+
for (const item of entry.items)
|
|
496
|
+
this.items.push(item.type === 'box' ? { ...item, containers: chain(item.containers) } : item);
|
|
497
|
+
this.boundary = copyBoundary(entry.after);
|
|
498
|
+
for (const e of entry.held)
|
|
499
|
+
this.conversion.hold(e);
|
|
500
|
+
}
|
|
204
501
|
/** An element in the flow, at block level; `floated` when it is an insert's own element. */
|
|
205
502
|
block(el, containers, floated = false) {
|
|
206
503
|
const cs = getComputedStyle(el);
|
|
207
|
-
|
|
504
|
+
// A plugin that breaks this element hands the page builder its own list.
|
|
505
|
+
if (!floated && cs.display !== 'none' && cs.display !== 'contents' && this.conversion.matchesBreak(el)) {
|
|
506
|
+
const broken = this.opts.elementBreaker?.(el, {
|
|
507
|
+
element: el,
|
|
508
|
+
measure: contentBox(el, cs).width,
|
|
509
|
+
fonts: this.opts.fonts,
|
|
510
|
+
...(this.opts.hyphenator ? { hyphenator: this.opts.hyphenator } : {}),
|
|
511
|
+
});
|
|
512
|
+
if (broken) {
|
|
513
|
+
this.placeBroken(el, containers, cs, broken);
|
|
514
|
+
return;
|
|
515
|
+
}
|
|
516
|
+
}
|
|
517
|
+
// A paragraph or a container the cache has is empty until now, and is what it was.
|
|
518
|
+
const stashed = this.conversion.stashed.get(el);
|
|
519
|
+
const container = this.conversion.fits(el, cs, this.exclusions.length > 0);
|
|
520
|
+
const kind = stashed ? 'paragraph' : container ? 'container' : this.conversion.kindOf(el, cs, floated);
|
|
521
|
+
if (kind === 'none')
|
|
208
522
|
return;
|
|
209
|
-
if (
|
|
523
|
+
if (kind === 'contents') {
|
|
210
524
|
this.contents(el, containers);
|
|
211
525
|
return;
|
|
212
526
|
}
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
this.boundary.marks.push({ type: 'mark', kind: 'running', name: running, element: el });
|
|
527
|
+
if (kind === 'running') {
|
|
528
|
+
this.boundary.marks.push({ type: 'mark', kind: 'running', name: runningOf(cs), element: el });
|
|
216
529
|
this.conversion.hold(el);
|
|
217
530
|
return;
|
|
218
531
|
}
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
this.items.push(this.conversion.insert(el, float));
|
|
532
|
+
if (kind === 'insert') {
|
|
533
|
+
this.items.push(this.conversion.insert(el, this.conversion.floatOf(cs)));
|
|
222
534
|
return;
|
|
223
535
|
}
|
|
224
|
-
|
|
225
|
-
if (side) {
|
|
536
|
+
if (kind === 'float') {
|
|
226
537
|
// It waits at the boundary, to go before the next box.
|
|
227
|
-
const { box, out } = this.cssFloat(el,
|
|
538
|
+
const { box, out } = this.cssFloat(el, cssFloatOf(cs), containers);
|
|
228
539
|
this.boundary.floats.push({ box, at: (this.boundary.positive?.width ?? 0) + this.boundary.negative, out });
|
|
229
540
|
return;
|
|
230
541
|
}
|
|
542
|
+
if (this.multicol)
|
|
543
|
+
this.spanner(el, containers, cs);
|
|
231
544
|
this.before(el, cs);
|
|
232
545
|
if (cs.clear !== 'none' && this.exclusions.length)
|
|
233
546
|
this.clear(el, cs.clear);
|
|
234
|
-
|
|
547
|
+
if (stashed)
|
|
548
|
+
this.boundary.marks.push(...stashed.marks);
|
|
549
|
+
else if (container)
|
|
550
|
+
this.boundary.marks.push(...container.entry.marks);
|
|
551
|
+
else
|
|
552
|
+
this.stringMarks(el, cs);
|
|
235
553
|
const inside = [...containers, el];
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
554
|
+
if (stashed) {
|
|
555
|
+
this.cached(el, inside, cs, stashed);
|
|
556
|
+
}
|
|
557
|
+
else if (kind === 'columns') {
|
|
558
|
+
this.columns(el, containers, cs, columnCount(cs));
|
|
239
559
|
}
|
|
240
|
-
else if (
|
|
560
|
+
else if (kind === 'minipage') {
|
|
241
561
|
// One box; what leaves it follows it, as a \vbox's inserts do.
|
|
242
562
|
this.flush();
|
|
243
563
|
const packed = this.conversion.minipage(el);
|
|
244
564
|
this.items.push(this.minipageBox(el, packed, containers), ...packed.out);
|
|
245
565
|
}
|
|
246
|
-
else if (
|
|
566
|
+
else if (kind === 'vbox') {
|
|
247
567
|
this.flush();
|
|
248
568
|
const inner = this.conversion.list(el);
|
|
249
569
|
// Its inserts and marks migrate out, after it, for the page builder
|
|
@@ -256,10 +576,10 @@ class Builder {
|
|
|
256
576
|
this.items.push({ type: 'box', kind: 'vbox', list, ...this.size(rect, depth), element: el, containers });
|
|
257
577
|
this.items.push(...inner.filter((i) => i.type === 'insert' || i.type === 'mark'));
|
|
258
578
|
}
|
|
259
|
-
else if (
|
|
579
|
+
else if (kind === 'table') {
|
|
260
580
|
this.table(el, containers);
|
|
261
581
|
}
|
|
262
|
-
else if (
|
|
582
|
+
else if (kind === 'leaf') {
|
|
263
583
|
const inner = this.conversion.minipagesIn(el);
|
|
264
584
|
const rect = el.getBoundingClientRect();
|
|
265
585
|
// An empty block is its margins, which collapse through it.
|
|
@@ -268,10 +588,10 @@ class Builder {
|
|
|
268
588
|
this.items.push({ type: 'box', kind: 'block', ...this.size(rect, 0), element: el, containers, ...this.inner(inner.boxes) }, ...inner.out);
|
|
269
589
|
}
|
|
270
590
|
}
|
|
271
|
-
else if (
|
|
591
|
+
else if (kind === 'pre') {
|
|
272
592
|
this.pre(el, containers, cs);
|
|
273
593
|
}
|
|
274
|
-
else if (
|
|
594
|
+
else if (kind === 'paragraph') {
|
|
275
595
|
this.paragraph(el, inside);
|
|
276
596
|
}
|
|
277
597
|
else {
|
|
@@ -281,13 +601,49 @@ class Builder {
|
|
|
281
601
|
const bfc = top > 0 || isFormattingContext(cs);
|
|
282
602
|
if (bfc)
|
|
283
603
|
this.edge(el, containers, 'start', top);
|
|
284
|
-
this.
|
|
604
|
+
this.containerContents(el, inside, cs);
|
|
285
605
|
const bottom = edge(cs, 'bottom');
|
|
286
606
|
if (bfc || bottom > 0)
|
|
287
607
|
this.edge(el, containers, 'end', bottom);
|
|
288
608
|
}
|
|
289
609
|
this.after(el, cs);
|
|
290
610
|
}
|
|
611
|
+
/**
|
|
612
|
+
* In a multi-column element's content, where a block starts a part of
|
|
613
|
+
* the list: a spanner (`column-span: all`, in the columns' own flow) after
|
|
614
|
+
* the columns' content, or that content after a spanner. As Chromium sets
|
|
615
|
+
* them, the columns' last margin is dropped before a spanner, and a
|
|
616
|
+
* spanner's margins don't collapse with the columns' content, only with
|
|
617
|
+
* a spanner's next to it. A spanner is set across the element's content
|
|
618
|
+
* box, its margin box as wide as that, in its style, which its clones
|
|
619
|
+
* keep: it is laid out as it will be rebuilt, out of the columns.
|
|
620
|
+
*/
|
|
621
|
+
spanner(el, containers, cs) {
|
|
622
|
+
const spans = cs.columnSpan === 'all' && containers.every((c) => !isFormattingContext(getComputedStyle(c)));
|
|
623
|
+
if (spans) {
|
|
624
|
+
const ml = Number.parseFloat(cs.marginLeft) || 0;
|
|
625
|
+
const mr = Number.parseFloat(cs.marginRight) || 0;
|
|
626
|
+
const parent = el.parentElement;
|
|
627
|
+
const outer = contentBox(parent, getComputedStyle(parent));
|
|
628
|
+
const width = el.getBoundingClientRect().width;
|
|
629
|
+
el.style.setProperty('margin-left', `${ml + this.multicol.left - outer.left}px`);
|
|
630
|
+
if (Math.abs(width + ml + mr - outer.width) < EPSILON) {
|
|
631
|
+
el.style.setProperty('box-sizing', 'border-box');
|
|
632
|
+
el.style.setProperty('width', `${Math.max(0, this.multicol.width - ml - mr)}px`);
|
|
633
|
+
}
|
|
634
|
+
}
|
|
635
|
+
if (spans === this.spanning)
|
|
636
|
+
return;
|
|
637
|
+
if (spans) {
|
|
638
|
+
delete this.boundary.positive;
|
|
639
|
+
this.boundary.negative = 0;
|
|
640
|
+
}
|
|
641
|
+
else {
|
|
642
|
+
this.flush();
|
|
643
|
+
}
|
|
644
|
+
this.cuts.push({ at: this.items.length, span: spans });
|
|
645
|
+
this.spanning = spans;
|
|
646
|
+
}
|
|
291
647
|
/**
|
|
292
648
|
* A CSS float (`float: left` or `right`): its content laid out in it, as
|
|
293
649
|
* a kept box's, and its margin box, which the lines after it are set
|
|
@@ -382,33 +738,52 @@ class Builder {
|
|
|
382
738
|
/**
|
|
383
739
|
* A multi-column element: its content laid out at one column's width,
|
|
384
740
|
* as one list for the page layout to break into columns. Its marks come
|
|
385
|
-
* before it and its inserts after it.
|
|
386
|
-
* `
|
|
741
|
+
* before it and its inserts after it. A spanner in it (`column-span:
|
|
742
|
+
* all`) parts it: the columns before it end there, as one box, its own
|
|
743
|
+
* boxes are set across them, in this list, and the columns go on after
|
|
744
|
+
* it in another box (`spanner`). Its own border and padding aren't
|
|
745
|
+
* handled.
|
|
387
746
|
*/
|
|
388
747
|
columns(el, containers, cs, count) {
|
|
748
|
+
this.columnRows++;
|
|
389
749
|
this.flush();
|
|
390
750
|
const em = Number.parseFloat(cs.fontSize) || 16;
|
|
391
751
|
const gap = cs.columnGap === 'normal' || cs.columnGap === '' ? em : parseLength(cs.columnGap, em);
|
|
392
|
-
const
|
|
752
|
+
const content = contentBox(el, cs);
|
|
753
|
+
const columnWidth = Math.max(0, (content.width - gap * (count - 1)) / count);
|
|
393
754
|
// Laid out in one column, at a column's width, so every box is measured where it will be.
|
|
394
755
|
const style = el.getAttribute('style');
|
|
395
756
|
el.style.setProperty('column-count', 'auto');
|
|
396
757
|
el.style.setProperty('column-width', 'auto');
|
|
397
758
|
el.style.setProperty('box-sizing', 'content-box');
|
|
398
759
|
el.style.setProperty('width', `${columnWidth}px`);
|
|
399
|
-
const
|
|
760
|
+
const builder = this.conversion.build(el, content);
|
|
400
761
|
if (style === null)
|
|
401
762
|
el.removeAttribute('style');
|
|
402
763
|
else
|
|
403
764
|
el.setAttribute('style', style);
|
|
404
765
|
const rect = el.getBoundingClientRect();
|
|
405
|
-
const
|
|
406
|
-
|
|
407
|
-
this.
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
766
|
+
const inner = builder.items;
|
|
767
|
+
const cuts = [{ at: 0, span: false }, ...builder.cuts];
|
|
768
|
+
const shift = content.left - this.left;
|
|
769
|
+
for (const [n, { at, span }] of cuts.entries()) {
|
|
770
|
+
const part = inner.slice(at, cuts[n + 1]?.at ?? inner.length);
|
|
771
|
+
if (span) {
|
|
772
|
+
// Its boxes in the list as the element's own, outside its columns.
|
|
773
|
+
for (const i of part)
|
|
774
|
+
this.items.push(i.type === 'box' ? { ...i, containers: [...containers, el, ...i.containers], shift: i.shift + shift } : i);
|
|
775
|
+
continue;
|
|
776
|
+
}
|
|
777
|
+
const list = part.filter((i) => i.type !== 'insert' && i.type !== 'mark');
|
|
778
|
+
this.items.push(...part.filter((i) => i.type === 'mark'));
|
|
779
|
+
if (list.some((i) => i.type === 'box')) {
|
|
780
|
+
this.items.push({
|
|
781
|
+
type: 'box', kind: 'columns', count, columnWidth, gap, list, height: naturalHeight(list), depth: 0, width: rect.width,
|
|
782
|
+
shift: rect.left - this.left, element: el, containers,
|
|
783
|
+
});
|
|
784
|
+
}
|
|
785
|
+
this.items.push(...part.filter((i) => i.type === 'insert'));
|
|
786
|
+
}
|
|
412
787
|
}
|
|
413
788
|
/** Content the browser lays out, as one box: a paragraph of atomic inlines alone. */
|
|
414
789
|
leaf(el) {
|
|
@@ -480,8 +855,42 @@ class Builder {
|
|
|
480
855
|
return combinePenalties([Math.max(EJECT_PENALTY, Math.min(INFINITE_VPENALTY, pen)), ...insidePenalties]);
|
|
481
856
|
};
|
|
482
857
|
}
|
|
858
|
+
/**
|
|
859
|
+
* A plugin's vertical list for an element: its boxes, glue and penalties,
|
|
860
|
+
* in place of the element's own layout. A box is the element or one inside
|
|
861
|
+
* it. Penalties the plugins put inside the element combine with the
|
|
862
|
+
* breaker's, and a forbidden break stays forbidden.
|
|
863
|
+
*/
|
|
864
|
+
placeBroken(el, containers, cs, items) {
|
|
865
|
+
this.before(el, cs);
|
|
866
|
+
this.flush();
|
|
867
|
+
const inside = combinePenalties(this.conversion.inside([...containers, el]));
|
|
868
|
+
const chain = [...containers, el];
|
|
869
|
+
for (const item of items) {
|
|
870
|
+
if (item.type === 'penalty') {
|
|
871
|
+
this.items.push({ type: 'penalty', penalty: inside === undefined ? item.penalty : combinePenalties([item.penalty, inside]) });
|
|
872
|
+
}
|
|
873
|
+
else if (item.type === 'glue') {
|
|
874
|
+
this.items.push({
|
|
875
|
+
type: 'glue', width: item.width, stretch: item.stretch ?? 0, shrink: item.shrink ?? 0,
|
|
876
|
+
...(item.stretchOrder ? { stretchOrder: item.stretchOrder } : {}),
|
|
877
|
+
});
|
|
878
|
+
}
|
|
879
|
+
else {
|
|
880
|
+
const rect = item.element.getBoundingClientRect();
|
|
881
|
+
this.items.push({
|
|
882
|
+
type: 'box', kind: 'block', ...this.size(rect, 0), element: item.element,
|
|
883
|
+
containers: item.element === el ? containers : chain,
|
|
884
|
+
});
|
|
885
|
+
}
|
|
886
|
+
}
|
|
887
|
+
this.after(el, cs);
|
|
888
|
+
}
|
|
483
889
|
/** A paragraph: its lines, the penalties between them, and what migrates out of it after its line. */
|
|
484
890
|
paragraph(el, containers) {
|
|
891
|
+
// What it is laid out from, read before its layout changes it, if a cache is to keep it.
|
|
892
|
+
const key = this.opts.cache && this.flow && !this.exclusions.length && el !== this.root && this.conversion.reusable(el)
|
|
893
|
+
? this.conversion.keyOf(el) : undefined;
|
|
485
894
|
const migrants = new Map();
|
|
486
895
|
// Its minipages first, which it measures as atomic inlines; then the
|
|
487
896
|
// floats in its text, where the browser put them, and the lines' shape.
|
|
@@ -504,6 +913,7 @@ class Builder {
|
|
|
504
913
|
}
|
|
505
914
|
const penalty = this.linePenalty(el, getComputedStyle(el), containers, lines.length, (n) => lines[n].hyphenated);
|
|
506
915
|
const migrated = new Map();
|
|
916
|
+
const held = [];
|
|
507
917
|
for (const m of layout.migrated) {
|
|
508
918
|
const e = m.element;
|
|
509
919
|
const what = migrants.get(e);
|
|
@@ -516,6 +926,7 @@ class Builder {
|
|
|
516
926
|
else if ('running' in what) {
|
|
517
927
|
items.push({ type: 'mark', kind: 'running', name: what.running, element: e });
|
|
518
928
|
this.conversion.hold(e);
|
|
929
|
+
held.push(e);
|
|
519
930
|
}
|
|
520
931
|
else
|
|
521
932
|
items.push(...what.marks);
|
|
@@ -526,6 +937,8 @@ class Builder {
|
|
|
526
937
|
migrated.set(n, [...(migrated.get(n) ?? []), ...packed.out]);
|
|
527
938
|
}
|
|
528
939
|
const baselines = baselinesOf(lines.map((l) => l.element));
|
|
940
|
+
const box = key === undefined ? undefined : contentBox(el, getComputedStyle(el));
|
|
941
|
+
const cached = [];
|
|
529
942
|
for (const [n, line] of lines.entries()) {
|
|
530
943
|
if (n > 0)
|
|
531
944
|
this.items.push({ type: 'penalty', penalty: this.beside(rects[n - 1].bottom, rects[n].top) ? INFINITE_VPENALTY : penalty(n) });
|
|
@@ -533,14 +946,57 @@ class Builder {
|
|
|
533
946
|
this.items.push(...this.floatItems(f.box), ...f.out);
|
|
534
947
|
const rect = rects[n];
|
|
535
948
|
const height = baselines[n] - rect.top;
|
|
949
|
+
const out = migrated.get(n) ?? [];
|
|
536
950
|
this.items.push({
|
|
537
951
|
type: 'box', kind: 'line', height, depth: rect.bottom - baselines[n], width: rect.width, shift: rect.left - this.left,
|
|
538
952
|
element: line.element, containers, paragraph: layout, line: n, ...this.inner(inner.boxes, line.element),
|
|
539
953
|
});
|
|
540
|
-
this.items.push(...
|
|
954
|
+
this.items.push(...out);
|
|
955
|
+
if (box)
|
|
956
|
+
cached.push({ height, depth: rect.bottom - baselines[n], width: rect.width, shift: rect.left - box.left, migrated: out });
|
|
541
957
|
}
|
|
542
958
|
for (const f of hung.get(lines.length) ?? [])
|
|
543
959
|
this.items.push(...this.floatItems(f.box), ...f.out);
|
|
960
|
+
if (box)
|
|
961
|
+
this.opts.cache.keep(el, { kind: 'paragraph', key: key, measure: box.width, layout, lines: cached, held }, false);
|
|
962
|
+
}
|
|
963
|
+
/**
|
|
964
|
+
* A paragraph the cache has ({@link Conversion.stash}): its lines as they
|
|
965
|
+
* were set, at its measure, with what migrated out of them, and the
|
|
966
|
+
* penalties between them as this flow makes them. If its measure
|
|
967
|
+
* changed, or a float above reaches it, it is laid out again.
|
|
968
|
+
*/
|
|
969
|
+
cached(el, containers, cs, stashed) {
|
|
970
|
+
const { entry } = stashed;
|
|
971
|
+
const box = contentBox(el, cs);
|
|
972
|
+
this.conversion.stashed.delete(el);
|
|
973
|
+
if (this.exclusions.length || Math.abs(box.width - entry.measure) > EPSILON / 100) {
|
|
974
|
+
el.replaceChildren(...stashed.children);
|
|
975
|
+
this.conversion.keys.set(el, entry.key);
|
|
976
|
+
this.paragraph(el, containers);
|
|
977
|
+
return;
|
|
978
|
+
}
|
|
979
|
+
this.flush();
|
|
980
|
+
const { layout } = entry;
|
|
981
|
+
const penalty = this.linePenalty(el, cs, containers, entry.lines.length, (n) => layout.lines[n].hyphenated);
|
|
982
|
+
for (const [n, line] of entry.lines.entries()) {
|
|
983
|
+
if (n > 0)
|
|
984
|
+
this.items.push({ type: 'penalty', penalty: penalty(n) });
|
|
985
|
+
this.items.push({
|
|
986
|
+
type: 'box', kind: 'line', height: line.height, depth: line.depth, width: line.width, shift: box.left - this.left + line.shift,
|
|
987
|
+
element: layout.lines[n].element, containers, paragraph: layout, line: n,
|
|
988
|
+
});
|
|
989
|
+
this.items.push(...line.migrated);
|
|
990
|
+
}
|
|
991
|
+
for (const e of entry.held)
|
|
992
|
+
this.conversion.hold(e);
|
|
993
|
+
this.opts.cache.keep(el, entry, true);
|
|
994
|
+
}
|
|
995
|
+
get opts() {
|
|
996
|
+
return this.conversion.opts;
|
|
997
|
+
}
|
|
998
|
+
get root() {
|
|
999
|
+
return this.conversion.root;
|
|
544
1000
|
}
|
|
545
1001
|
/** A table, broken between its rows; its captions and edges stay with the rows next to them. */
|
|
546
1002
|
table(table, containers) {
|
|
@@ -565,13 +1021,21 @@ class Builder {
|
|
|
565
1021
|
}
|
|
566
1022
|
else {
|
|
567
1023
|
this.edge(table, containers, 'start', rows[0].getBoundingClientRect().top - y, false);
|
|
1024
|
+
// Rows a cell spans down are one box's rows: no break between them.
|
|
1025
|
+
const joined = new Set();
|
|
1026
|
+
rows.forEach((row, i) => {
|
|
1027
|
+
for (const cell of row.cells)
|
|
1028
|
+
for (let k = 1; k < cell.rowSpan && i + k < rows.length; k++)
|
|
1029
|
+
joined.add(rows[i + k]);
|
|
1030
|
+
});
|
|
568
1031
|
let previous;
|
|
569
1032
|
for (const row of rows) {
|
|
570
1033
|
const r = row.getBoundingClientRect();
|
|
571
1034
|
const header = row.parentElement?.localName === 'thead';
|
|
572
1035
|
if (previous) {
|
|
573
1036
|
// A break between rows, unless it would leave a header row at
|
|
574
|
-
// the foot of a page
|
|
1037
|
+
// the foot of a page or split a cell spanning rows; the spacing
|
|
1038
|
+
// between rows goes at a break.
|
|
575
1039
|
const before = previous.getBoundingClientRect();
|
|
576
1040
|
const pcs = getComputedStyle(previous);
|
|
577
1041
|
const rcs = getComputedStyle(row);
|
|
@@ -583,8 +1047,9 @@ class Builder {
|
|
|
583
1047
|
b.penalties.push(...this.conversion.inside(inside));
|
|
584
1048
|
if (previous.parentElement?.localName === 'thead')
|
|
585
1049
|
b.avoid = true;
|
|
586
|
-
this.items.push(penaltyOf(b) ?? { type: 'penalty', penalty: 0 });
|
|
587
|
-
|
|
1050
|
+
this.items.push(joined.has(row) ? { type: 'penalty', penalty: INFINITE_VPENALTY } : penaltyOf(b) ?? { type: 'penalty', penalty: 0 });
|
|
1051
|
+
// Less than a hundredth of a px is how Firefox rounds rows where they stand, not space.
|
|
1052
|
+
if (r.top - before.bottom > EPSILON)
|
|
588
1053
|
this.items.push({ type: 'glue', width: r.top - before.bottom, stretch: 0, shrink: 0 });
|
|
589
1054
|
}
|
|
590
1055
|
const rowContainers = row.parentElement && row.parentElement !== table ? [...inside, row.parentElement] : inside;
|
|
@@ -960,10 +1425,12 @@ function lineHeight(el, cs) {
|
|
|
960
1425
|
probe.remove();
|
|
961
1426
|
return h;
|
|
962
1427
|
}
|
|
963
|
-
/** GCPM's `float: footnote`, `top
|
|
964
|
-
function floatOf(cs) {
|
|
1428
|
+
/** GCPM's `float: footnote`, `top`, `bottom`, or a plugin-registered insert class, as lowered to `--pw-float`. */
|
|
1429
|
+
function floatOf(cs, custom) {
|
|
965
1430
|
const v = cs.getPropertyValue('--pw-float').trim();
|
|
966
|
-
|
|
1431
|
+
if (v === 'footnote' || v === 'top' || v === 'bottom')
|
|
1432
|
+
return v;
|
|
1433
|
+
return v && custom?.has(v) ? v : undefined;
|
|
967
1434
|
}
|
|
968
1435
|
/** GCPM's `position: running(name)`, as the compiler lowers it to `--pw-running: name`. */
|
|
969
1436
|
function runningOf(cs) {
|