pulpweaver4 0.0.91 → 0.0.186
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
|
@@ -1,14 +1,19 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* What a painted book's PDF has beyond its pages' looks
|
|
3
3
|
* (https://plans.inkylabs.com/pulpweaver#every-kind-of-pdf): links, named
|
|
4
|
-
* destinations, bookmarks, page labels and tagged PDF,
|
|
5
|
-
* and the laid-out pages, and the standards an edition
|
|
4
|
+
* destinations, bookmarks, page labels, form fields' tags and tagged PDF,
|
|
5
|
+
* all from the HTML and the laid-out pages, and the standards an edition
|
|
6
|
+
* claims.
|
|
6
7
|
*/
|
|
7
8
|
import type { PdfStandard } from '../../config/config.js';
|
|
8
|
-
import type { PdfConformance, PdfDocument, PdfOp } from '../types.js';
|
|
9
|
+
import type { PdfConformance, PdfDocument, PdfFileAttachment, PdfNote, PdfOp } from '../types.js';
|
|
10
|
+
import { type PlacedAnnotation } from './annotations.js';
|
|
9
11
|
import { type DestinationView } from './links.js';
|
|
10
|
-
|
|
12
|
+
import { type TagCache } from './tags.js';
|
|
13
|
+
export { type ArtifactKind, type PageTags, plainText, roleOf, structureTree, type TagCache } from './tags.js';
|
|
11
14
|
export { type DestinationView } from './links.js';
|
|
15
|
+
export { fieldsAsContent } from './forms.js';
|
|
16
|
+
export { ATTACH_ATTRIBUTE, attachment, COMMENT_ATTRIBUTE, commentNote, mediaTypeOf, type PlacedAnnotation, placedAnnotations } from './annotations.js';
|
|
12
17
|
export { pageLabels } from './labels.js';
|
|
13
18
|
export interface StructureOptions {
|
|
14
19
|
/**
|
|
@@ -29,10 +34,31 @@ export interface StructureOptions {
|
|
|
29
34
|
bookmarks?: boolean;
|
|
30
35
|
/** The view destinations and bookmarks open at: an XYZ point (the default), the page's width, or the whole page. */
|
|
31
36
|
view?: DestinationView;
|
|
37
|
+
/**
|
|
38
|
+
* Told of each link on the pages that no element of `html` holds, which a
|
|
39
|
+
* tagged PDF leaves as text: its annotation would be in no `Link`
|
|
40
|
+
* element, which PDF/UA forbids. The layout keys every link of the HTML
|
|
41
|
+
* (`keyLinks`), so it is one only the pages have.
|
|
42
|
+
*/
|
|
43
|
+
unlinked?: (link: Element) => void;
|
|
44
|
+
/** Pages' tags kept from the last document, which a page whose ops and content are the same takes again (#178). */
|
|
45
|
+
tags?: TagCache;
|
|
46
|
+
/**
|
|
47
|
+
* Comments and attached files (`annotations.ts`), each with the element
|
|
48
|
+
* it is placed by: each goes on its page, and when tagged in an `Annot`
|
|
49
|
+
* element where its element is read.
|
|
50
|
+
*/
|
|
51
|
+
annotations?: readonly AnnotationOnPage[];
|
|
52
|
+
}
|
|
53
|
+
/** A comment or an attached file, and where its element puts it. */
|
|
54
|
+
export interface AnnotationOnPage {
|
|
55
|
+
placed: PlacedAnnotation;
|
|
56
|
+
note?: PdfNote;
|
|
57
|
+
attachment?: PdfFileAttachment;
|
|
32
58
|
}
|
|
33
59
|
/**
|
|
34
60
|
* Adds to a painted document (`paintDocument`'s) its named destinations,
|
|
35
|
-
* links, bookmarks, page labels and, unless `tagged` is off, its tags and
|
|
61
|
+
* links, comments and attached files, bookmarks, page labels and, unless `tagged` is off, its tags and
|
|
36
62
|
* structure tree. Changes and returns `doc`.
|
|
37
63
|
*/
|
|
38
64
|
export declare function structurePdf(doc: PdfDocument, options: StructureOptions): PdfDocument;
|
|
@@ -42,6 +68,16 @@ export interface EditionPdf {
|
|
|
42
68
|
standards: PdfConformance[];
|
|
43
69
|
/** Whether the PDF may have links: not in PDF/X, which allows no actions. */
|
|
44
70
|
links: boolean;
|
|
71
|
+
/**
|
|
72
|
+
* Whether form controls may be form fields: not in PDF/X, which allows no
|
|
73
|
+
* annotation where the page is printed, so its controls are their looks
|
|
74
|
+
* alone (`fieldsAsContent`).
|
|
75
|
+
*/
|
|
76
|
+
forms: boolean;
|
|
77
|
+
/** Whether a form's buttons may act (reset the form): not in PDF/A, which allows no action that changes the document. */
|
|
78
|
+
formActions: boolean;
|
|
79
|
+
/** Whether the pages may have comments and attached files: not in PDF/X, which allows no annotation where the page is printed. */
|
|
80
|
+
annotations: boolean;
|
|
45
81
|
/**
|
|
46
82
|
* Whether its transparency must be flattened, and the colours the painter
|
|
47
83
|
* leaves in sRGB converted to the output intent (`flattenTransparency`):
|
|
@@ -1,14 +1,18 @@
|
|
|
1
1
|
import { PDF_STANDARDS } from '../../config/project-schema.js';
|
|
2
2
|
import { paintedFrom } from '../../paint/painter.js';
|
|
3
|
+
import { annotElements } from './annotations.js';
|
|
3
4
|
import { addLinks, bookmarks, destinations, links, placesOf } from './links.js';
|
|
5
|
+
import { tagWidgets } from './forms.js';
|
|
4
6
|
import { addPageLabels } from './labels.js';
|
|
5
7
|
import { elementsByKey, tagDocument } from './tags.js';
|
|
6
8
|
export { plainText, roleOf, structureTree } from './tags.js';
|
|
7
9
|
export {} from './links.js';
|
|
10
|
+
export { fieldsAsContent } from './forms.js';
|
|
11
|
+
export { ATTACH_ATTRIBUTE, attachment, COMMENT_ATTRIBUTE, commentNote, mediaTypeOf, placedAnnotations } from './annotations.js';
|
|
8
12
|
export { pageLabels } from './labels.js';
|
|
9
13
|
/**
|
|
10
14
|
* Adds to a painted document (`paintDocument`'s) its named destinations,
|
|
11
|
-
* links, bookmarks, page labels and, unless `tagged` is off, its tags and
|
|
15
|
+
* links, comments and attached files, bookmarks, page labels and, unless `tagged` is off, its tags and
|
|
12
16
|
* structure tree. Changes and returns `doc`.
|
|
13
17
|
*/
|
|
14
18
|
export function structurePdf(doc, options) {
|
|
@@ -19,17 +23,45 @@ export function structurePdf(doc, options) {
|
|
|
19
23
|
const places = placesOf(pages);
|
|
20
24
|
doc.destinations = destinations(html, places, view);
|
|
21
25
|
const names = new Set(doc.destinations.map((d) => d.name));
|
|
22
|
-
const
|
|
26
|
+
const byKey = elementsByKey(html);
|
|
27
|
+
let placed = options.links === false ? [] : links(pages, names, byKey);
|
|
28
|
+
const annots = new Set();
|
|
23
29
|
if (options.tagged !== false) {
|
|
30
|
+
placed = placed.filter((p) => {
|
|
31
|
+
if (byKey.has(p.key))
|
|
32
|
+
return true;
|
|
33
|
+
options.unlinked?.(p.element);
|
|
34
|
+
return false;
|
|
35
|
+
});
|
|
24
36
|
tagDocument(doc, pages, html, options.sourceOf ?? paintedFrom, (tagging, orders) => {
|
|
25
37
|
// A link's annotation is read with its text, in its `Link` element.
|
|
26
38
|
for (const p of placed) {
|
|
27
39
|
const a = pages[p.page].querySelector(`a[data-pw-key="${p.key}"]`);
|
|
28
40
|
const order = (a && orders[p.page].get(a)) ?? 0;
|
|
29
|
-
|
|
30
|
-
p.link.id = tagging.leaf(p.key, order);
|
|
41
|
+
p.link.id = tagging.leaf(p.key, order);
|
|
31
42
|
}
|
|
32
|
-
|
|
43
|
+
// A form field's widget is read where its control is, in its `Form` element.
|
|
44
|
+
tagWidgets(doc, pages, tagging, orders);
|
|
45
|
+
// A comment or attached file, where its element is.
|
|
46
|
+
for (const a of options.annotations ?? []) {
|
|
47
|
+
// As a link's: one only the pages have would be in no element of the tree.
|
|
48
|
+
if (!byKey.has(a.placed.key))
|
|
49
|
+
continue;
|
|
50
|
+
const order = orders[a.placed.page].get(a.placed.element) ?? 0;
|
|
51
|
+
const id = tagging.leaf(a.placed.key, order);
|
|
52
|
+
annots.add(id);
|
|
53
|
+
(a.note ?? a.attachment).id = id;
|
|
54
|
+
}
|
|
55
|
+
}, options.tags);
|
|
56
|
+
if (doc.structure && annots.size)
|
|
57
|
+
annotElements(doc.structure, annots);
|
|
58
|
+
}
|
|
59
|
+
for (const a of options.annotations ?? []) {
|
|
60
|
+
const page = doc.pages[a.placed.page];
|
|
61
|
+
if (a.note)
|
|
62
|
+
(page.notes ??= []).push(a.note);
|
|
63
|
+
if (a.attachment)
|
|
64
|
+
(page.fileAttachments ??= []).push(a.attachment);
|
|
33
65
|
}
|
|
34
66
|
addLinks(doc, placed);
|
|
35
67
|
addPageLabels(doc, pages);
|
|
@@ -46,6 +78,9 @@ export function editionPdf(standards) {
|
|
|
46
78
|
return {
|
|
47
79
|
standards: standards.map((s) => CONFORMANCE[s]),
|
|
48
80
|
links: !standards.some((s) => s.startsWith('PDF/X-')),
|
|
81
|
+
forms: !standards.some((s) => s.startsWith('PDF/X-')),
|
|
82
|
+
formActions: !standards.some((s) => s.startsWith('PDF/A-')),
|
|
83
|
+
annotations: !standards.some((s) => s.startsWith('PDF/X-')),
|
|
49
84
|
flatten: standards.some((s) => s === 'PDF/X-1a' || s === 'PDF/X-3'),
|
|
50
85
|
};
|
|
51
86
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/pdf/structure/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/pdf/structure/index.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,aAAa,EAAE,MAAM,gCAAgC,CAAA;AAC9D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AAC,UAAU,CAAC,QAAQ,CAAC,CAAC;QAC3D,WAAW,EAAE,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC;QAC3D,OAAO,EAAE,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,KAAK,UAAU,IAAI,CAAC,KAAK,SAAS,CAAC;KACpE,CAAA;AACH,CAAC"}
|
|
@@ -79,7 +79,7 @@ export function links(pages, names, html) {
|
|
|
79
79
|
continue;
|
|
80
80
|
}
|
|
81
81
|
const whole = (key !== undefined && html?.get(key)?.closest('a[href]')) || a;
|
|
82
|
-
const placed = { page: i, key: key ?? '', link: { rects, target: goes, alt: altOf(whole, href) } };
|
|
82
|
+
const placed = { page: i, key: key ?? '', link: { rects, target: goes, alt: altOf(whole, href) }, element: a };
|
|
83
83
|
out.push(placed);
|
|
84
84
|
if (piece !== undefined)
|
|
85
85
|
pieces.set(piece, placed);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"links.js","sourceRoot":"","sources":["../../../src/pdf/structure/links.ts"],"names":[],"mappings":"AAeA,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAA;AAErC,4BAA4B;AAC5B,MAAM,EAAE,GAAG,IAAI,CAAA;AAYf,uHAAuH;AACvH,MAAM,UAAU,QAAQ,CAAC,KAAyB;IAChD,MAAM,MAAM,GAAG,IAAI,GAAG,EAAiB,CAAA;IACvC,KAAK,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,CAAC,EAAE,EAAE;QACxB,MAAM,MAAM,GAAG,IAAI,CAAC,qBAAqB,EAAE,CAAA;QAC3C,KAAK,MAAM,EAAE,IAAI,IAAI,CAAC,gBAAgB,CAAc,eAAe,CAAC,EAAE,CAAC;YACrE,mGAAmG;YACnG,MAAM,IAAI,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC,OAAO,CAAC,MAAM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AAI,EAAE,CAAA;QAClF,OAAO,KAAK,CAAC,EAAE,CAAC,CAAC,CAAC,CAAE,CAAC,KAAK,IAAI,KAAK;YAAE,KAAK,CAAC,GAAG,EAAE,CAAA;QAChD,KAAK,CAAC,EAAE,CAAC,CAAC,CAAC,CAAE,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;QACjC,KAAK,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,QAAQ,EAAE,CAAC,IAAI,CAAC,QAAQ,GAAG,EAAE,CAAC,EAAE,CAAC,CAAA;IACvD,CAAC;IACD,MAAM,KAAK,GAAG,CAAC,KAAuB,EAAE,EAAE;QACxC,KAAK,MAAM,CAAC,IAAI,KAAK,EAAE,CAAC;YACtB,IAAI,CAAC,CAAC,CAAC,QAAQ,EAAE,MAAM;gBAAE,OAAO,CAAC,CAAC,QAAQ,CAAA;;gBACrC,KAAK,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAA;QACxB,CAAC;IACH,CAAC,CAAA;IACD,KAAK,CAAC,IAAI,CAAC,CAAA;IACX,OAAO,IAAI,CAAA;AACb,CAAC;AAED,8CAA8C;AAC9C,MAAM,UAAU,QAAQ,CAAC,GAAgB,EAAE,MAA6B;IACtE,KAAK,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,MAAM;QAAE,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAE,CAAC,KAAK,KAAK,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;AACjF,CAAC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* How a viewer shows each page, from `@page` (#186; plan: Every kind of
|
|
3
|
+
* PDF, beamer's `\transdissolve` and `\transduration`, and `pdflscape`):
|
|
4
|
+
*
|
|
5
|
+
* - `--pw-page-rotate: 90` turns the page as a viewer shows it (`/Rotate`),
|
|
6
|
+
* clockwise, by 90, 180 or 270 degrees, as `pdflscape` turns a landscape
|
|
7
|
+
* page; the page is laid out and printed as it is;
|
|
8
|
+
* - `--pw-page-duration: 5s` advances a presentation after so long (`/Dur`);
|
|
9
|
+
* - `--pw-page-transition: wipe 0.5s left-to-right` is the effect a
|
|
10
|
+
* presentation reveals the page with (`/Trans`): a style (`split`,
|
|
11
|
+
* `blinds`, `box`, `wipe`, `dissolve`, `glitter`, `replace`, `fly`,
|
|
12
|
+
* `push`, `cover`, `uncover` or `fade`), how long it takes, and as the
|
|
13
|
+
* style takes them a direction (`left-to-right`, `bottom-to-top`,
|
|
14
|
+
* `right-to-left`, `top-to-bottom`, `top-left-to-bottom-right`, or
|
|
15
|
+
* `none` for fly), `horizontal` or `vertical`, and `inward` or `outward`.
|
|
16
|
+
*
|
|
17
|
+
* The layout copies each page's values to `data-pw-page-rotate`,
|
|
18
|
+
* `-duration` and `-transition`; a value this can't read is a warning.
|
|
19
|
+
*/
|
|
20
|
+
import type { PdfDocument, PdfPage, PdfTransition } from '../types.js';
|
|
21
|
+
/** `--pw-page-rotate`'s value, or why it is none. */
|
|
22
|
+
export declare function parseRotate(text: string): PdfPage['rotate'] | string;
|
|
23
|
+
/** `--pw-page-duration`'s value in seconds, or why it is none. */
|
|
24
|
+
export declare function parseDuration(text: string): number | string;
|
|
25
|
+
/** `--pw-page-transition`'s value, or why it is none. */
|
|
26
|
+
export declare function parseTransition(text: string): PdfTransition | string;
|
|
27
|
+
/** Gives each page its rotation, duration and transition, and returns what couldn't be read, once each. */
|
|
28
|
+
export declare function addPresentation(doc: PdfDocument, pages: readonly Element[]): string[];
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
const STYLES = ['split', 'blinds', 'box', 'wipe', 'dissolve', 'glitter', 'replace', 'fly', 'push', 'cover', 'uncover', 'fade'];
|
|
2
|
+
const DIRECTIONS = ['left-to-right', 'bottom-to-top', 'right-to-left', 'top-to-bottom', 'top-left-to-bottom-right', 'none'];
|
|
3
|
+
/** A CSS `<time>` in seconds, or undefined. */
|
|
4
|
+
function seconds(text) {
|
|
5
|
+
const m = /^(\d+(?:\.\d+)?|\.\d+)(s|ms)$/i.exec(text);
|
|
6
|
+
if (!m)
|
|
7
|
+
return undefined;
|
|
8
|
+
return Number(m[1]) / (m[2].toLowerCase() === 'ms' ? 1000 : 1);
|
|
9
|
+
}
|
|
10
|
+
/** `--pw-page-rotate`'s value, or why it is none. */
|
|
11
|
+
export function parseRotate(text) {
|
|
12
|
+
const m = /^(-?\d+)(deg)?$/.exec(text.trim());
|
|
13
|
+
const n = m ? ((Number(m[1]) % 360) + 360) % 360 : NaN;
|
|
14
|
+
if (n === 0 || n === 90 || n === 180 || n === 270)
|
|
15
|
+
return n;
|
|
16
|
+
return `--pw-page-rotate: ${text.trim()} is not 0, 90, 180 or 270`;
|
|
17
|
+
}
|
|
18
|
+
/** `--pw-page-duration`'s value in seconds, or why it is none. */
|
|
19
|
+
export function parseDuration(text) {
|
|
20
|
+
const s = seconds(text.trim());
|
|
21
|
+
return s === undefined ? `--pw-page-duration: ${text.trim()} is not a time, such as 5s` : s;
|
|
22
|
+
}
|
|
23
|
+
/** `--pw-page-transition`'s value, or why it is none. */
|
|
24
|
+
export function parseTransition(text) {
|
|
25
|
+
const words = text.trim().split(/\s+/);
|
|
26
|
+
const style = words.shift();
|
|
27
|
+
if (!STYLES.includes(style))
|
|
28
|
+
return `--pw-page-transition: ${style} is no transition, which are ${STYLES.join(', ')}`;
|
|
29
|
+
const out = { style };
|
|
30
|
+
for (const w of words) {
|
|
31
|
+
const time = seconds(w);
|
|
32
|
+
if (time !== undefined)
|
|
33
|
+
out.duration = time;
|
|
34
|
+
else if (DIRECTIONS.includes(w))
|
|
35
|
+
out.direction = w;
|
|
36
|
+
else if (w === 'horizontal' || w === 'vertical')
|
|
37
|
+
out.dimension = w;
|
|
38
|
+
else if (w === 'inward' || w === 'outward')
|
|
39
|
+
out.motion = w;
|
|
40
|
+
else
|
|
41
|
+
return `--pw-page-transition: ${text.trim()} has ${w}, which is no time, direction, horizontal or vertical, inward or outward`;
|
|
42
|
+
}
|
|
43
|
+
if (out.direction === 'none' && style !== 'fly')
|
|
44
|
+
return `--pw-page-transition: only fly travels from none`;
|
|
45
|
+
return out;
|
|
46
|
+
}
|
|
47
|
+
/** Gives each page its rotation, duration and transition, and returns what couldn't be read, once each. */
|
|
48
|
+
export function addPresentation(doc, pages) {
|
|
49
|
+
const problems = new Set();
|
|
50
|
+
pages.forEach((page, i) => {
|
|
51
|
+
const pdf = doc.pages[i];
|
|
52
|
+
const rotate = page.getAttribute('data-pw-page-rotate');
|
|
53
|
+
const duration = page.getAttribute('data-pw-page-duration');
|
|
54
|
+
const transition = page.getAttribute('data-pw-page-transition');
|
|
55
|
+
if (rotate !== null) {
|
|
56
|
+
const r = parseRotate(rotate);
|
|
57
|
+
if (typeof r === 'string')
|
|
58
|
+
problems.add(r);
|
|
59
|
+
else if (r)
|
|
60
|
+
pdf.rotate = r;
|
|
61
|
+
}
|
|
62
|
+
if (duration !== null) {
|
|
63
|
+
const d = parseDuration(duration);
|
|
64
|
+
if (typeof d === 'string')
|
|
65
|
+
problems.add(d);
|
|
66
|
+
else
|
|
67
|
+
pdf.duration = d;
|
|
68
|
+
}
|
|
69
|
+
if (transition !== null) {
|
|
70
|
+
const t = parseTransition(transition);
|
|
71
|
+
if (typeof t === 'string')
|
|
72
|
+
problems.add(t);
|
|
73
|
+
else
|
|
74
|
+
pdf.transition = t;
|
|
75
|
+
}
|
|
76
|
+
});
|
|
77
|
+
return [...problems];
|
|
78
|
+
}
|
|
79
|
+
//# sourceMappingURL=presentation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"presentation.js","sourceRoot":"","sources":["../../../src/pdf/structure/presentation.ts"],"names":[],"mappings":"AAqBA,MAAM,MAAM,GAAG,CAAC,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,SAAS,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,SAAS,EAAE,M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number;
|
|
51
51
|
}
|
|
52
|
+
/** Where each node of a page is read: its place in the document's DOM order. */
|
|
53
|
+
export interface NodeOrder {
|
|
54
|
+
get(node: Node): number | undefined;
|
|
55
|
+
}
|
|
52
56
|
/** Each node of a page in DOM order, its order counted on from `start`. */
|
|
53
57
|
export declare function domOrder(page: Element, start: number): Map<Node, number>;
|
|
54
58
|
/** An element's structure type, or what else it is, by HTML's meaning of it. */
|
|
@@ -71,9 +75,37 @@ export declare function tagPage(ops: PdfOp[], page: Element, order: Map<Node, nu
|
|
|
71
75
|
export declare function structureTree(root: Element, leaves: ReadonlyMap<string, readonly Leaf[]>, lang?: string): PdfStructNode[];
|
|
72
76
|
/** Every element of the HTML with a key, by it. */
|
|
73
77
|
export declare function elementsByKey(root: Element): Map<string, Element>;
|
|
78
|
+
/**
|
|
79
|
+
* A page's tags, apart from the rest of the document's: the ops `tagPage`
|
|
80
|
+
* puts among the page's, each after so many of them, its leaves' ids
|
|
81
|
+
* counted from 0 in the order it made them, each with its key and its order
|
|
82
|
+
* within the page, and how many nodes the page has in DOM order. Where
|
|
83
|
+
* the page falls in the document numbers its leaves and orders
|
|
84
|
+
* (`applyTags`), so the tags of a page whose ops and content are the same
|
|
85
|
+
* are kept from one document to the next (#178).
|
|
86
|
+
*/
|
|
87
|
+
export interface PageTags {
|
|
88
|
+
readonly inserted: readonly (readonly [after: number, op: PdfOp])[];
|
|
89
|
+
readonly leaves: readonly (readonly [key: string, order: number])[];
|
|
90
|
+
readonly size: number;
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Where pages' tags are kept from one document to the next: a build
|
|
94
|
+
* session's paint cache (`print/output.ts`). `context` is what tagging the
|
|
95
|
+
* page read of the HTML outside it; tags kept with another context are none.
|
|
96
|
+
*/
|
|
97
|
+
export interface TagCache {
|
|
98
|
+
get(page: number, context: string): PageTags | undefined;
|
|
99
|
+
set(page: number, context: string, tags: PageTags): void;
|
|
100
|
+
}
|
|
101
|
+
/** A page's tags (`PageTags`): `tagPage` given its own leaves and orders, from 0. */
|
|
102
|
+
export declare function pageTags(ops: PdfOp[], page: Element, order: Map<Node, number>, html: ReadonlyMap<string, Element>, sourceOf: (op: PdfOp) => Node | undefined, background?: PdfRect): PageTags;
|
|
103
|
+
/** A page's ops with its tags among them, its leaves recorded in `tagging` and its orders counted on from `start`. */
|
|
104
|
+
export declare function applyTags(ops: readonly PdfOp[], tags: PageTags, tagging: Tagging, start: number): PdfOp[];
|
|
74
105
|
/**
|
|
75
106
|
* Tags every page's ops and sets the document's structure tree. `extra` may
|
|
76
|
-
* record more leaves (links') before the tree is made.
|
|
107
|
+
* record more leaves (links') before the tree is made. A page whose tags
|
|
108
|
+
* `cache` keeps is not tagged again.
|
|
77
109
|
*/
|
|
78
|
-
export declare function tagDocument(doc: PdfDocument, pages: readonly Element[], html: Element, sourceOf: (op: PdfOp) => Node | undefined, extra?: (tagging: Tagging, orders:
|
|
110
|
+
export declare function tagDocument(doc: PdfDocument, pages: readonly Element[], html: Element, sourceOf: (op: PdfOp) => Node | undefined, extra?: (tagging: Tagging, orders: NodeOrder[]) => void, cache?: TagCache): Tagging;
|
|
79
111
|
export {};
|
|
@@ -24,6 +24,11 @@ export function domOrder(page, start) {
|
|
|
24
24
|
order.set(node, n++);
|
|
25
25
|
return order;
|
|
26
26
|
}
|
|
27
|
+
/** A table cell's spans, PDF's `RowSpan` and `ColSpan` attributes, where they are more than one. */
|
|
28
|
+
function spans(el) {
|
|
29
|
+
const cell = el;
|
|
30
|
+
return { ...(cell.rowSpan > 1 && { rowSpan: cell.rowSpan }), ...(cell.colSpan > 1 && { colSpan: cell.colSpan }) };
|
|
31
|
+
}
|
|
27
32
|
/** An element's structure type, or what else it is, by HTML's meaning of it. */
|
|
28
33
|
export function roleOf(el) {
|
|
29
34
|
const name = el.localName;
|
|
@@ -76,8 +81,8 @@ export function roleOf(el) {
|
|
|
76
81
|
case 'tbody': return element('TBody');
|
|
77
82
|
case 'tfoot': return element('TFoot');
|
|
78
83
|
case 'tr': return element('TR');
|
|
79
|
-
case 'th': return element('TH', { scope: el.closest('thead') ? 'column' : 'row' });
|
|
80
|
-
case 'td': return element('TD');
|
|
84
|
+
case 'th': return element('TH', { scope: el.closest('thead') ? 'column' : 'row', ...spans(el) });
|
|
85
|
+
case 'td': return element('TD', spans(el));
|
|
81
86
|
case 'figure': return element('Div');
|
|
82
87
|
case 'img': {
|
|
83
88
|
const alt = el.getAttribute('alt')?.trim();
|
|
@@ -104,6 +109,11 @@ export function roleOf(el) {
|
|
|
104
109
|
case 'ins':
|
|
105
110
|
case 'del':
|
|
106
111
|
case 'small': return element('Span');
|
|
112
|
+
// A form control holds its field's widget (`forms.ts`), or, without the form, its value.
|
|
113
|
+
case 'input':
|
|
114
|
+
case 'textarea':
|
|
115
|
+
case 'select':
|
|
116
|
+
case 'button': return element('Form');
|
|
107
117
|
case 'hr': return { kind: 'artifact' };
|
|
108
118
|
case 'div':
|
|
109
119
|
if (cls.contains('pw-document'))
|
|
@@ -178,7 +188,7 @@ function tagOf(op, source, page, html) {
|
|
|
178
188
|
const text = op.op === 'glyphs';
|
|
179
189
|
// An image is content when it is an element's own (an `img`, a canvas),
|
|
180
190
|
// and layout when it is a background, border image or shadow.
|
|
181
|
-
const graphic = op.op === 'image' && (el?.localName === 'img' || el?.localName === 'canvas' || el?.localName === 'svg');
|
|
191
|
+
const graphic = (op.op === 'image' || op.op === 'pdf') && (el?.localName === 'img' || el?.localName === 'canvas' || el?.localName === 'svg');
|
|
182
192
|
// The element of the HTML the op shows, by its key.
|
|
183
193
|
let key;
|
|
184
194
|
for (let e = el; e && e !== page.parentElement; e = e.parentElement) {
|
|
@@ -212,23 +222,31 @@ function inFigure(el) {
|
|
|
212
222
|
* order.
|
|
213
223
|
*/
|
|
214
224
|
export function structureTree(root, leaves, lang) {
|
|
215
|
-
return build(root, leaves, lang ?? root.closest('[lang]')?.getAttribute('lang') ?? undefined, new Set()).map((p) => p.node);
|
|
225
|
+
return build(root, leaves, lang ?? root.closest('[lang]')?.getAttribute('lang') ?? undefined, new Set(), new Set()).map((p) => p.node);
|
|
216
226
|
}
|
|
217
|
-
|
|
227
|
+
/**
|
|
228
|
+
* An element's structure. Its leaves are its key's; copies of an element
|
|
229
|
+
* that share its key (an included PDF's pages, one image each) are one
|
|
230
|
+
* element, the first, whose leaves are on every page they are.
|
|
231
|
+
*/
|
|
232
|
+
function build(el, leaves, lang, skip, claimed) {
|
|
218
233
|
const role = roleOf(el);
|
|
219
234
|
if (role.kind === 'artifact')
|
|
220
235
|
return [];
|
|
221
236
|
const ownLang = el.getAttribute('lang') ?? undefined;
|
|
222
237
|
const childLang = ownLang ?? lang;
|
|
223
238
|
const key = el.dataset?.['pwKey'];
|
|
224
|
-
const
|
|
239
|
+
const own = key !== undefined && !claimed.has(key);
|
|
240
|
+
if (own)
|
|
241
|
+
claimed.add(key);
|
|
242
|
+
const items = (own ? leaves.get(key) ?? [] : []).map((l) => ({ order: l.order, node: l.id }));
|
|
225
243
|
// A list item's marker is its label, read before its body.
|
|
226
244
|
let label;
|
|
227
245
|
if (role.kind === 'element' && role.tag === 'LI') {
|
|
228
246
|
const marker = [...el.querySelectorAll('.pw-marker')].find((m) => m.closest('li') === el);
|
|
229
247
|
if (marker) {
|
|
230
248
|
skip.add(marker);
|
|
231
|
-
label = build(marker, leaves, childLang, skip)[0];
|
|
249
|
+
label = build(marker, leaves, childLang, skip, claimed)[0];
|
|
232
250
|
}
|
|
233
251
|
}
|
|
234
252
|
// Children in the HTML's order; one out of the flow (a note) is read just after what precedes it there.
|
|
@@ -236,7 +254,7 @@ function build(el, leaves, lang, skip) {
|
|
|
236
254
|
for (const child of el.children) {
|
|
237
255
|
if (skip.has(child))
|
|
238
256
|
continue;
|
|
239
|
-
const placed = build(child, leaves, childLang, skip);
|
|
257
|
+
const placed = build(child, leaves, childLang, skip, claimed);
|
|
240
258
|
if (!placed.length)
|
|
241
259
|
continue;
|
|
242
260
|
const note = child.getAttribute('role') === 'doc-footnote' || child.classList.contains('pw-note');
|
|
@@ -291,21 +309,106 @@ export function elementsByKey(root) {
|
|
|
291
309
|
function backgroundBox(p) {
|
|
292
310
|
return p.bleedBox ?? { x: 0, y: 0, width: p.width, height: p.height };
|
|
293
311
|
}
|
|
312
|
+
/** A page's tags (`PageTags`): `tagPage` given its own leaves and orders, from 0. */
|
|
313
|
+
export function pageTags(ops, page, order, html, sourceOf, background) {
|
|
314
|
+
const own = new Tagging();
|
|
315
|
+
const out = tagPage(ops, page, order, html, own, sourceOf, background);
|
|
316
|
+
const inserted = [];
|
|
317
|
+
let k = 0;
|
|
318
|
+
for (const op of out) {
|
|
319
|
+
if (op === ops[k])
|
|
320
|
+
k++;
|
|
321
|
+
else
|
|
322
|
+
inserted.push([k, op]);
|
|
323
|
+
}
|
|
324
|
+
const leaves = [];
|
|
325
|
+
for (const [key, list] of own.leaves)
|
|
326
|
+
for (const l of list)
|
|
327
|
+
leaves[l.id] = [key, l.order];
|
|
328
|
+
return { inserted, leaves, size: order.size };
|
|
329
|
+
}
|
|
330
|
+
/** A page's ops with its tags among them, its leaves recorded in `tagging` and its orders counted on from `start`. */
|
|
331
|
+
export function applyTags(ops, tags, tagging, start) {
|
|
332
|
+
const ids = tags.leaves.map(([key, order]) => tagging.leaf(key, order + start));
|
|
333
|
+
const out = [];
|
|
334
|
+
let k = 0;
|
|
335
|
+
for (const [after, op] of tags.inserted) {
|
|
336
|
+
while (k < after)
|
|
337
|
+
out.push(ops[k++]);
|
|
338
|
+
const copy = { ...op };
|
|
339
|
+
if (copy.op === 'begin') {
|
|
340
|
+
if (copy.id !== undefined)
|
|
341
|
+
copy.id = ids[copy.id];
|
|
342
|
+
if (copy.bbox)
|
|
343
|
+
copy.bbox = { ...copy.bbox };
|
|
344
|
+
}
|
|
345
|
+
out.push(copy);
|
|
346
|
+
}
|
|
347
|
+
while (k < ops.length)
|
|
348
|
+
out.push(ops[k++]);
|
|
349
|
+
return out;
|
|
350
|
+
}
|
|
351
|
+
/**
|
|
352
|
+
* What tagging a page reads of the HTML beyond the page itself, for each
|
|
353
|
+
* keyed element of it: whether the HTML has its key, the part its nearest
|
|
354
|
+
* element with a role has, and whether it is in a drawn figure.
|
|
355
|
+
*/
|
|
356
|
+
function tagContext(page, html, memo, background) {
|
|
357
|
+
const parts = [JSON.stringify(background)];
|
|
358
|
+
for (const el of page.querySelectorAll('[data-pw-key]')) {
|
|
359
|
+
const key = el.dataset['pwKey'];
|
|
360
|
+
let part = memo.get(key);
|
|
361
|
+
if (part === undefined) {
|
|
362
|
+
const source = html.get(key);
|
|
363
|
+
part = '-';
|
|
364
|
+
for (let e = source ?? null; e; e = e.parentElement) {
|
|
365
|
+
const role = roleOf(e);
|
|
366
|
+
if (role.kind === 'transparent')
|
|
367
|
+
continue;
|
|
368
|
+
part = role.kind === 'artifact' ? 'a' : 'e';
|
|
369
|
+
break;
|
|
370
|
+
}
|
|
371
|
+
if (source)
|
|
372
|
+
part += inFigure(source) ? 'f' : 't';
|
|
373
|
+
memo.set(key, part);
|
|
374
|
+
}
|
|
375
|
+
parts.push(part);
|
|
376
|
+
}
|
|
377
|
+
return parts.join('');
|
|
378
|
+
}
|
|
294
379
|
/**
|
|
295
380
|
* Tags every page's ops and sets the document's structure tree. `extra` may
|
|
296
|
-
* record more leaves (links') before the tree is made.
|
|
381
|
+
* record more leaves (links') before the tree is made. A page whose tags
|
|
382
|
+
* `cache` keeps is not tagged again.
|
|
297
383
|
*/
|
|
298
|
-
export function tagDocument(doc, pages, html, sourceOf, extra) {
|
|
384
|
+
export function tagDocument(doc, pages, html, sourceOf, extra, cache) {
|
|
299
385
|
const byKey = elementsByKey(html);
|
|
300
386
|
const tagging = new Tagging();
|
|
301
387
|
const orders = [];
|
|
388
|
+
const memo = new Map();
|
|
302
389
|
let start = 0;
|
|
303
390
|
doc.pages.forEach((p, i) => {
|
|
304
391
|
const page = pages[i];
|
|
305
|
-
const
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
392
|
+
const background = backgroundBox(p);
|
|
393
|
+
const context = cache ? tagContext(page, byKey, memo, background) : '';
|
|
394
|
+
let tags = cache?.get(i, context);
|
|
395
|
+
const at = start;
|
|
396
|
+
if (tags) {
|
|
397
|
+
// Its orders are read again only if a link or a field asks for them.
|
|
398
|
+
let order;
|
|
399
|
+
orders.push({ get: (node) => (order ??= domOrder(page, at)).get(node) });
|
|
400
|
+
}
|
|
401
|
+
else {
|
|
402
|
+
const order = domOrder(page, 0);
|
|
403
|
+
tags = pageTags(p.ops ?? [], page, order, byKey, sourceOf, background);
|
|
404
|
+
cache?.set(i, context, tags);
|
|
405
|
+
orders.push({ get: (node) => {
|
|
406
|
+
const n = order.get(node);
|
|
407
|
+
return n === undefined ? undefined : n + at;
|
|
408
|
+
} });
|
|
409
|
+
}
|
|
410
|
+
p.ops = applyTags(p.ops ?? [], tags, tagging, start);
|
|
411
|
+
start += tags.size;
|
|
309
412
|
});
|
|
310
413
|
extra?.(tagging, orders);
|
|
311
414
|
doc.structure = structureTree(html, tagging.leaves, doc.metadata?.lang);
|