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
|
@@ -30,19 +30,294 @@ export class PageBuilder {
|
|
|
30
30
|
classes = [];
|
|
31
31
|
marks = new Map();
|
|
32
32
|
number;
|
|
33
|
-
|
|
33
|
+
/**
|
|
34
|
+
* Breaks a lookahead search asked for, one per page fired: an ordinal
|
|
35
|
+
* from `probe`, or `greedy` for the break this builder would take.
|
|
36
|
+
* Absent, the builder is TeX's, and the fields below stay unused.
|
|
37
|
+
*/
|
|
38
|
+
plan;
|
|
39
|
+
planAt = 0;
|
|
40
|
+
/** Finite-cost breakpoints seen on the page being built. */
|
|
41
|
+
seen = 0;
|
|
42
|
+
/** Stop `build` before the next item: a probe that must fire, or one page of a search. */
|
|
43
|
+
halt = false;
|
|
44
|
+
stopAfterOne = false;
|
|
45
|
+
/** Set while `probe` walks a page: the breakpoints, filled in by `move`. */
|
|
46
|
+
recording;
|
|
47
|
+
/** The ordinal of the greedy builder's best finite-cost break, once one is seen. */
|
|
48
|
+
probeBest;
|
|
49
|
+
emergency;
|
|
50
|
+
/** Each item's place in the caller's list, for those given one; items given none, the caller's own, are `foreign`. */
|
|
51
|
+
index = new Map();
|
|
52
|
+
foreign = new Set();
|
|
53
|
+
/** The place after the last item given one; and the furthest place moved onto a page. */
|
|
54
|
+
end = 0;
|
|
55
|
+
furthest = -1;
|
|
56
|
+
/** Items the builder makes itself before an item still to come: from `resume`, put in when that item is given. */
|
|
57
|
+
before = new Map();
|
|
58
|
+
/** How far into the list each page looked: the furthest place moved onto a page when it was fired, −1 for none. */
|
|
59
|
+
looked = [];
|
|
60
|
+
/** The state after each page, by how many pages came before it (the first page's, 0, too), where the builder can start again. */
|
|
61
|
+
states = new Map();
|
|
62
|
+
/** Whether `opts.stop` stopped it. */
|
|
63
|
+
stopped = false;
|
|
64
|
+
/** The pages before the first of `pages`, when it was resumed. */
|
|
65
|
+
offset;
|
|
66
|
+
/** Goal height override during one `step()` call for a page template region. */
|
|
67
|
+
stepVsize;
|
|
68
|
+
constructor(opts, from) {
|
|
34
69
|
this.opts = opts;
|
|
35
70
|
this.unit = opts.unit ?? 1;
|
|
36
71
|
this.number = opts.firstPage ?? 1;
|
|
37
72
|
this.classNumbers = opts.classNumbers ?? { footnote: 254, top: 253, bottom: 252 };
|
|
73
|
+
this.offset = from?.pages ?? 0;
|
|
74
|
+
if (!from) {
|
|
75
|
+
this.states.set(0, { pages: 0, number: this.number, marks: new Map(), held: [], next: 0, made: [] });
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
this.number = from.number;
|
|
79
|
+
for (const [name, m] of from.marks)
|
|
80
|
+
this.marks.set(name, { ...m });
|
|
81
|
+
this.end = this.furthest = from.next;
|
|
82
|
+
this.furthest--;
|
|
83
|
+
for (const { before, item } of from.made)
|
|
84
|
+
this.before.set(before, [...(this.before.get(before) ?? []), item]);
|
|
85
|
+
this.contrib = from.held.map((h) => {
|
|
86
|
+
const node = { type: 'ins', insert: h.insert, list: [...h.list], height: h.height, continued: h.continued };
|
|
87
|
+
this.index.set(node, h.index);
|
|
88
|
+
return node;
|
|
89
|
+
}).reverse();
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Starts a build of a list from a state a build of the same list was in
|
|
93
|
+
* (`states`), whose items before `state.next` were the same: give it the
|
|
94
|
+
* list's items from `state.next` on. Its `pages` are those after the
|
|
95
|
+
* state's.
|
|
96
|
+
*/
|
|
97
|
+
static resume(opts, state) {
|
|
98
|
+
return new PageBuilder(opts, state);
|
|
38
99
|
}
|
|
39
|
-
/**
|
|
40
|
-
|
|
100
|
+
/**
|
|
101
|
+
* Adds items to the contribution list and builds what pages they fill.
|
|
102
|
+
* `from` is the first one's place in the caller's list, for an
|
|
103
|
+
* incremental build's states; items given without one are the caller's
|
|
104
|
+
* own, and no state is kept while one of them waits.
|
|
105
|
+
*/
|
|
106
|
+
contribute(items, from) {
|
|
107
|
+
if (this.stopped)
|
|
108
|
+
return;
|
|
109
|
+
this.hold(items, from);
|
|
110
|
+
this.build();
|
|
111
|
+
}
|
|
112
|
+
/** Queues items onto the contribution list without building pages yet, for stepping region by region. */
|
|
113
|
+
enqueue(items) {
|
|
41
114
|
const add = [];
|
|
42
115
|
for (const item of items)
|
|
43
116
|
add.push(item.type === 'insert' ? ins(item) : item);
|
|
44
117
|
this.contrib = [...add.reverse(), ...this.contrib];
|
|
45
|
-
|
|
118
|
+
}
|
|
119
|
+
/** Whether any box or insert remains to be placed on a page or in a region. */
|
|
120
|
+
hasMore() {
|
|
121
|
+
const live = (n) => n.type === 'box' || n.type === 'ins';
|
|
122
|
+
return this.page.some(live) || this.contrib.some(live);
|
|
123
|
+
}
|
|
124
|
+
/** The first non-null box waiting in the builder, for resolving a page's name before stepping. */
|
|
125
|
+
peekFirstBox() {
|
|
126
|
+
for (const p of this.page)
|
|
127
|
+
if (p.type === 'box' && p.kind !== 'null')
|
|
128
|
+
return p;
|
|
129
|
+
for (let k = this.contrib.length - 1; k >= 0; k--) {
|
|
130
|
+
const p = this.contrib[k];
|
|
131
|
+
if (p.type === 'box' && p.kind !== 'null')
|
|
132
|
+
return p;
|
|
133
|
+
}
|
|
134
|
+
return undefined;
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* The remaining items in order if no page is mid-build and no inserts are
|
|
138
|
+
* pending: used to check whether a flow's tail balances across a page's
|
|
139
|
+
* column regions.
|
|
140
|
+
*/
|
|
141
|
+
peekRemainingItems() {
|
|
142
|
+
if (this.page.length > 0)
|
|
143
|
+
return undefined;
|
|
144
|
+
const out = [];
|
|
145
|
+
for (let k = this.contrib.length - 1; k >= 0; k--) {
|
|
146
|
+
const p = this.contrib[k];
|
|
147
|
+
if (p.type === 'ins')
|
|
148
|
+
return undefined;
|
|
149
|
+
out.push(p);
|
|
150
|
+
}
|
|
151
|
+
return out;
|
|
152
|
+
}
|
|
153
|
+
/**
|
|
154
|
+
* Builds and returns a single region/page slice of height `vsize` from
|
|
155
|
+
* queued contributions, or `undefined` if nothing remains. Keeps inserts,
|
|
156
|
+
* marks and remaining items in this flow's state for the next region.
|
|
157
|
+
*/
|
|
158
|
+
step(vsize, pageNumber) {
|
|
159
|
+
if (!this.hasMore())
|
|
160
|
+
return undefined;
|
|
161
|
+
const before = this.pages.length;
|
|
162
|
+
this.stepVsize = vsize;
|
|
163
|
+
if (pageNumber !== undefined)
|
|
164
|
+
this.number = pageNumber;
|
|
165
|
+
try {
|
|
166
|
+
let guard = 0;
|
|
167
|
+
while (this.pages.length === before) {
|
|
168
|
+
if (++guard > 10000)
|
|
169
|
+
throw new Error('the page builder can’t finish: inserts held over for ever');
|
|
170
|
+
while (this.pages.length === before && this.contrib.length)
|
|
171
|
+
this.move(this.contrib.pop());
|
|
172
|
+
if (this.pages.length > before)
|
|
173
|
+
break;
|
|
174
|
+
if (!this.page.length)
|
|
175
|
+
break;
|
|
176
|
+
const flush = [
|
|
177
|
+
{ type: 'penalty', penalty: -0x40000000 },
|
|
178
|
+
{ type: 'glue', width: 0, stretch: 65536 / this.unit, shrink: 0, stretchOrder: 2 },
|
|
179
|
+
];
|
|
180
|
+
if (this.contents !== 'box')
|
|
181
|
+
flush.push({ type: 'box', kind: 'null', height: 0, depth: 0 });
|
|
182
|
+
this.contrib = flush;
|
|
183
|
+
}
|
|
184
|
+
return this.pages.length > before ? this.pages.at(-1) : undefined;
|
|
185
|
+
}
|
|
186
|
+
finally {
|
|
187
|
+
this.stepVsize = undefined;
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
/** Puts items on the contribution list without building them, `from` as `contribute` takes it. `contribute` is this, then a build. */
|
|
191
|
+
hold(items, from) {
|
|
192
|
+
const add = [];
|
|
193
|
+
let i = from;
|
|
194
|
+
for (const item of items) {
|
|
195
|
+
if (i !== undefined)
|
|
196
|
+
for (const made of this.before.get(i) ?? [])
|
|
197
|
+
add.push(made);
|
|
198
|
+
const node = item.type === 'insert' ? ins(item) : item;
|
|
199
|
+
add.push(node);
|
|
200
|
+
if (i === undefined)
|
|
201
|
+
this.foreign.add(node);
|
|
202
|
+
else {
|
|
203
|
+
this.index.set(node, i);
|
|
204
|
+
this.end = ++i;
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
this.contrib = [...add.reverse(), ...this.contrib];
|
|
208
|
+
}
|
|
209
|
+
/**
|
|
210
|
+
* Breaks the pages that follow where `plan` says, one entry per page
|
|
211
|
+
* fired: an ordinal `probe` reported, or `greedy` for the break this
|
|
212
|
+
* builder would take on its own. Pages after the plan run out are greedy.
|
|
213
|
+
* A blank page a sided break inserts is not an entry.
|
|
214
|
+
*/
|
|
215
|
+
follow(plan) {
|
|
216
|
+
this.plan = plan;
|
|
217
|
+
this.planAt = 0;
|
|
218
|
+
this.seen = 0;
|
|
219
|
+
}
|
|
220
|
+
/**
|
|
221
|
+
* The breakpoints the greedy builder would see on the current page, and
|
|
222
|
+
* which of them it would take, without firing the page or changing this
|
|
223
|
+
* builder. A page that runs out of legal breaks reports `emergency`.
|
|
224
|
+
*/
|
|
225
|
+
probe() {
|
|
226
|
+
const b = this.clone();
|
|
227
|
+
const recording = [];
|
|
228
|
+
b.recording = recording;
|
|
229
|
+
b.unread = b.contrib.length;
|
|
230
|
+
b.build();
|
|
231
|
+
const chosen = b.probeBest;
|
|
232
|
+
const emergency = b.emergency;
|
|
233
|
+
const breaks = recording.map((br) => ({ ...br, chosen: br.ordinal === chosen }));
|
|
234
|
+
const exhausted = b.ranOut || (!b.halt && !b.contrib.length);
|
|
235
|
+
return { breaks, ...(emergency ? { emergency } : {}), done: !b.halt && breaks.length === 0 && !emergency, exhausted, unread: b.unread };
|
|
236
|
+
}
|
|
237
|
+
/**
|
|
238
|
+
* A copy of this builder that has fired one page, at `choice`: an ordinal
|
|
239
|
+
* from `probe`, or `greedy` for the break the builder would take. The
|
|
240
|
+
* page is in the copy's `pages`; what follows is waiting. This builder
|
|
241
|
+
* is unchanged.
|
|
242
|
+
*/
|
|
243
|
+
splitAt(choice) {
|
|
244
|
+
const b = this.clone();
|
|
245
|
+
b.stopAfterOne = true;
|
|
246
|
+
if (typeof choice === 'number')
|
|
247
|
+
b.plan = [choice];
|
|
248
|
+
b.build();
|
|
249
|
+
return b;
|
|
250
|
+
}
|
|
251
|
+
/** The page about to be built, its number. */
|
|
252
|
+
pageNumber() {
|
|
253
|
+
return this.number;
|
|
254
|
+
}
|
|
255
|
+
/** How many items wait on the contribution list. */
|
|
256
|
+
waiting() {
|
|
257
|
+
return this.contrib.length;
|
|
258
|
+
}
|
|
259
|
+
/** How many pages it has fired on the plan it follows (`follow`), blank pages not among them. */
|
|
260
|
+
planned() {
|
|
261
|
+
return this.planAt;
|
|
262
|
+
}
|
|
263
|
+
/** Each mark's values so far, as the next page starts with them. */
|
|
264
|
+
markValues() {
|
|
265
|
+
return this.marks;
|
|
266
|
+
}
|
|
267
|
+
/**
|
|
268
|
+
* Where a builder given the list without places stands between two
|
|
269
|
+
* pages (a lookahead search's, which knows the places itself), as
|
|
270
|
+
* `states` has it: `place` gives an item's place in the list, none for
|
|
271
|
+
* what the builder made, and `end` is the place after the last item it
|
|
272
|
+
* was given. A held insert's `insert` is the list's. `pages` is not
|
|
273
|
+
* counted: 0.
|
|
274
|
+
*/
|
|
275
|
+
standing(place, end) {
|
|
276
|
+
if (this.page.length)
|
|
277
|
+
return undefined;
|
|
278
|
+
const held = [];
|
|
279
|
+
let k = this.contrib.length - 1;
|
|
280
|
+
for (; k >= 0; k--) {
|
|
281
|
+
const node = this.contrib[k];
|
|
282
|
+
if (node.type !== 'ins')
|
|
283
|
+
break;
|
|
284
|
+
const i = place(node.insert);
|
|
285
|
+
if (i === undefined)
|
|
286
|
+
return undefined;
|
|
287
|
+
held.push({ insert: node.insert, index: i, list: [...node.list], height: node.height, continued: node.continued });
|
|
288
|
+
}
|
|
289
|
+
const pending = [];
|
|
290
|
+
let next = end;
|
|
291
|
+
for (; k >= 0; k--) {
|
|
292
|
+
const node = this.contrib[k];
|
|
293
|
+
const i = node.type === 'ins' ? place(node.insert) : place(node);
|
|
294
|
+
if (i !== undefined) {
|
|
295
|
+
next = i;
|
|
296
|
+
break;
|
|
297
|
+
}
|
|
298
|
+
if (node.type === 'ins')
|
|
299
|
+
return undefined;
|
|
300
|
+
pending.push(node);
|
|
301
|
+
}
|
|
302
|
+
const marks = new Map();
|
|
303
|
+
for (const [name, m] of this.marks)
|
|
304
|
+
marks.set(name, { ...m });
|
|
305
|
+
return { pages: 0, number: this.number, marks, held, next, made: pending.map((item) => ({ before: next, item })) };
|
|
306
|
+
}
|
|
307
|
+
/**
|
|
308
|
+
* What is waiting to be built, the next item first. A held insert carries
|
|
309
|
+
* the part of it still to place, which a split changes.
|
|
310
|
+
*/
|
|
311
|
+
pending() {
|
|
312
|
+
const out = [];
|
|
313
|
+
for (let i = this.contrib.length - 1; i >= 0; i--) {
|
|
314
|
+
const n = this.contrib[i];
|
|
315
|
+
if (n.type === 'ins')
|
|
316
|
+
out.push({ item: n.insert, held: { height: n.height, continued: n.continued, length: n.list.length } });
|
|
317
|
+
else
|
|
318
|
+
out.push({ item: n });
|
|
319
|
+
}
|
|
320
|
+
return out;
|
|
46
321
|
}
|
|
47
322
|
/**
|
|
48
323
|
* The room left on the current page for the next box: TeX's `\pagegoal`
|
|
@@ -64,6 +339,11 @@ export class PageBuilder {
|
|
|
64
339
|
vsizeAfter(ahead) {
|
|
65
340
|
return this.opts.vsizeOf?.(this.number + ahead, undefined) ?? this.opts.vsize;
|
|
66
341
|
}
|
|
342
|
+
/** Notes that the caller's list has been given up to `end` (an item it gave as its own items, a multi-column box's rows). */
|
|
343
|
+
skip(end) {
|
|
344
|
+
if (end > this.end)
|
|
345
|
+
this.end = end;
|
|
346
|
+
}
|
|
67
347
|
/**
|
|
68
348
|
* Fires what is left, as TeX's `\end` does: while anything is on the page
|
|
69
349
|
* or waiting (held-over inserts), an empty box, `\vfill` and a forced
|
|
@@ -71,6 +351,11 @@ export class PageBuilder {
|
|
|
71
351
|
* at the top.
|
|
72
352
|
*/
|
|
73
353
|
finish() {
|
|
354
|
+
if (this.stopped)
|
|
355
|
+
return this.pages;
|
|
356
|
+
// A search stops a builder after one page; finishing means build the rest.
|
|
357
|
+
this.halt = false;
|
|
358
|
+
this.stopAfterOne = false;
|
|
74
359
|
this.build();
|
|
75
360
|
let guard = 0;
|
|
76
361
|
while (this.page.length || this.contrib.length) {
|
|
@@ -90,8 +375,15 @@ export class PageBuilder {
|
|
|
90
375
|
}
|
|
91
376
|
/** TeX's `build_page`: moves the contribution list onto the page until it is empty. */
|
|
92
377
|
build() {
|
|
93
|
-
while (this.contrib.length) {
|
|
378
|
+
while (this.contrib.length && !this.stopped) {
|
|
379
|
+
if (this.halt)
|
|
380
|
+
return;
|
|
94
381
|
const p = this.contrib.pop();
|
|
382
|
+
if (this.contrib.length < this.unread)
|
|
383
|
+
this.unread = this.contrib.length;
|
|
384
|
+
const i = this.index.get(p);
|
|
385
|
+
if (i !== undefined && i > this.furthest)
|
|
386
|
+
this.furthest = i;
|
|
95
387
|
this.move(p);
|
|
96
388
|
}
|
|
97
389
|
}
|
|
@@ -172,10 +464,8 @@ export class PageBuilder {
|
|
|
172
464
|
for (const r of this.classes)
|
|
173
465
|
r.bestIns = r.lastIns;
|
|
174
466
|
}
|
|
175
|
-
if (
|
|
176
|
-
this.fire(p);
|
|
467
|
+
if (this.atBreak(p, b, pi, c))
|
|
177
468
|
return;
|
|
178
|
-
}
|
|
179
469
|
}
|
|
180
470
|
if (p.type === 'glue') {
|
|
181
471
|
// §1004: the glue's width, stretch and shrink join the page's.
|
|
@@ -209,9 +499,10 @@ export class PageBuilder {
|
|
|
209
499
|
for (const [name, m] of this.marks)
|
|
210
500
|
marks.set(name, m.bot ? { top: m.bot, first: m.bot, bot: m.bot, all: [] } : { all: [] });
|
|
211
501
|
this.pages.push({
|
|
212
|
-
number: this.number++, blank: true, items: [], height: this.opts.vsize, depth: 0, glue: { sign: 'normal', order: 0, ratio: 0 }, overfull: 0,
|
|
502
|
+
number: this.number++, blank: true, items: [], height: this.stepVsize ?? this.opts.vsize, depth: 0, glue: { sign: 'normal', order: 0, ratio: 0 }, overfull: 0,
|
|
213
503
|
badness: 0, penalty: INFINITE_VPENALTY, inserts: {}, marks,
|
|
214
504
|
});
|
|
505
|
+
this.looked.push(this.furthest);
|
|
215
506
|
}
|
|
216
507
|
/** §987: the page's specifications are fixed when its first box or insert arrives. */
|
|
217
508
|
freeze(s, first) {
|
|
@@ -223,7 +514,7 @@ export class PageBuilder {
|
|
|
223
514
|
if (q.type === 'box')
|
|
224
515
|
box = q;
|
|
225
516
|
}
|
|
226
|
-
this.goal = this.opts.vsizeOf?.(this.number, box) ?? this.opts.vsize;
|
|
517
|
+
this.goal = this.stepVsize ?? this.opts.vsizeOf?.(this.number, box) ?? this.opts.vsize;
|
|
227
518
|
this.pageMaxDepth = this.opts.maxDepth;
|
|
228
519
|
this.depth = 0;
|
|
229
520
|
this.total = 0;
|
|
@@ -237,15 +528,23 @@ export class PageBuilder {
|
|
|
237
528
|
if (this.contents === 'empty')
|
|
238
529
|
this.freeze('inserts');
|
|
239
530
|
const params = this.opts.inserts[p.insert.class];
|
|
531
|
+
if (!params)
|
|
532
|
+
throw new Error(`unknown insert class ${JSON.stringify(p.insert.class)}`);
|
|
533
|
+
const takesMain = params.occupiesMain !== false;
|
|
240
534
|
let r = this.classes.find((c) => c.cls === p.insert.class);
|
|
241
535
|
if (!r) {
|
|
242
536
|
// §1009: the class's first insert on the page brings its \skip.
|
|
243
537
|
r = { cls: p.insert.class, split: false, height: 0 };
|
|
244
538
|
this.classes.push(r);
|
|
245
539
|
const q = params.skip;
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
540
|
+
if (takesMain) {
|
|
541
|
+
this.goal -= q.width;
|
|
542
|
+
this.stretch[q.stretchOrder ?? 0] += q.stretch;
|
|
543
|
+
this.shrink += q.shrink;
|
|
544
|
+
}
|
|
545
|
+
else {
|
|
546
|
+
r.height += q.width;
|
|
547
|
+
}
|
|
249
548
|
}
|
|
250
549
|
if (r.split) {
|
|
251
550
|
this.insertPenalties += params.floatingPenalty;
|
|
@@ -254,25 +553,31 @@ export class PageBuilder {
|
|
|
254
553
|
r.lastIns = p;
|
|
255
554
|
const delta = this.goal - this.total - this.depth + this.shrink;
|
|
256
555
|
const h = p.height;
|
|
257
|
-
|
|
258
|
-
|
|
556
|
+
const fitsMain = !takesMain || h <= 0 || h <= delta;
|
|
557
|
+
if (fitsMain && p.height + r.height <= params.maxHeight) {
|
|
558
|
+
if (takesMain)
|
|
559
|
+
this.goal -= h;
|
|
259
560
|
r.height += p.height;
|
|
260
561
|
return;
|
|
261
562
|
}
|
|
262
563
|
// §1010: the best way to split it.
|
|
263
|
-
const w =
|
|
564
|
+
const w = takesMain
|
|
565
|
+
? Math.min(this.goal - this.total - this.depth, params.maxHeight - r.height)
|
|
566
|
+
: params.maxHeight - r.height;
|
|
264
567
|
const split = vertBreak(p.list, w, params.splitMaxDepth, (t, s) => this.badness(t, s));
|
|
265
568
|
if (split.at === 0 && split.height === 0 && this.contents !== 'box') {
|
|
266
569
|
// Nothing would go on a page with no box yet: place it whole, overfull,
|
|
267
570
|
// rather than hold it for ever, leaving the text no room (a goal of 0)
|
|
268
571
|
// so it has the page to itself.
|
|
269
|
-
|
|
572
|
+
if (takesMain)
|
|
573
|
+
this.goal = Math.max(0, this.goal - h);
|
|
270
574
|
r.height += p.height;
|
|
271
575
|
return;
|
|
272
576
|
}
|
|
273
577
|
r.height += split.height;
|
|
274
|
-
this.opts.trace?.(`% split${this.classNumbers[p.insert.class]} to ${scaled(this.sp(w))},${scaled(this.sp(split.height))} p=${split.at === undefined ? EJECT_PENALTY : penaltyAt(p.list[split.at])}`);
|
|
275
|
-
|
|
578
|
+
this.opts.trace?.(`% split${this.classNumbers[p.insert.class] ?? 251} to ${scaled(this.sp(w))},${scaled(this.sp(split.height))} p=${split.at === undefined ? EJECT_PENALTY : penaltyAt(p.list[split.at])}`);
|
|
579
|
+
if (takesMain)
|
|
580
|
+
this.goal -= split.height;
|
|
276
581
|
r.split = true;
|
|
277
582
|
r.brokenIns = p;
|
|
278
583
|
r.brokenAt = split.at;
|
|
@@ -354,6 +659,7 @@ export class PageBuilder {
|
|
|
354
659
|
number: this.number++, blank: false, items, height: this.bestSize, depth: set.depth, glue: set.glue, overfull: set.overfull,
|
|
355
660
|
badness: this.bestBadness, penalty, inserts: placed, marks: this.pageMarks(own),
|
|
356
661
|
});
|
|
662
|
+
this.looked.push(this.furthest);
|
|
357
663
|
const rest = this.page.slice(best);
|
|
358
664
|
if (best === this.page.length)
|
|
359
665
|
this.contrib.push(c);
|
|
@@ -383,6 +689,193 @@ export class PageBuilder {
|
|
|
383
689
|
this.insertPenalties = 0;
|
|
384
690
|
this.best = undefined;
|
|
385
691
|
this.leastCost = AWFUL_BAD;
|
|
692
|
+
this.seen = 0;
|
|
693
|
+
if (this.plan)
|
|
694
|
+
this.planAt++;
|
|
695
|
+
if (this.stopAfterOne)
|
|
696
|
+
this.halt = true;
|
|
697
|
+
const state = this.state(held.length);
|
|
698
|
+
if (state) {
|
|
699
|
+
this.states.set(state.pages, state);
|
|
700
|
+
if (this.opts.stop?.(state))
|
|
701
|
+
this.stopped = true;
|
|
702
|
+
}
|
|
703
|
+
}
|
|
704
|
+
/**
|
|
705
|
+
* The greedy builder fires when the cost is awful or the break is forced.
|
|
706
|
+
* A search instead records the breakpoint (`recording`) or fires at the
|
|
707
|
+
* ordinal its plan names. Returns whether `p` was taken, so it must not
|
|
708
|
+
* also go onto the page.
|
|
709
|
+
*/
|
|
710
|
+
atBreak(p, b, pi, c) {
|
|
711
|
+
const must = c === AWFUL_BAD || pi <= EJECT_PENALTY;
|
|
712
|
+
if (this.recording) {
|
|
713
|
+
if (c < AWFUL_BAD) {
|
|
714
|
+
// The best update has already run: this node is the best exactly when it sits at the page's end.
|
|
715
|
+
if (this.best === this.page.length && this.leastCost === c)
|
|
716
|
+
this.probeBest = this.seen;
|
|
717
|
+
this.recording.push({ ordinal: this.seen, badness: b, penalty: pi, widow: this.opensWidow(p) });
|
|
718
|
+
this.seen++;
|
|
719
|
+
}
|
|
720
|
+
else if (this.best === this.page.length && this.leastCost === c) {
|
|
721
|
+
this.emergency = { badness: b, penalty: pi, widow: this.opensWidow(p) };
|
|
722
|
+
}
|
|
723
|
+
if (must) {
|
|
724
|
+
this.halt = true;
|
|
725
|
+
this.contrib.push(p);
|
|
726
|
+
return true;
|
|
727
|
+
}
|
|
728
|
+
return false;
|
|
729
|
+
}
|
|
730
|
+
const step = this.plan?.[this.planAt];
|
|
731
|
+
if (typeof step === 'number' && c < AWFUL_BAD) {
|
|
732
|
+
if (this.seen === step) {
|
|
733
|
+
this.best = this.page.length;
|
|
734
|
+
this.bestSize = this.goal;
|
|
735
|
+
this.bestBadness = b;
|
|
736
|
+
this.leastCost = c;
|
|
737
|
+
for (const r of this.classes)
|
|
738
|
+
r.bestIns = r.lastIns;
|
|
739
|
+
this.fire(p);
|
|
740
|
+
return true;
|
|
741
|
+
}
|
|
742
|
+
this.seen++;
|
|
743
|
+
}
|
|
744
|
+
if (must) {
|
|
745
|
+
this.fire(p);
|
|
746
|
+
return true;
|
|
747
|
+
}
|
|
748
|
+
return false;
|
|
749
|
+
}
|
|
750
|
+
/** Whether the page after `p` would open on a paragraph's last line. */
|
|
751
|
+
opensWidow(p) {
|
|
752
|
+
const widow = (n) => {
|
|
753
|
+
if (n.type === 'penalty' || n.type === 'glue' || n.type === 'mark' || n.type === 'ins')
|
|
754
|
+
return undefined;
|
|
755
|
+
if (n.type !== 'box' || n.kind === 'null' || n.kind === 'edge')
|
|
756
|
+
return undefined;
|
|
757
|
+
return n.kind === 'line' && n.line > 0 && n.line === n.paragraph.lines.length - 1;
|
|
758
|
+
};
|
|
759
|
+
const here = widow(p);
|
|
760
|
+
if (here !== undefined)
|
|
761
|
+
return here;
|
|
762
|
+
for (let i = this.contrib.length - 1; i >= 0; i--) {
|
|
763
|
+
if (i < this.unread)
|
|
764
|
+
this.unread = i;
|
|
765
|
+
const w = widow(this.contrib[i]);
|
|
766
|
+
if (w !== undefined)
|
|
767
|
+
return w;
|
|
768
|
+
}
|
|
769
|
+
this.ranOut = true;
|
|
770
|
+
return false;
|
|
771
|
+
}
|
|
772
|
+
/** Set when `opensWidow` read to the end of the contribution list, for `probe`. */
|
|
773
|
+
ranOut = false;
|
|
774
|
+
/** While `probe` builds: how many items at the contribution list’s end nothing has read. */
|
|
775
|
+
unread = 0;
|
|
776
|
+
/** A builder at this one's page, its own pages empty, ready to build again. Inserts are copies: a split must not change this one. */
|
|
777
|
+
clone() {
|
|
778
|
+
const b = new PageBuilder(this.opts);
|
|
779
|
+
b.number = this.number;
|
|
780
|
+
b.contents = this.contents;
|
|
781
|
+
b.goal = this.goal;
|
|
782
|
+
b.total = this.total;
|
|
783
|
+
b.depth = this.depth;
|
|
784
|
+
b.pageMaxDepth = this.pageMaxDepth;
|
|
785
|
+
b.stretch = [...this.stretch];
|
|
786
|
+
b.shrink = this.shrink;
|
|
787
|
+
b.insertPenalties = this.insertPenalties;
|
|
788
|
+
b.leastCost = this.leastCost;
|
|
789
|
+
b.best = this.best;
|
|
790
|
+
b.bestSize = this.bestSize;
|
|
791
|
+
b.bestBadness = this.bestBadness;
|
|
792
|
+
const map = new Map();
|
|
793
|
+
const copyIns = (p) => {
|
|
794
|
+
let c = map.get(p);
|
|
795
|
+
if (!c) {
|
|
796
|
+
c = { type: 'ins', insert: p.insert, list: [...p.list], height: p.height, continued: p.continued };
|
|
797
|
+
map.set(p, c);
|
|
798
|
+
}
|
|
799
|
+
return c;
|
|
800
|
+
};
|
|
801
|
+
const copy = (n) => (n.type === 'ins' ? copyIns(n) : n);
|
|
802
|
+
b.page = this.page.map(copy);
|
|
803
|
+
b.contrib = this.contrib.map(copy);
|
|
804
|
+
b.classes = this.classes.map((r) => {
|
|
805
|
+
const copyClass = { cls: r.cls, split: r.split, height: r.height };
|
|
806
|
+
if (r.brokenAt !== undefined)
|
|
807
|
+
copyClass.brokenAt = r.brokenAt;
|
|
808
|
+
if (r.lastIns)
|
|
809
|
+
copyClass.lastIns = copyIns(r.lastIns);
|
|
810
|
+
if (r.bestIns)
|
|
811
|
+
copyClass.bestIns = copyIns(r.bestIns);
|
|
812
|
+
if (r.brokenIns)
|
|
813
|
+
copyClass.brokenIns = copyIns(r.brokenIns);
|
|
814
|
+
return copyClass;
|
|
815
|
+
});
|
|
816
|
+
b.marks = new Map([...this.marks].map(([name, m]) => {
|
|
817
|
+
const copyMark = {};
|
|
818
|
+
if (m.top)
|
|
819
|
+
copyMark.top = m.top;
|
|
820
|
+
if (m.first)
|
|
821
|
+
copyMark.first = m.first;
|
|
822
|
+
if (m.bot)
|
|
823
|
+
copyMark.bot = m.bot;
|
|
824
|
+
return [name, copyMark];
|
|
825
|
+
}));
|
|
826
|
+
return b;
|
|
827
|
+
}
|
|
828
|
+
/**
|
|
829
|
+
* Where the builder stands, just after a page, if it can start again
|
|
830
|
+
* from there: the contribution list, read from its next item, is the
|
|
831
|
+
* held inserts, then the list's items in order from one place on, with
|
|
832
|
+
* only what the builder made itself among them.
|
|
833
|
+
*/
|
|
834
|
+
state(heldCount) {
|
|
835
|
+
if (!this.index.size)
|
|
836
|
+
return undefined;
|
|
837
|
+
const held = [];
|
|
838
|
+
const made = [];
|
|
839
|
+
let next;
|
|
840
|
+
let pending = [];
|
|
841
|
+
for (let k = this.contrib.length - 1; k >= 0; k--) {
|
|
842
|
+
const node = this.contrib[k];
|
|
843
|
+
if (this.foreign.has(node))
|
|
844
|
+
return undefined;
|
|
845
|
+
const i = this.index.get(node);
|
|
846
|
+
if (held.length < heldCount) {
|
|
847
|
+
if (node.type !== 'ins' || i === undefined)
|
|
848
|
+
return undefined;
|
|
849
|
+
held.push({ insert: node.insert, index: i, list: [...node.list], height: node.height, continued: node.continued });
|
|
850
|
+
continue;
|
|
851
|
+
}
|
|
852
|
+
if (i === undefined) {
|
|
853
|
+
pending.push(node);
|
|
854
|
+
continue;
|
|
855
|
+
}
|
|
856
|
+
next ??= i;
|
|
857
|
+
for (const item of pending)
|
|
858
|
+
made.push({ before: i, item });
|
|
859
|
+
pending = [];
|
|
860
|
+
}
|
|
861
|
+
const start = next ?? this.end;
|
|
862
|
+
for (const item of pending)
|
|
863
|
+
made.push({ before: this.end, item });
|
|
864
|
+
// The list's items in the contribution list must run on from `start` to `end`.
|
|
865
|
+
let expect = start;
|
|
866
|
+
for (let k = this.contrib.length - 1 - heldCount; k >= 0; k--) {
|
|
867
|
+
const i = this.index.get(this.contrib[k]);
|
|
868
|
+
if (i === undefined)
|
|
869
|
+
continue;
|
|
870
|
+
if (i !== expect++)
|
|
871
|
+
return undefined;
|
|
872
|
+
}
|
|
873
|
+
if (expect !== this.end)
|
|
874
|
+
return undefined;
|
|
875
|
+
const marks = new Map();
|
|
876
|
+
for (const [name, m] of this.marks)
|
|
877
|
+
marks.set(name, { ...m });
|
|
878
|
+
return { pages: this.offset + this.pages.length, number: this.number, marks, held, next: start, made };
|
|
386
879
|
}
|
|
387
880
|
pageMarks(own) {
|
|
388
881
|
const out = new Map();
|