pulpweaver4 0.0.88 → 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.d.ts +2 -1
- package/dist/ast/djot.js +31 -2
- 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 +72 -9
- package/dist/ast/nodes.js +8 -0
- 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/book.d.ts +2 -0
- package/dist/citations/book.js +17 -6
- package/dist/citations/book.js.map +1 -1
- package/dist/citations/collect.d.ts +5 -1
- package/dist/citations/collect.js +5 -1
- package/dist/citations/collect.js.map +1 -1
- 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/notes.js +54 -11
- package/dist/citations/notes.js.map +1 -1
- package/dist/citations/positions.js +4 -4
- package/dist/citations/positions.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/intents.d.ts +10 -0
- package/dist/colour/intents.js +10 -0
- package/dist/colour/intents.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 +99 -6
- package/dist/config/config.js +217 -6
- package/dist/config/config.js.map +1 -1
- package/dist/config/project-schema.d.ts +0 -8
- package/dist/config/project-schema.js +221 -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/processor.d.ts +3 -1
- package/dist/csl/processor.js +19 -13
- package/dist/csl/processor.js.map +1 -1
- package/dist/csl/project.d.ts +19 -4
- package/dist/csl/project.js +31 -11
- package/dist/csl/project.js.map +1 -1
- package/dist/djot/djot.js/src/ast.d.ts +4 -1
- package/dist/djot/djot.js/src/ast.js +8 -1
- package/dist/djot/djot.js/src/ast.js.map +1 -1
- package/dist/djot/djot.js/src/djot-renderer.js +3 -3
- package/dist/djot/djot.js/src/djot-renderer.js.map +1 -1
- package/dist/djot/djot.js/src/html.js +2 -1
- package/dist/djot/djot.js/src/html.js.map +1 -1
- package/dist/djot/djot.js/src/inline.d.ts +1 -1
- package/dist/djot/djot.js/src/inline.js +25 -12
- package/dist/djot/djot.js/src/inline.js.map +1 -1
- package/dist/djot/djot.js/src/pandoc.js +81 -11
- package/dist/djot/djot.js/src/pandoc.js.map +1 -1
- package/dist/djot/djot.js/src/parse.js +12 -3
- package/dist/djot/djot.js/src/parse.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 +34 -9
- 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-box.d.ts +2 -0
- package/dist/layout/page-box.js +6 -4
- package/dist/layout/page-box.js.map +1 -1
- package/dist/layout/page-rules.d.ts +8 -1
- package/dist/layout/page-rules.js +46 -2
- 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 +116 -3
- package/dist/layout/pages.js +1396 -162
- 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.d.ts +3 -1
- package/dist/lint/rules/source.js +9 -4
- 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 +378 -15
- 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 +37 -4
- 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 +426 -60
- 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 +132 -22
- 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 +26 -0
- package/dist/test/pipeline.js +4 -2
- 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 +128 -6
- 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/lint-rules/unused-entry.md +3 -1
- 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 +253 -2
- package/docs/reference/pulpweaver4-toml/index.md +57 -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/paragraph.js
CHANGED
|
@@ -47,6 +47,13 @@
|
|
|
47
47
|
* `\parshape` gives them (`ParagraphOptions.shape`): the lines beside a CSS
|
|
48
48
|
* float, each block placed at its indent.
|
|
49
49
|
*
|
|
50
|
+
* `--pw-protrusion` and `--pw-expansion` are off unless the paragraph sets
|
|
51
|
+
* them. Protrusion hangs the built-in punctuation into the margin (the
|
|
52
|
+
* line's measure grows by the hang, and the line's margin and width place
|
|
53
|
+
* it there). Expansion lets each line's glyphs widen or narrow within the
|
|
54
|
+
* limit, through a `wdth` axis when every face on the line has one and
|
|
55
|
+
* through `letter-spacing` otherwise, sharing the shortfall with the glue.
|
|
56
|
+
*
|
|
50
57
|
* With `--pw-line-breaking: browser` the lines are the browser's: it lays
|
|
51
58
|
* the paragraph out, its breaks are read back from where it puts each
|
|
52
59
|
* character (`browserLineStarts`), and the lines are set and written as the
|
|
@@ -59,8 +66,11 @@ import { hyphenMins } from '../hyphenation/hyphenator.js';
|
|
|
59
66
|
import { INFINITE_PENALTY, box, finishParagraph, hyphenationPoint, penalty, } from '../linebreak/items.js';
|
|
60
67
|
import { breakLines, setLines } from '../linebreak/knuth-plass.js';
|
|
61
68
|
import { appliedSpacing, fontStyleFromComputed } from '../measure/index.js';
|
|
69
|
+
import { bidiControls, resolveLevels } from '../measure/bidi.js';
|
|
62
70
|
import { calibrateSize } from './calibrate.js';
|
|
63
71
|
import { DEFAULT_WORD_SPACE, parseGlue, parseLength } from './glue.js';
|
|
72
|
+
import { release } from './ranges.js';
|
|
73
|
+
import { PROTRUSION_FACTORS, protrusionFactor } from './protrusion.js';
|
|
64
74
|
const SOFT_HYPHEN = '';
|
|
65
75
|
/** What stands for an atomic inline in a paragraph's text. */
|
|
66
76
|
export const OBJECT_REPLACEMENT = '\uFFFC';
|
|
@@ -96,7 +106,7 @@ export function layoutParagraph(el, opts) {
|
|
|
96
106
|
const justify = align.body === 'justify';
|
|
97
107
|
const skips = alignmentSkips(align, Number.parseFloat(pcs.fontSize));
|
|
98
108
|
const browser = pcs.getPropertyValue('--pw-line-breaking').trim() === 'browser';
|
|
99
|
-
const { segments, atoms, text, migrated: anchors } = collect(el, opts);
|
|
109
|
+
const { segments, atoms, text, levels, migrated: anchors } = collect(el, opts);
|
|
100
110
|
const atomAt = new Map(atoms.map((a) => [a.at, a]));
|
|
101
111
|
const segAt = (i) => segments.find((s) => i >= s.start && i < s.end) ?? segments.at(-1);
|
|
102
112
|
const widthOf = (a, b) => {
|
|
@@ -114,6 +124,58 @@ export function layoutParagraph(el, opts) {
|
|
|
114
124
|
const s = segAt(i);
|
|
115
125
|
return s.run.widthBetween(i, i + 1) - s.run.wordSpacing;
|
|
116
126
|
};
|
|
127
|
+
const params = parameters(pcs);
|
|
128
|
+
const protrusionScale = Number.parseFloat(pcs.getPropertyValue('--pw-protrusion'));
|
|
129
|
+
const scale = Number.isFinite(protrusionScale) ? protrusionScale : 0;
|
|
130
|
+
const expansionOn = (params.expansion ?? 0) > 0;
|
|
131
|
+
const factors = opts.protrusion ?? PROTRUSION_FACTORS;
|
|
132
|
+
/** How far the character at `offset` hangs, scaled. 0 when protrusion is off or the character isn't in the set. */
|
|
133
|
+
const hangAt = (offset, side) => {
|
|
134
|
+
if (!(scale > 0) || offset < 0 || offset >= text.length)
|
|
135
|
+
return 0;
|
|
136
|
+
const ch = text[offset];
|
|
137
|
+
const factor = protrusionFactor(ch, side, factors);
|
|
138
|
+
if (!factor)
|
|
139
|
+
return 0;
|
|
140
|
+
const seg = segAt(offset);
|
|
141
|
+
if (offset < seg.start || offset >= seg.end)
|
|
142
|
+
return 0;
|
|
143
|
+
return seg.run.widthBetween(offset, offset + 1) * factor * scale;
|
|
144
|
+
};
|
|
145
|
+
/** A text box. With protrusion and expansion off it is `box(width)`, as the fixtures' boxes are. */
|
|
146
|
+
const textBox = (from, end) => {
|
|
147
|
+
const width = widthOf(from, end);
|
|
148
|
+
if ((!(scale > 0) && !expansionOn) || end <= from)
|
|
149
|
+
return box(width);
|
|
150
|
+
return box(width, {
|
|
151
|
+
leftHang: hangAt(from, 'left'),
|
|
152
|
+
rightHang: hangAt(end - 1, 'right'),
|
|
153
|
+
expand: expansionOn ? width : 0,
|
|
154
|
+
});
|
|
155
|
+
};
|
|
156
|
+
/**
|
|
157
|
+
* A break in a word, and the box before it. An inserted hyphen (`-`)
|
|
158
|
+
* hangs and expands by its own advance; a break with no hyphen (an
|
|
159
|
+
* explicit hyphen, a URL) leaves that to the box, whose last glyph is
|
|
160
|
+
* the character at the edge.
|
|
161
|
+
*/
|
|
162
|
+
const pushBreak = (from, at, wordStart, wordEndAt, hyphen, pen, auto = false) => {
|
|
163
|
+
push(textBox(from, at), { kind: 'box', start: from, end: at });
|
|
164
|
+
const seg = segAt(Math.max(0, at - 1));
|
|
165
|
+
const width = breakWidth(measurer, seg, text.slice(wordStart, wordEndAt), at - wordStart, hyphen);
|
|
166
|
+
const base = auto ? hyphenationPoint(width, pen) : penalty(pen, width, true);
|
|
167
|
+
if (hyphen !== '-' || (!(scale > 0) && !expansionOn)) {
|
|
168
|
+
push(base, { kind: 'break', at, hyphen, ...(auto ? { auto: true } : {}) });
|
|
169
|
+
return;
|
|
170
|
+
}
|
|
171
|
+
const advance = measurer.shape(seg.font, '-', seg.style).width;
|
|
172
|
+
const right = scale > 0 ? advance * protrusionFactor('-', 'right', factors) * scale : 0;
|
|
173
|
+
push({
|
|
174
|
+
...base,
|
|
175
|
+
...(right ? { rightHang: right } : {}),
|
|
176
|
+
...(expansionOn ? { expand: advance } : {}),
|
|
177
|
+
}, { kind: 'break', at, hyphen, ...(auto ? { auto: true } : {}) });
|
|
178
|
+
};
|
|
117
179
|
// The list: a box per word fragment, glue per space, penalties where a
|
|
118
180
|
// word may break.
|
|
119
181
|
const items = [];
|
|
@@ -187,8 +249,7 @@ export function layoutParagraph(el, opts) {
|
|
|
187
249
|
// soft and explicit hyphens.
|
|
188
250
|
let from = i;
|
|
189
251
|
for (const at of autoPoints(i, end)) {
|
|
190
|
-
|
|
191
|
-
push(hyphenationPoint(breakWidth(measurer, segAt(at - 1), text.slice(i, end), at - i, '-'), hyphenPenalty), { kind: 'break', at, hyphen: '-', auto: true });
|
|
252
|
+
pushBreak(from, at, i, end, '-', hyphenPenalty, true);
|
|
192
253
|
from = at;
|
|
193
254
|
}
|
|
194
255
|
const url = URL_START.test(text.slice(i, end));
|
|
@@ -196,26 +257,19 @@ export function layoutParagraph(el, opts) {
|
|
|
196
257
|
const c = text[j];
|
|
197
258
|
if (url && j > from && urlBreakBefore(text, j, end)) {
|
|
198
259
|
// A URL may break before a slash or a full stop, as Chicago breaks one (14.18), with no hyphen added.
|
|
199
|
-
|
|
200
|
-
push(penalty(exHyphenPenalty, breakWidth(measurer, segAt(j - 1), text.slice(i, end), j - i, ''), true), { kind: 'break', at: j, hyphen: '' });
|
|
260
|
+
pushBreak(from, j, i, end, '', exHyphenPenalty);
|
|
201
261
|
from = j;
|
|
202
262
|
}
|
|
203
263
|
if (c === SOFT_HYPHEN && hyphensOf(segAt(j).computed) === 'none')
|
|
204
264
|
continue;
|
|
205
265
|
if (c === SOFT_HYPHEN || (EXPLICIT_HYPHENS.test(c) && j > i && j + 1 < end)) {
|
|
206
266
|
const after = j + 1;
|
|
207
|
-
|
|
208
|
-
if (c === SOFT_HYPHEN) {
|
|
209
|
-
push(penalty(hyphenPenalty, breakWidth(measurer, segAt(j), text.slice(i, end), after - i, '-'), true), { kind: 'break', at: after, hyphen: '-' });
|
|
210
|
-
}
|
|
211
|
-
else {
|
|
212
|
-
push(penalty(exHyphenPenalty, breakWidth(measurer, segAt(j), text.slice(i, end), after - i, ''), true), { kind: 'break', at: after, hyphen: '' });
|
|
213
|
-
}
|
|
267
|
+
pushBreak(from, after, i, end, c === SOFT_HYPHEN ? '-' : '', c === SOFT_HYPHEN ? hyphenPenalty : exHyphenPenalty);
|
|
214
268
|
from = after;
|
|
215
269
|
}
|
|
216
270
|
}
|
|
217
271
|
if (from < end)
|
|
218
|
-
push(
|
|
272
|
+
push(textBox(from, end), { kind: 'box', start: from, end });
|
|
219
273
|
i = end;
|
|
220
274
|
}
|
|
221
275
|
// The browser's lines break where it started a new one: at the glue or
|
|
@@ -240,14 +294,14 @@ export function layoutParagraph(el, opts) {
|
|
|
240
294
|
if (at === start && from[k - 1]?.kind === 'leader')
|
|
241
295
|
continue;
|
|
242
296
|
if (at > start)
|
|
243
|
-
push(
|
|
297
|
+
push(textBox(start, at), { kind: 'box', start, end: at });
|
|
244
298
|
// What the cut changes in a word's width is left out: a break the list didn't have is rare.
|
|
245
299
|
if (at > start || items.at(-1)?.type === 'box')
|
|
246
300
|
push(penalty(0), { kind: 'break', at, hyphen: '' });
|
|
247
301
|
chosen.push(items.length - 1);
|
|
248
302
|
start = at;
|
|
249
303
|
}
|
|
250
|
-
push(start === o.start ? item :
|
|
304
|
+
push(start === o.start ? item : textBox(start, o.end), { kind: 'box', start, end: o.end });
|
|
251
305
|
}
|
|
252
306
|
}
|
|
253
307
|
const finished = finishParagraph(items, skips.parFillSkip);
|
|
@@ -255,8 +309,8 @@ export function layoutParagraph(el, opts) {
|
|
|
255
309
|
origins.pop();
|
|
256
310
|
origins.push({ kind: 'end' }, { kind: 'end' }, { kind: 'end' });
|
|
257
311
|
const breaks = lineStarts
|
|
258
|
-
? setLines(finished, chosen, { measure, leftSkip: skips.start, rightSkip: skips.end })
|
|
259
|
-
: (opts.lineBreaker?.(el) ?? breakLines)(finished, { measure, ...
|
|
312
|
+
? setLines(finished, chosen, { measure, ...params, leftSkip: skips.start, rightSkip: skips.end })
|
|
313
|
+
: (opts.lineBreaker?.(el) ?? breakLines)(finished, { measure, ...params, leftSkip: skips.start, rightSkip: skips.end });
|
|
260
314
|
/** Whether line `n` fills its measure: a justified line, not left at its natural width. */
|
|
261
315
|
const fills = (n) => justify && breaks.lines[n].glueOrder === 0;
|
|
262
316
|
// Each leader as wide as its line set its glue: what the line's widths below count it as.
|
|
@@ -294,8 +348,9 @@ export function layoutParagraph(el, opts) {
|
|
|
294
348
|
let w = 0;
|
|
295
349
|
const parts = segments.filter((s) => s.end > a && s.start < b);
|
|
296
350
|
for (const [i, s] of parts.entries()) {
|
|
297
|
-
const
|
|
298
|
-
|
|
351
|
+
const [from, to] = [Math.max(a, s.start), Math.min(b, s.end)];
|
|
352
|
+
const t = text.slice(from, to) + (i === parts.length - 1 ? hyphen : '');
|
|
353
|
+
w += ceil(measurer.shape(s.font, t, { ...s.style, wordSpacingPx: common }, { levels: levels.subarray(from, to) }).width);
|
|
299
354
|
}
|
|
300
355
|
for (const atom of atoms)
|
|
301
356
|
if (atom.at >= a && atom.at < b)
|
|
@@ -367,8 +422,70 @@ export function layoutParagraph(el, opts) {
|
|
|
367
422
|
// and what cutting the word there changes.
|
|
368
423
|
const brokenAt = finished[line.end];
|
|
369
424
|
const breakAdds = brk.kind === 'break' && brokenAt.type === 'penalty' ? brokenAt.width : 0;
|
|
370
|
-
lines.push({ start, end, hyphen, auto: !!hyphen && brk.kind === 'break' && !!brk.auto, spacing, sentences, width: breakAdds });
|
|
425
|
+
lines.push({ start, end, hyphen, auto: !!hyphen && brk.kind === 'break' && !!brk.auto, spacing, sentences, width: breakAdds, tracking: 0, wdth: 0 });
|
|
371
426
|
}
|
|
427
|
+
const graphemes = new Intl.Segmenter(undefined, { granularity: 'grapheme' });
|
|
428
|
+
/** `wdth` when every face on the line has the axis; otherwise tracking. A mixed line is not expanded both ways. */
|
|
429
|
+
const expansionStyle = (n) => {
|
|
430
|
+
const br = breaks.lines[n];
|
|
431
|
+
if (br.expansion === 0)
|
|
432
|
+
return undefined;
|
|
433
|
+
const l = lines[n];
|
|
434
|
+
const parts = segments.filter((s) => s.end > l.start && s.start < l.end);
|
|
435
|
+
if (parts.length > 0 && parts.every((s) => 'wdth' in s.font.axes))
|
|
436
|
+
return { tracking: 0, wdth: 100 * (1 + br.expansion) };
|
|
437
|
+
let expandable = 0;
|
|
438
|
+
for (let k = br.start; k < br.end; k++) {
|
|
439
|
+
const item = finished[k];
|
|
440
|
+
if (item?.type === 'box')
|
|
441
|
+
expandable += item.expand ?? 0;
|
|
442
|
+
}
|
|
443
|
+
const atBreak = finished[br.end];
|
|
444
|
+
if (atBreak?.type === 'penalty')
|
|
445
|
+
expandable += atBreak.expand ?? 0;
|
|
446
|
+
// Letter-spacing also falls on each space, and that part is taken back
|
|
447
|
+
// off the glue, so only the glyphs (and an inserted hyphen) carry the
|
|
448
|
+
// fraction. Counting the spaces would under-expand the glyphs.
|
|
449
|
+
let glyphs = 0;
|
|
450
|
+
for (const { segment } of graphemes.segment(text.slice(l.start, l.end) + l.hyphen)) {
|
|
451
|
+
if (!/^\s$/u.test(segment))
|
|
452
|
+
glyphs++;
|
|
453
|
+
}
|
|
454
|
+
return { tracking: glyphs > 0 ? (br.expansion * expandable) / glyphs : 0, wdth: 0 };
|
|
455
|
+
};
|
|
456
|
+
const styleFor = (seg, exp) => {
|
|
457
|
+
let wdth = exp.wdth;
|
|
458
|
+
if (wdth) {
|
|
459
|
+
const axis = seg.font.axes.wdth;
|
|
460
|
+
if (axis)
|
|
461
|
+
wdth = Math.min(axis.max, Math.max(axis.min, wdth));
|
|
462
|
+
}
|
|
463
|
+
return {
|
|
464
|
+
...seg.style,
|
|
465
|
+
letterSpacingPx: seg.style.letterSpacingPx + exp.tracking,
|
|
466
|
+
wordSpacingPx: 0,
|
|
467
|
+
features: exp.tracking !== 0 ? { ...seg.style.features, liga: 0, clig: 0, dlig: 0, hlig: 0, calt: 0 } : seg.style.features,
|
|
468
|
+
variations: wdth ? { ...seg.style.variations, wdth } : seg.style.variations,
|
|
469
|
+
};
|
|
470
|
+
};
|
|
471
|
+
/** The line as the browser will lay it out at `exp`, word-spacing included, indent included. */
|
|
472
|
+
const measuredExpanded = (l, n, exp) => {
|
|
473
|
+
let w = n === 0 ? indent : 0;
|
|
474
|
+
const parts = segments.filter((s) => s.end > l.start && s.start < l.end);
|
|
475
|
+
for (const [i, s] of parts.entries()) {
|
|
476
|
+
const from = Math.max(l.start, s.start);
|
|
477
|
+
const to = Math.min(l.end, s.end);
|
|
478
|
+
const t = text.slice(from, to) + (i === parts.length - 1 ? l.hyphen : '');
|
|
479
|
+
if (t)
|
|
480
|
+
w += measurer.shape(s.font, t, styleFor(s, exp), { levels: levels.subarray(from, to) }).width;
|
|
481
|
+
}
|
|
482
|
+
for (const atom of atoms)
|
|
483
|
+
if (atom.at >= l.start && atom.at < l.end)
|
|
484
|
+
w += atom.width;
|
|
485
|
+
for (const ws of l.spacing.values())
|
|
486
|
+
w += ws;
|
|
487
|
+
return w;
|
|
488
|
+
};
|
|
372
489
|
// Chromium shapes across a space only within one element, so a span
|
|
373
490
|
// around a space would lose its kerning (fonts kern against the space):
|
|
374
491
|
// a line's word spaces share one word-spacing there, which keeps their
|
|
@@ -389,8 +506,48 @@ export function layoutParagraph(el, opts) {
|
|
|
389
506
|
}
|
|
390
507
|
for (const [n, l] of lines.entries()) {
|
|
391
508
|
const brLine = breaks.lines[n];
|
|
509
|
+
// A filling line's target includes the hangs the breaker added to the
|
|
510
|
+
// measure. With hangs of 0 it is the measure, as before.
|
|
511
|
+
const hangTarget = brLine.measure + (fills(n) ? brLine.leftHang + brLine.rightHang : 0);
|
|
512
|
+
const exp = expansionStyle(n);
|
|
513
|
+
if (exp) {
|
|
514
|
+
// The line's letter-spacing replaces what it inherited, so a paragraph
|
|
515
|
+
// that already tracks (a small-caps line) keeps that and gains the expansion.
|
|
516
|
+
const base = exp.tracking ? (Number.parseFloat(pcs.letterSpacing) || 0) : 0;
|
|
517
|
+
l.tracking = exp.tracking ? base + exp.tracking : 0;
|
|
518
|
+
l.wdth = exp.wdth;
|
|
519
|
+
// letter-spacing also falls on each space; take it back off the glue.
|
|
520
|
+
if (exp.tracking) {
|
|
521
|
+
for (const [at, ws] of l.spacing)
|
|
522
|
+
l.spacing.set(at, appliedSpacing(model, ws - exp.tracking));
|
|
523
|
+
}
|
|
524
|
+
let natural = measuredExpanded(l, n, exp);
|
|
525
|
+
const justified = fills(n) && l.spacing.size > 0;
|
|
526
|
+
if (justified) {
|
|
527
|
+
if (unit) {
|
|
528
|
+
let units = Math.round((hangTarget - natural) / unit);
|
|
529
|
+
const spaces = [...l.spacing.keys()];
|
|
530
|
+
for (let s = 0; units !== 0 && s < spaces.length * 4; s++) {
|
|
531
|
+
const at = spaces[s % spaces.length];
|
|
532
|
+
const step = Math.sign(units) * unit;
|
|
533
|
+
l.spacing.set(at, l.spacing.get(at) + step);
|
|
534
|
+
natural += step;
|
|
535
|
+
units -= Math.sign(units);
|
|
536
|
+
}
|
|
537
|
+
}
|
|
538
|
+
else {
|
|
539
|
+
const words = [...l.spacing.keys()];
|
|
540
|
+
const share = (hangTarget - natural) / words.length;
|
|
541
|
+
for (const at of words)
|
|
542
|
+
l.spacing.set(at, l.spacing.get(at) + share);
|
|
543
|
+
natural = hangTarget;
|
|
544
|
+
}
|
|
545
|
+
}
|
|
546
|
+
l.width = natural;
|
|
547
|
+
continue;
|
|
548
|
+
}
|
|
392
549
|
if (!unit && l.sentences.size) {
|
|
393
|
-
l.width = setSentenceSpaces(l, n === 0 ? indent : 0, fills(n) ?
|
|
550
|
+
l.width = setSentenceSpaces(l, n === 0 ? indent : 0, fills(n) ? hangTarget : undefined);
|
|
394
551
|
continue;
|
|
395
552
|
}
|
|
396
553
|
let natural = l.width;
|
|
@@ -405,7 +562,7 @@ export function layoutParagraph(el, opts) {
|
|
|
405
562
|
natural += widthOf(k, l.end) + (n === 0 ? indent : 0);
|
|
406
563
|
const justified = fills(n) && l.spacing.size > 0;
|
|
407
564
|
if (unit && justified) {
|
|
408
|
-
let units = Math.round((
|
|
565
|
+
let units = Math.round((hangTarget - natural) / unit);
|
|
409
566
|
const spaces = [...l.spacing.keys()];
|
|
410
567
|
for (let s = 0; units !== 0 && s < spaces.length * 4; s++) {
|
|
411
568
|
const at = spaces[s % spaces.length];
|
|
@@ -426,7 +583,12 @@ export function layoutParagraph(el, opts) {
|
|
|
426
583
|
return v;
|
|
427
584
|
return undefined;
|
|
428
585
|
});
|
|
429
|
-
const { elements, hyphens } = render(el, segments, atoms, lines.map((l) => ({
|
|
586
|
+
const { elements, hyphens } = render(el, segments, atoms, lines.map((l, n) => ({
|
|
587
|
+
start: l.start, end: l.end, hyphen: l.hyphen,
|
|
588
|
+
leftHang: breaks.lines[n].leftHang,
|
|
589
|
+
rightHang: fills(n) ? breaks.lines[n].rightHang : 0,
|
|
590
|
+
tracking: l.tracking, wdth: l.wdth,
|
|
591
|
+
})), lines.map((l) => l.spacing), commons, lineShape, indent);
|
|
430
592
|
setLeaders(el, pcs, [...leaderLines.keys()]);
|
|
431
593
|
// Firefox's model leaves a few advances rounded the other way (#4's
|
|
432
594
|
// unmodelled cases), so each justified line is read back once and its
|
|
@@ -442,10 +604,50 @@ export function layoutParagraph(el, opts) {
|
|
|
442
604
|
l.width = width;
|
|
443
605
|
continue;
|
|
444
606
|
}
|
|
445
|
-
const units = Math.round((brLine.measure - width) / unit);
|
|
607
|
+
const units = Math.round((brLine.measure + brLine.leftHang + brLine.rightHang - width) / unit);
|
|
446
608
|
l.width = width + (units ? spreadUnits(line, units, unit) : 0);
|
|
447
609
|
}
|
|
448
610
|
}
|
|
611
|
+
else {
|
|
612
|
+
// Chromium's advances match the measurer, except a `wdth` axis, which
|
|
613
|
+
// is not linear in the percentage, and it lays out each run of text
|
|
614
|
+
// between element boundaries (a code span, an emphasis) at its width
|
|
615
|
+
// rounded up to its 1/64 px layout unit, so a line of several runs ends
|
|
616
|
+
// a unit or more past the sum of their advances (#159). Such a line, or
|
|
617
|
+
// an expanded one, is read back once and the difference put on its
|
|
618
|
+
// spaces, so it ends where it was set; left at its natural width, it
|
|
619
|
+
// ends where the browser put it.
|
|
620
|
+
for (const [n, l] of lines.entries()) {
|
|
621
|
+
const brLine = breaks.lines[n];
|
|
622
|
+
const runs = segments.filter((s) => s.end > l.start && s.start < l.end).length +
|
|
623
|
+
atoms.filter((a) => a.at >= l.start && a.at < l.end).length;
|
|
624
|
+
if (brLine.expansion === 0 && (runs < 2 || l.sentences.size))
|
|
625
|
+
continue;
|
|
626
|
+
const line = elements[n];
|
|
627
|
+
if (!fills(n) || !l.spacing.size) {
|
|
628
|
+
if (brLine.expansion === 0)
|
|
629
|
+
l.width = textWidth(line) + (n === 0 ? indent : 0);
|
|
630
|
+
continue;
|
|
631
|
+
}
|
|
632
|
+
const target = brLine.measure + brLine.leftHang + brLine.rightHang;
|
|
633
|
+
// Each run's rounding moves with the spacing, so a correction can land
|
|
634
|
+
// a unit or two off again: a few rounds settle it.
|
|
635
|
+
for (let round = 0; round < 3; round++) {
|
|
636
|
+
const drift = target - (textWidth(line) + (n === 0 ? indent : 0));
|
|
637
|
+
if (Math.abs(drift) < 1 / 128)
|
|
638
|
+
break;
|
|
639
|
+
const share = drift / l.spacing.size;
|
|
640
|
+
line.style.wordSpacing = `${(Number.parseFloat(line.style.wordSpacing) || 0) + share}px`;
|
|
641
|
+
for (const span of line.querySelectorAll('.pw-space')) {
|
|
642
|
+
// A space with no spacing of its own inherits the line's.
|
|
643
|
+
if (span.closest('.pw-break') || !span.style.wordSpacing)
|
|
644
|
+
continue;
|
|
645
|
+
span.style.wordSpacing = `${(Number.parseFloat(span.style.wordSpacing) || 0) + share}px`;
|
|
646
|
+
}
|
|
647
|
+
}
|
|
648
|
+
l.width = target;
|
|
649
|
+
}
|
|
650
|
+
}
|
|
449
651
|
// Each line not filling its measure is placed in it as the skips at its
|
|
450
652
|
// ends would set it (the last line by `text-align-last`): its share of
|
|
451
653
|
// the room left goes before its text as padding, so the line's block stays
|
|
@@ -585,6 +787,7 @@ function browserLineStarts(text, segments, atoms, points) {
|
|
|
585
787
|
see(offset, rect);
|
|
586
788
|
}
|
|
587
789
|
}
|
|
790
|
+
release(range);
|
|
588
791
|
// A line starts after the space that ends the last, wherever the browser puts that.
|
|
589
792
|
return [...new Set(starts.map((at) => (text[at] === ' ' ? at + 1 : at)))].filter((at) => at < text.length);
|
|
590
793
|
}
|
|
@@ -676,6 +879,10 @@ function parameters(cs) {
|
|
|
676
879
|
const es = cs.getPropertyValue('--pw-emergency-stretch').trim();
|
|
677
880
|
if (es)
|
|
678
881
|
out.emergencyStretch = parseLength(es, fontSize);
|
|
882
|
+
// Per-mille, as `\pdffontexpand`'s limit: 20 is 2% either way. The breaker takes the fraction.
|
|
883
|
+
const expansion = cs.getPropertyValue('--pw-expansion').trim();
|
|
884
|
+
if (expansion)
|
|
885
|
+
out.expansion = Number.parseInt(expansion, 10) / 1000;
|
|
679
886
|
return out;
|
|
680
887
|
}
|
|
681
888
|
/**
|
|
@@ -777,6 +984,7 @@ function setLeaders(paragraph, pcs, atoms) {
|
|
|
777
984
|
el.style.paddingInlineStart = `${first * leader.box - x + leader.space}px`;
|
|
778
985
|
el.style.wordSpacing = `${leader.box - leader.textWidth - leader.spaceWidth}px`;
|
|
779
986
|
el.textContent = Array.from({ length: count }, () => leader.text).join(' ');
|
|
987
|
+
el.dataset.pwGenerated = 'leader';
|
|
780
988
|
}
|
|
781
989
|
}
|
|
782
990
|
/**
|
|
@@ -848,9 +1056,19 @@ function collect(el, opts) {
|
|
|
848
1056
|
piece.data = piece.data.trimEnd();
|
|
849
1057
|
}
|
|
850
1058
|
const text = pieces.map((p) => (p instanceof Text ? p.data : OBJECT_REPLACEMENT)).join('');
|
|
1059
|
+
const levels = paragraphLevels(el, pieces, text);
|
|
851
1060
|
const segments = [];
|
|
852
1061
|
const atoms = [];
|
|
853
1062
|
const starts = [];
|
|
1063
|
+
// An element's text nodes are one run to the browser, set at one size, so
|
|
1064
|
+
// its size is calibrated on all of them: a node alone may be a word too
|
|
1065
|
+
// short to tell the sizes apart, or a lone space (Djot's soft break),
|
|
1066
|
+
// which falls back to a sample the font may not have (#158).
|
|
1067
|
+
const samples = new Map();
|
|
1068
|
+
for (const piece of pieces) {
|
|
1069
|
+
if (piece instanceof Text && piece.parentElement)
|
|
1070
|
+
samples.set(piece.parentElement, (samples.get(piece.parentElement) ?? '') + piece.data);
|
|
1071
|
+
}
|
|
854
1072
|
let offset = 0;
|
|
855
1073
|
for (const piece of pieces) {
|
|
856
1074
|
const start = offset;
|
|
@@ -876,8 +1094,8 @@ function collect(el, opts) {
|
|
|
876
1094
|
if (!font)
|
|
877
1095
|
throw new Error(`no font registered for font-family ${computed.fontFamily}`);
|
|
878
1096
|
const style = fontStyleFromComputed(computed, element.closest('[lang]')?.getAttribute('lang') ?? '');
|
|
879
|
-
style.setSizePx = calibrateSize(fonts.measurer, element, font, style,
|
|
880
|
-
const run = fonts.measurer.shape(font, text, style, { start, end: offset });
|
|
1097
|
+
style.setSizePx = calibrateSize(fonts.measurer, element, font, style, samples.get(element));
|
|
1098
|
+
const run = fonts.measurer.shape(font, text, style, { start, end: offset, levels });
|
|
881
1099
|
segments.push({ node: piece, start, end: offset, style, font, run, element, computed });
|
|
882
1100
|
}
|
|
883
1101
|
starts.push(offset);
|
|
@@ -886,7 +1104,45 @@ function collect(el, opts) {
|
|
|
886
1104
|
if (!segments.length)
|
|
887
1105
|
throw new Error('a paragraph of atomic inlines alone: it needs text, for its font');
|
|
888
1106
|
const migrated = anchors.map((a) => ({ element: a.element, offset: starts[a.piece], removed: a.removed }));
|
|
889
|
-
return { segments, atoms, text, migrated };
|
|
1107
|
+
return { segments, atoms, text, levels, migrated };
|
|
1108
|
+
}
|
|
1109
|
+
/**
|
|
1110
|
+
* The bidi level of each of the paragraph's code units, resolved over the
|
|
1111
|
+
* whole paragraph in its direction, as browsers do: each inline element
|
|
1112
|
+
* between a piece and the paragraph is the embedding, isolate or override
|
|
1113
|
+
* its `direction` and `unicode-bidi` make it (a `bdi`, a `dir` attribute),
|
|
1114
|
+
* and an atomic inline is a neutral (#194).
|
|
1115
|
+
*/
|
|
1116
|
+
function paragraphLevels(el, pieces, text) {
|
|
1117
|
+
const pcs = getComputedStyle(el);
|
|
1118
|
+
const base = pcs.unicodeBidi === 'plaintext' ? 'auto' : pcs.direction === 'rtl' ? 'rtl' : 'ltr';
|
|
1119
|
+
const marks = [];
|
|
1120
|
+
const open = [];
|
|
1121
|
+
let offset = 0;
|
|
1122
|
+
for (const piece of pieces) {
|
|
1123
|
+
const length = piece instanceof Text ? piece.data.length : 1;
|
|
1124
|
+
const chain = [];
|
|
1125
|
+
for (let e = piece.parentElement; e && e !== el; e = e.parentElement)
|
|
1126
|
+
chain.unshift(e);
|
|
1127
|
+
let keep = 0;
|
|
1128
|
+
while (keep < open.length && open[keep].element === chain[keep])
|
|
1129
|
+
keep++;
|
|
1130
|
+
const closing = open.splice(keep).reverse().map((o) => o.close).join('');
|
|
1131
|
+
let opening = '';
|
|
1132
|
+
for (const e of chain.slice(keep)) {
|
|
1133
|
+
const cs = getComputedStyle(e);
|
|
1134
|
+
const c = bidiControls(cs.direction, cs.unicodeBidi);
|
|
1135
|
+
opening += c.open;
|
|
1136
|
+
open.push({ element: e, close: c.close });
|
|
1137
|
+
}
|
|
1138
|
+
if (closing || opening)
|
|
1139
|
+
marks.push({ at: offset, controls: closing + opening });
|
|
1140
|
+
offset += length;
|
|
1141
|
+
}
|
|
1142
|
+
const closing = open.reverse().map((o) => o.close).join('');
|
|
1143
|
+
if (closing)
|
|
1144
|
+
marks.push({ at: offset, controls: closing });
|
|
1145
|
+
return resolveLevels(text, base, marks);
|
|
890
1146
|
}
|
|
891
1147
|
/**
|
|
892
1148
|
* Moves each line's content into a block of its own, cloning the inline
|
|
@@ -957,6 +1213,7 @@ function render(el, segments, atoms, lines, spacing, commons, shapeOf, indent) {
|
|
|
957
1213
|
span.className = 'pw-space';
|
|
958
1214
|
span.style.wordSpacing = `${v}px`;
|
|
959
1215
|
range.surroundContents(span);
|
|
1216
|
+
release(range);
|
|
960
1217
|
}
|
|
961
1218
|
const out = [];
|
|
962
1219
|
const hyphens = [];
|
|
@@ -966,21 +1223,32 @@ function render(el, segments, atoms, lines, spacing, commons, shapeOf, indent) {
|
|
|
966
1223
|
range.setStart(boundaries[n].startContainer, boundaries[n].startOffset);
|
|
967
1224
|
range.setEnd(ends[n].startContainer, ends[n].startOffset);
|
|
968
1225
|
const content = extract(range);
|
|
1226
|
+
release(range);
|
|
969
1227
|
const lineEl = document.createElement('span');
|
|
970
1228
|
lineEl.className = 'pw-line';
|
|
971
1229
|
const { measure, left } = shapeOf(n);
|
|
972
|
-
|
|
1230
|
+
// Protrusion: the line shifts left by the left hang and, when it fills,
|
|
1231
|
+
// grows by both hangs, so the edge glyphs hang into the margin. A last
|
|
1232
|
+
// line's right hang was absorbed by \parfillskip and is not widened for.
|
|
1233
|
+
// All zero leaves the declaration as it was.
|
|
1234
|
+
const hangL = line.leftHang ?? 0;
|
|
1235
|
+
const hangR = line.rightHang ?? 0;
|
|
1236
|
+
const w = (n === 0 ? measure - indent : measure) + hangL + hangR;
|
|
1237
|
+
const shift = left + (n === 0 && indent < 0 ? indent : 0) - hangL;
|
|
973
1238
|
lineEl.style.cssText = `display:block;width:${w}px;white-space:pre;text-align:start;text-align-last:auto;text-indent:0;` +
|
|
974
1239
|
`text-rendering:geometricPrecision;word-spacing:${common ?? 0}px` +
|
|
975
1240
|
// A hanging indent (a negative \parindent, as an index's entries have) moves the line out into the padding;
|
|
976
1241
|
// a \parshape's indent (beside a left float) moves it in.
|
|
977
1242
|
(n === 0 && indent > 0 ? `;padding-left:${indent}px` : '') +
|
|
978
|
-
(
|
|
1243
|
+
(shift ? `;margin-left:${shift}px` : '') +
|
|
1244
|
+
(line.tracking ? `;letter-spacing:${line.tracking}px` : '') +
|
|
1245
|
+
(line.wdth ? `;font-stretch:${line.wdth}%` : '');
|
|
979
1246
|
lineEl.append(content);
|
|
980
1247
|
if (line.hyphen) {
|
|
981
1248
|
// In the element of the line's last character, so it has its font.
|
|
982
1249
|
const hyphen = document.createElement('span');
|
|
983
|
-
hyphen.className = 'pw-hyphen';
|
|
1250
|
+
hyphen.className = 'pw-generated pw-hyphen';
|
|
1251
|
+
hyphen.dataset.pwGenerated = 'hyphen';
|
|
984
1252
|
hyphen.setAttribute('aria-hidden', 'true');
|
|
985
1253
|
hyphen.textContent = line.hyphen;
|
|
986
1254
|
const last = lastText(lineEl);
|
|
@@ -1001,8 +1269,10 @@ function render(el, segments, atoms, lines, spacing, commons, shapeOf, indent) {
|
|
|
1001
1269
|
brk.append(extract(gap));
|
|
1002
1270
|
lineEl.append(brk);
|
|
1003
1271
|
}
|
|
1272
|
+
release(gap);
|
|
1004
1273
|
out.push(lineEl);
|
|
1005
1274
|
}
|
|
1275
|
+
release(...boundaries, ...ends);
|
|
1006
1276
|
// What is left after the text is dropped, but for elements that were empty to begin with: marks.
|
|
1007
1277
|
out.at(-1)?.append(...empty.filter((e) => el.contains(e) && !e.closest('.pw-line')));
|
|
1008
1278
|
el.replaceChildren(...out);
|
|
@@ -1080,7 +1350,9 @@ function textWidth(line) {
|
|
|
1080
1350
|
r.setEndBefore(brk);
|
|
1081
1351
|
else
|
|
1082
1352
|
r.setEnd(line, line.childNodes.length);
|
|
1083
|
-
|
|
1353
|
+
const width = r.getBoundingClientRect().width;
|
|
1354
|
+
release(r);
|
|
1355
|
+
return width;
|
|
1084
1356
|
}
|
|
1085
1357
|
/**
|
|
1086
1358
|
* Adds `units` (negative: takes them) of `unit` px of spacing to a line's
|
|
@@ -1119,6 +1391,7 @@ function spreadUnits(line, units, unit) {
|
|
|
1119
1391
|
span.className = 'pw-space';
|
|
1120
1392
|
span.style.wordSpacing = `${base + add}px`;
|
|
1121
1393
|
r.surroundContents(span);
|
|
1394
|
+
release(r);
|
|
1122
1395
|
}
|
|
1123
1396
|
return units * unit;
|
|
1124
1397
|
}
|