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
|
@@ -0,0 +1,287 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A plugin's reference, made from its definition
|
|
3
|
+
* (https://plans.inkylabs.com/pulpweaver#the-documentation-site): its
|
|
4
|
+
* options, outputs, blocks and spans, lint rules and presets, test matchers
|
|
5
|
+
* and indexes, as Markdown pages with the frontmatter Starlight reads, which
|
|
6
|
+
* the plugin's package ships in its `docs/reference/` and
|
|
7
|
+
* pulpweaver.inkylabs.com shows beside the core's. A plugin's own script
|
|
8
|
+
* calls `pluginReference` on its built module at each release, adds any
|
|
9
|
+
* pages of its own, and fails on whatever `problems` lists, as the core's
|
|
10
|
+
* `scripts/reference` does for the core:
|
|
11
|
+
*
|
|
12
|
+
* ```js
|
|
13
|
+
* import { pluginReference, renderReferencePage } from 'pulpweaver4'
|
|
14
|
+
* import plugin from '../dist/index.js'
|
|
15
|
+
*
|
|
16
|
+
* const { pages, problems } = pluginReference(plugin, { matchers: { toHaveQuestionsNumbered: 'Every questions block is numbered.' } })
|
|
17
|
+
* for (const page of pages) await writeFile(`docs/${page.path}`, renderReferencePage(page, 'scripts/reference.mjs'))
|
|
18
|
+
* ```
|
|
19
|
+
*
|
|
20
|
+
* Links between pages are relative paths to their `.md` files, which
|
|
21
|
+
* resolve in the package's `docs/` as on GitLab, and which the site turns
|
|
22
|
+
* into its own URLs.
|
|
23
|
+
*/
|
|
24
|
+
import { describe } from '../config/schema.js';
|
|
25
|
+
const INDEX = 'reference/index.md';
|
|
26
|
+
const OPTIONS = 'reference/options.md';
|
|
27
|
+
const SYNTAX = 'reference/blocks-and-spans.md';
|
|
28
|
+
const RULES = 'reference/lint-rules';
|
|
29
|
+
const LEVELS = {
|
|
30
|
+
source: '`source`: the sources and the bibliography, in every edition and in `pw lint`',
|
|
31
|
+
html: '`html`: the rendered HTML, in every edition, in `pw build`',
|
|
32
|
+
layout: '`layout`: the laid-out pages, in print editions, in `pw build`',
|
|
33
|
+
};
|
|
34
|
+
const PRINT = { name: 'paperback', media: 'print', output: 'pdf' };
|
|
35
|
+
const SCREEN = { name: 'web', media: 'screen', output: 'web' };
|
|
36
|
+
/**
|
|
37
|
+
* A plugin's reference, from its definition (what `definePlugin` returns):
|
|
38
|
+
* an index with its outputs, blocks and spans, rules, presets, matchers and
|
|
39
|
+
* indexes; a page of its options; a page of its blocks' and spans'
|
|
40
|
+
* attributes; and a page for each lint rule. Anything without a description
|
|
41
|
+
* is listed in `problems`, which a plugin's release should fail on.
|
|
42
|
+
*/
|
|
43
|
+
export function pluginReference(plugin, options = {}) {
|
|
44
|
+
const problems = [];
|
|
45
|
+
const need = (text, what) => {
|
|
46
|
+
if (!text?.trim())
|
|
47
|
+
problems.push(`${what} has no description`);
|
|
48
|
+
return text?.trim() ?? '';
|
|
49
|
+
};
|
|
50
|
+
const name = plugin.name;
|
|
51
|
+
const description = need(plugin.description, `the plugin ${name}`);
|
|
52
|
+
const optionEntries = Object.entries(plugin.options?.properties ?? {});
|
|
53
|
+
for (const [key, s] of optionEntries)
|
|
54
|
+
need(s.description, `the option ${key}`);
|
|
55
|
+
const outputs = Object.entries(plugin.output);
|
|
56
|
+
const claims = [
|
|
57
|
+
...Object.entries(plugin.blocks).map(([n, c]) => ({ kind: 'block', name: n, claim: c })),
|
|
58
|
+
...Object.entries(plugin.inlines).map(([n, c]) => ({ kind: 'span', name: n, claim: c })),
|
|
59
|
+
];
|
|
60
|
+
const rules = Object.values(plugin.lint.rules);
|
|
61
|
+
const presets = Object.entries(plugin.lint.presets);
|
|
62
|
+
const matchers = Object.keys(plugin.matchers);
|
|
63
|
+
const indexes = Object.entries(plugin.indexes);
|
|
64
|
+
for (const m of Object.keys(options.matchers ?? {}))
|
|
65
|
+
if (!matchers.includes(m))
|
|
66
|
+
problems.push(`the matcher ${m} has a description but the plugin has no such matcher`);
|
|
67
|
+
const pages = [];
|
|
68
|
+
if (optionEntries.length)
|
|
69
|
+
pages.push(optionsPage(plugin, optionEntries));
|
|
70
|
+
if (claims.length)
|
|
71
|
+
pages.push(syntaxPage(claims, need));
|
|
72
|
+
for (const rule of rules)
|
|
73
|
+
pages.push(rulePage(rule, presets, need));
|
|
74
|
+
const own = options.pages ?? [];
|
|
75
|
+
const body = [
|
|
76
|
+
sentence(description),
|
|
77
|
+
'## Installing it',
|
|
78
|
+
`\`pw add ${name}\` installs it beside the project and names it in \`pulpweaver4.toml\`’s \`[plugins]\`:`,
|
|
79
|
+
code('toml', `[plugins]\n${tomlKey(name)} = ${toToml(exampleOptions(plugin.options))}`),
|
|
80
|
+
optionEntries.length
|
|
81
|
+
? `Its ${link('options', INDEX, OPTIONS)} are that table’s keys: ${optionEntries.map(([k]) => link(inlineCode(k), INDEX, OPTIONS, anchorOf(k))).join(', ')}.`
|
|
82
|
+
: 'It takes no options.',
|
|
83
|
+
];
|
|
84
|
+
if (outputs.length) {
|
|
85
|
+
body.push('## Outputs', 'An edition whose `output` is one of these is written by the plugin.', table(['Output', 'What it writes'], outputs.map(([o, d]) => [inlineCode(`output = "${o}"`), need(d.description, `the output ${o}`)])));
|
|
86
|
+
}
|
|
87
|
+
if (claims.length) {
|
|
88
|
+
body.push('## Blocks and spans', `What the plugin reads in the source, with ${link('their attributes', INDEX, SYNTAX)}.`, table(['Syntax', 'What it is'], claims.map((c) => [link(inlineCode(syntaxOf(c.kind, c.name)), INDEX, SYNTAX, anchorOf(syntaxOf(c.kind, c.name))), c.claim.description?.trim() ?? ''])));
|
|
89
|
+
}
|
|
90
|
+
if (rules.length) {
|
|
91
|
+
body.push('## Lint rules', 'Set in `pulpweaver4.toml`’s `[lint]`, as any rule is.', table(['Rule', 'Level', 'What it reports'], rules.map((r) => [link(inlineCode(r.name), INDEX, rulePath(name, r.name)), inlineCode(r.level), r.description?.trim() ?? ''])));
|
|
92
|
+
}
|
|
93
|
+
if (presets.length) {
|
|
94
|
+
body.push('## Presets', 'A project or an edition `extends` them in `[lint]`, beside the core’s.');
|
|
95
|
+
for (const [p, preset] of presets) {
|
|
96
|
+
body.push(`### ${inlineCode(p)}`, `${sentence(need(preset.description, `the preset ${p}`))}${preset.extends?.length ? ` It extends ${preset.extends.map(inlineCode).join(', ')}.` : ''}${p === `${name}/recommended` ? ' It comes with the core’s `recommended`: a project or edition that extends that has it too, without naming it.' : ''}`, table(['Rule', 'Setting'], Object.entries(preset.rules).map(([r, s]) => [plugin.lint.rules[r] ? link(inlineCode(r), INDEX, rulePath(name, r)) : inlineCode(r), inlineCode(toToml(s))])));
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
if (matchers.length) {
|
|
100
|
+
body.push('## Test matchers', `\`expect\` matchers for a book’s tests, once the plugin is in \`[plugins]\`.`, table(['Matcher', 'What it checks'], matchers.map((m) => [inlineCode(m), need(options.matchers?.[m], `the matcher ${m}`)])));
|
|
101
|
+
}
|
|
102
|
+
if (indexes.length) {
|
|
103
|
+
body.push('## Indexes', 'Indexes it makes, which a `::: index` block places by its `name`.', table(['Name', 'Heading', 'What it indexes'], indexes.map(([i, d]) => [inlineCode(i), d.title ?? '', need(d.description, `the index ${i}`)])));
|
|
104
|
+
}
|
|
105
|
+
if (own.length)
|
|
106
|
+
body.push('## More', own.map((p) => `- ${link(p.title, INDEX, p.path)}: ${p.description}`).join('\n'));
|
|
107
|
+
const index = {
|
|
108
|
+
path: INDEX,
|
|
109
|
+
title: 'Reference',
|
|
110
|
+
description: plain(`${name}’s reference, generated from its code: ${lowerFirst(description) || 'the plugin'}`).replace(/\.?$/, '.'),
|
|
111
|
+
order: 0,
|
|
112
|
+
body: body.join('\n\n'),
|
|
113
|
+
};
|
|
114
|
+
return { pages: [index, ...pages, ...own], problems };
|
|
115
|
+
}
|
|
116
|
+
/** The file a page is written as: Starlight's frontmatter, a note that it is generated by `generator`, and its body. */
|
|
117
|
+
export function renderReferencePage(page, generator) {
|
|
118
|
+
const front = [
|
|
119
|
+
'---',
|
|
120
|
+
`title: ${JSON.stringify(page.title)}`,
|
|
121
|
+
`description: ${JSON.stringify(page.description)}`,
|
|
122
|
+
...(page.order === undefined ? [] : ['sidebar:', ` order: ${page.order}`]),
|
|
123
|
+
'---',
|
|
124
|
+
'',
|
|
125
|
+
`<!-- Generated from the plugin’s code by ${generator}; edit the code, not this page. -->`,
|
|
126
|
+
'',
|
|
127
|
+
];
|
|
128
|
+
return `${front.join('\n')}\n${page.body.trim()}\n`;
|
|
129
|
+
}
|
|
130
|
+
// The pages.
|
|
131
|
+
function optionsPage(plugin, entries) {
|
|
132
|
+
const body = [
|
|
133
|
+
`The options are ${inlineCode(plugin.name)}’s table in \`pulpweaver4.toml\`’s \`[plugins]\`. pulpweaver4 checks them as it loads the plugin: an unknown option, or a wrong value, stops the build, with its place in the file and how to fix it.`,
|
|
134
|
+
code('toml', `[plugins]\n${tomlKey(plugin.name)} = ${toToml(exampleOptions(plugin.options))}`),
|
|
135
|
+
];
|
|
136
|
+
const required = new Set(plugin.options?.required ?? []);
|
|
137
|
+
for (const [key, s] of entries) {
|
|
138
|
+
const facts = [['Value', valueOf(s)]];
|
|
139
|
+
if (s.default !== undefined)
|
|
140
|
+
facts.push(['Default', inlineCode(toToml(s.default))]);
|
|
141
|
+
facts.push(['Required', required.has(key) ? 'Yes' : 'No']);
|
|
142
|
+
body.push(`## ${inlineCode(key)}`, s.description?.trim() ?? '', table(['', ''], facts.map(([k, v]) => [`**${k}**`, v])));
|
|
143
|
+
const example = s.examples?.[0] ?? s.anyOf?.find((b) => b.examples?.length)?.examples?.[0];
|
|
144
|
+
if (example !== undefined)
|
|
145
|
+
body.push(code('toml', `[plugins]\n${tomlKey(plugin.name)} = ${toToml({ [key]: example })}`));
|
|
146
|
+
}
|
|
147
|
+
return { path: OPTIONS, title: 'Options', description: `The options of ${plugin.name}, its table in pulpweaver4.toml’s [plugins].`, order: 1, body: body.join('\n\n') };
|
|
148
|
+
}
|
|
149
|
+
function syntaxPage(claims, need) {
|
|
150
|
+
const body = ['The blocks and spans the plugin claims, and the attributes the build checks them for. `id`, `class` and attributes in the plugin’s own namespace (`<plugin>:<name>`) are always allowed; any other is an error.'];
|
|
151
|
+
for (const { kind, name, claim } of claims) {
|
|
152
|
+
const syntax = syntaxOf(kind, name);
|
|
153
|
+
body.push(`## ${inlineCode(syntax)}`, sentence(need(claim.description, `the ${kind} ${name}`)));
|
|
154
|
+
const attributes = Object.entries(claim.attributes ?? {});
|
|
155
|
+
const required = new Set(claim.required ?? []);
|
|
156
|
+
if (attributes.length) {
|
|
157
|
+
body.push(table(['Attribute', 'Value', 'Required', 'What it does'], attributes.map(([a, t]) => [
|
|
158
|
+
inlineCode(a),
|
|
159
|
+
valueOf(attributeSchema(t)),
|
|
160
|
+
required.has(a) ? 'Yes' : 'No',
|
|
161
|
+
need(typeof t === 'string' ? undefined : t.description, `the attribute ${a} of ${syntax}`),
|
|
162
|
+
])));
|
|
163
|
+
}
|
|
164
|
+
else {
|
|
165
|
+
body.push('It takes no attributes of its own.');
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
return { path: SYNTAX, title: 'Blocks and spans', description: 'The blocks and spans the plugin reads in the source, and their attributes.', order: 2, body: body.join('\n\n') };
|
|
169
|
+
}
|
|
170
|
+
function rulePage(rule, presets, need) {
|
|
171
|
+
const plugin = rule.name.slice(0, rule.name.indexOf('/'));
|
|
172
|
+
const path = rulePath(plugin, rule.name);
|
|
173
|
+
const description = need(rule.description, `the lint rule ${rule.name}`);
|
|
174
|
+
const inPresets = presets.filter(([, p]) => p.rules[rule.name] !== undefined);
|
|
175
|
+
const facts = [
|
|
176
|
+
['Level', LEVELS[rule.level]],
|
|
177
|
+
['When on', onMeans(rule)],
|
|
178
|
+
['Fixable', rule.fixable ? 'Yes, by `pw lint --fix`' : 'No'],
|
|
179
|
+
['In presets', inPresets.length ? inPresets.map(([p, preset]) => `${link(inlineCode(p), path, INDEX, anchorOf(p))} (${inlineCode(toToml(preset.rules[rule.name]))})`).join(', ') : 'none'],
|
|
180
|
+
];
|
|
181
|
+
const ruleOptions = Object.entries(rule.options?.properties ?? {});
|
|
182
|
+
for (const [o, s] of ruleOptions)
|
|
183
|
+
need(s.description, `the lint rule ${rule.name}’s option ${o}`);
|
|
184
|
+
const setting = ruleOptions.length
|
|
185
|
+
? toToml(['error', Object.fromEntries(ruleOptions.map(([k, s]) => [k, s.default ?? s.examples?.[0] ?? (s.type === 'integer' || s.type === 'number' ? 1 : '…')]))])
|
|
186
|
+
: '"error"';
|
|
187
|
+
const body = [
|
|
188
|
+
sentence(description),
|
|
189
|
+
table(['', ''], facts.map(([k, v]) => [`**${k}**`, v])),
|
|
190
|
+
...(ruleOptions.length
|
|
191
|
+
? ['## Options', table(['Option', 'Value', 'Default', 'What it is'], ruleOptions.map(([k, s]) => [inlineCode(k), valueOf(s), s.default === undefined ? '' : inlineCode(toToml(s.default)), s.description?.trim() ?? '']))]
|
|
192
|
+
: []),
|
|
193
|
+
'## Setting it',
|
|
194
|
+
'In `pulpweaver4.toml`, for the project or one edition:',
|
|
195
|
+
code('toml', `[lint.rules]\n${tomlKey(rule.name)} = ${setting}`),
|
|
196
|
+
];
|
|
197
|
+
return { path, title: rule.name, description: plain(sentence(`The ${rule.name} lint rule: ${lowerFirst(description)}`)), body: body.join('\n\n') };
|
|
198
|
+
}
|
|
199
|
+
// The pieces.
|
|
200
|
+
function rulePath(plugin, rule) {
|
|
201
|
+
return `${RULES}/${rule.startsWith(`${plugin}/`) ? rule.slice(plugin.length + 1) : rule}.md`;
|
|
202
|
+
}
|
|
203
|
+
function syntaxOf(kind, name) {
|
|
204
|
+
return kind === 'block' ? `::: ${name}` : `{.${name}}`;
|
|
205
|
+
}
|
|
206
|
+
function attributeSchema(t) {
|
|
207
|
+
return typeof t === 'string' ? { type: t } : t;
|
|
208
|
+
}
|
|
209
|
+
/** What `on` means for a rule. */
|
|
210
|
+
function onMeans(rule) {
|
|
211
|
+
const s = rule.severity;
|
|
212
|
+
if (typeof s !== 'function')
|
|
213
|
+
return inlineCode(s ?? 'warn');
|
|
214
|
+
const print = s(PRINT);
|
|
215
|
+
const screen = s(SCREEN);
|
|
216
|
+
return print === screen ? inlineCode(print) : `${inlineCode(print)} in a print edition, ${inlineCode(screen)} on screen`;
|
|
217
|
+
}
|
|
218
|
+
/** What a key takes, its literals in code. */
|
|
219
|
+
function valueOf(schema) {
|
|
220
|
+
let text = describe(schema);
|
|
221
|
+
if (schema.minimum !== undefined && schema.maximum !== undefined)
|
|
222
|
+
text += `, from ${schema.minimum} to ${schema.maximum}`;
|
|
223
|
+
return text.replace(/"[^"]*"/g, (literal) => inlineCode(literal));
|
|
224
|
+
}
|
|
225
|
+
/** The options' table as an example: each option's first example, or none. */
|
|
226
|
+
function exampleOptions(schema) {
|
|
227
|
+
const out = {};
|
|
228
|
+
for (const [k, s] of Object.entries(schema?.properties ?? {})) {
|
|
229
|
+
const example = s.examples?.[0] ?? s.anyOf?.find((b) => b.examples?.length)?.examples?.[0];
|
|
230
|
+
if (example !== undefined)
|
|
231
|
+
out[k] = example;
|
|
232
|
+
}
|
|
233
|
+
return out;
|
|
234
|
+
}
|
|
235
|
+
function toToml(value) {
|
|
236
|
+
if (typeof value === 'string')
|
|
237
|
+
return JSON.stringify(value);
|
|
238
|
+
if (typeof value === 'number' || typeof value === 'boolean')
|
|
239
|
+
return String(value);
|
|
240
|
+
if (Array.isArray(value))
|
|
241
|
+
return `[${value.map(toToml).join(', ')}]`;
|
|
242
|
+
if (value && typeof value === 'object') {
|
|
243
|
+
const entries = Object.entries(value);
|
|
244
|
+
return entries.length ? `{ ${entries.map(([k, v]) => `${tomlKey(k)} = ${toToml(v)}`).join(', ')} }` : '{}';
|
|
245
|
+
}
|
|
246
|
+
return String(value);
|
|
247
|
+
}
|
|
248
|
+
function tomlKey(key) {
|
|
249
|
+
return /^[A-Za-z0-9_-]+$/.test(key) ? key : JSON.stringify(key);
|
|
250
|
+
}
|
|
251
|
+
function link(text, from, to, anchor) {
|
|
252
|
+
const fromDir = from.split('/').slice(0, -1);
|
|
253
|
+
const toParts = to.split('/');
|
|
254
|
+
let common = 0;
|
|
255
|
+
while (common < fromDir.length && common < toParts.length - 1 && fromDir[common] === toParts[common])
|
|
256
|
+
common++;
|
|
257
|
+
const path = to === from ? '' : [...fromDir.slice(common).map(() => '..'), ...toParts.slice(common)].join('/');
|
|
258
|
+
return `[${text}](${path}${anchor ? `#${anchor}` : ''})`;
|
|
259
|
+
}
|
|
260
|
+
function table(head, rows) {
|
|
261
|
+
const cell = (c) => c.replace(/\n+/g, ' ').replace(/\|/g, '\\|');
|
|
262
|
+
return [`| ${head.map(cell).join(' | ')} |`, `| ${head.map(() => '---').join(' | ')} |`, ...rows.map((r) => `| ${r.map(cell).join(' | ')} |`)].join('\n');
|
|
263
|
+
}
|
|
264
|
+
function code(lang, text) {
|
|
265
|
+
const fence = text.includes('```') ? '````' : '```';
|
|
266
|
+
return `${fence}${lang}\n${text.trimEnd()}\n${fence}`;
|
|
267
|
+
}
|
|
268
|
+
function inlineCode(text) {
|
|
269
|
+
const longest = Math.max(0, ...[...text.matchAll(/`+/g)].map((m) => m[0].length));
|
|
270
|
+
const ticks = '`'.repeat(longest + 1);
|
|
271
|
+
return longest ? `${ticks} ${text} ${ticks}` : `${ticks}${text}${ticks}`;
|
|
272
|
+
}
|
|
273
|
+
function sentence(text) {
|
|
274
|
+
const t = text.trim();
|
|
275
|
+
return t === '' || /[.?!]$/.test(t) ? t : `${t}.`;
|
|
276
|
+
}
|
|
277
|
+
function lowerFirst(text) {
|
|
278
|
+
return /^[A-Z][a-z]/.test(text) ? text[0].toLowerCase() + text.slice(1) : text;
|
|
279
|
+
}
|
|
280
|
+
function plain(markdown) {
|
|
281
|
+
return markdown.replace(/\[([^\]]*)\]\([^)]*\)/g, '$1').replace(/`+([^`]*)`+/g, '$1').replace(/\s+/g, ' ').trim();
|
|
282
|
+
}
|
|
283
|
+
/** The anchor a heading gets, as Starlight's slugger (GitHub's) makes it: lowercase, punctuation dropped, each space a hyphen. */
|
|
284
|
+
function anchorOf(heading) {
|
|
285
|
+
return heading.toLowerCase().replace(/[^\p{L}\p{N}\s_-]/gu, '').replace(/\s/g, '-');
|
|
286
|
+
}
|
|
287
|
+
//# sourceMappingURL=reference.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reference.js","sourceRoot":"","sources":["../../src/plugin/reference.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,OAAO,EAAE,QAAQ,EAAe,MAAM,qBAAqB,CAAA;AAiC3D,MAAM,KAAK,GAAG,oBAAoB,CAAA;AAClC,MAAM,OAAO,GAAG,sBAAsB,CAAA;AACtC,MAAM,MAAM,GAAG,+BAA+B,CAAA;AAC9C,MAAM,KAAK,GAAG,sBAAsB,CAAA;AAEpC,MAAM,MAAM,GAAsC;IAChD,MAAM,EAAE,+EAA+E;IACvF,IAAI,EAAE,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AAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAE,CAAC,WAAW,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAA;AACjF,CAAC;AAED,SAAS,KAAK,CAAC,QAAgB;IAC7B,OAAO,QAAQ,CAAC,OAAO,CAAC,wBAAwB,EAAE,IAAI,CAAC,CAAC,OAAO,CAAC,cAAc,EAAE,IAAI,CAAC,CAAC,OAAO,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,IAAI,EAAE,CAAA;AACnH,CAAC;AAED,kIAAkI;AAClI,SAAS,QAAQ,CAAC,OAAe;IAC/B,OAAO,OAAO,CAAC,WAAW,EAAE,CAAC,OAAO,CAAC,qBAAqB,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAA;AACrF,CAAC"}
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
* - **Each name has one owner**: a block, an inline, the renderer of a node
|
|
8
8
|
* in a format, the reader for a file extension, an output, a command, a
|
|
9
9
|
* matcher, an insert class, a page template, a flow, a line breaker, an
|
|
10
|
-
* asset processor, and the theme. A second claim is an error naming
|
|
10
|
+
* asset processor, an index, and the theme. A second claim is an error naming
|
|
11
11
|
* both, and neither gets the name, so no plugin wins by coming last. The
|
|
12
12
|
* core's own names (`CORE_CLAIMS`) are the core's.
|
|
13
13
|
* - **Lint rules and presets are named `<plugin>/<name>`**, so they can't
|
|
@@ -15,14 +15,18 @@
|
|
|
15
15
|
* - **What accumulates combines by a fixed rule**: penalties at one break
|
|
16
16
|
* add up and a forbidden break stays forbidden (`combinePenalties`);
|
|
17
17
|
* boxes are a set; transforms are ordered by `after` and ids
|
|
18
|
-
* (`runTransforms`); stylesheets go in layers the stylesheet compiler orders
|
|
18
|
+
* (`runTransforms`); stylesheets go in layers the stylesheet compiler orders;
|
|
19
|
+
* hyphenation exceptions for one word break only where every plugin that
|
|
20
|
+
* gives one lets it (`combineExceptions`).
|
|
19
21
|
*/
|
|
20
22
|
import type { RawMatcherFn } from '@vitest/expect';
|
|
21
23
|
import type { PluginDeclarations } from '../config/config.js';
|
|
24
|
+
import type { HyphenationException } from '../hyphenation/exceptions.js';
|
|
22
25
|
import { type Owners } from '../transform/run.js';
|
|
23
26
|
import type { Transform } from '../transform/transform.js';
|
|
27
|
+
import type { PageResolver } from '../layout/converge.js';
|
|
24
28
|
import { type Problem } from '../problem.js';
|
|
25
|
-
import { type AssetProcessor, type CommandDefinition, type
|
|
29
|
+
import { type AssetProcessor, type CommandDefinition, type FlowDefinition, type IndexDefinition, type ElementBreaker, type InsertClassDefinition, type LineBreaker, type LintPreset, type LintRule, type NodeClaim, type OutputDefinition, type PageBuilderHook, type PageTemplateDefinition, type PenaltyRule, type Plugin, type PluginDefinition, type Reader, type RendererSet, type TextRenderer } from './define.js';
|
|
26
30
|
import type { PluginStylesheet, ThemeStylesheet } from '../style/compile.js';
|
|
27
31
|
import type { Output } from '../output/output.js';
|
|
28
32
|
/** Something a plugin contributes, with the plugin it came from. */
|
|
@@ -33,7 +37,7 @@ export interface Owned<T> {
|
|
|
33
37
|
readonly definition: T;
|
|
34
38
|
}
|
|
35
39
|
/** What claims a name: the kinds of duplicate claim. */
|
|
36
|
-
export type ClaimKind = 'plugin' | 'theme' | 'block' | 'inline' | 'renderer' | 'reader' | 'output' | 'command' | 'matcher' | 'insert' | 'page-template' | 'flow' | 'line-breaker' | 'asset-processor';
|
|
40
|
+
export type ClaimKind = 'plugin' | 'theme' | 'block' | 'inline' | 'renderer' | 'reader' | 'output' | 'command' | 'matcher' | 'insert' | 'page-template' | 'flow' | 'line-breaker' | 'element-breaker' | 'asset-processor' | 'index';
|
|
37
41
|
/** The names the core owns, which no plugin may claim. */
|
|
38
42
|
export declare const CORE_CLAIMS: Readonly<Partial<Record<ClaimKind, readonly string[]>>>;
|
|
39
43
|
/**
|
|
@@ -98,15 +102,19 @@ export interface PluginRegistry {
|
|
|
98
102
|
readonly penalties: readonly Owned<PenaltyRule>[];
|
|
99
103
|
/** Every plugin's, sorted, once each. */
|
|
100
104
|
readonly boxes: readonly string[];
|
|
101
|
-
readonly inserts: ReadonlyMap<string, Owned<
|
|
102
|
-
readonly pageTemplates: ReadonlyMap<string, Owned<
|
|
103
|
-
readonly flows: ReadonlyMap<string, Owned<
|
|
105
|
+
readonly inserts: ReadonlyMap<string, Owned<InsertClassDefinition>>;
|
|
106
|
+
readonly pageTemplates: ReadonlyMap<string, Owned<PageTemplateDefinition>>;
|
|
107
|
+
readonly flows: ReadonlyMap<string, Owned<FlowDefinition>>;
|
|
104
108
|
readonly lineBreakers: {
|
|
105
109
|
readonly languages: ReadonlyMap<string, Owned<LineBreaker>>;
|
|
106
110
|
readonly elements: ReadonlyMap<string, Owned<LineBreaker>>;
|
|
107
111
|
};
|
|
112
|
+
/** Element breakers, by selector. */
|
|
113
|
+
readonly elementBreakers: ReadonlyMap<string, Owned<ElementBreaker>>;
|
|
108
114
|
/** By plugin; the page builder (#23) must make what they do order-free. */
|
|
109
115
|
readonly pageBuilder: readonly Owned<PageBuilderHook>[];
|
|
116
|
+
/** Every plugin's, by plugin, in the plugins' order. */
|
|
117
|
+
readonly resolvers: readonly Owned<PageResolver>[];
|
|
110
118
|
};
|
|
111
119
|
/** The plugins' outputs, by the name an edition's `output` gives. */
|
|
112
120
|
readonly outputs: ReadonlyMap<string, Owned<OutputDefinition>>;
|
|
@@ -122,6 +130,14 @@ export interface PluginRegistry {
|
|
|
122
130
|
readonly assets: ReadonlyMap<string, Owned<AssetProcessor>>;
|
|
123
131
|
/** The plugins' `pw` commands, by name. */
|
|
124
132
|
readonly commands: ReadonlyMap<string, Owned<CommandDefinition>>;
|
|
133
|
+
/** The indexes the plugins make, by name. */
|
|
134
|
+
readonly indexes: ReadonlyMap<string, Owned<IndexDefinition>>;
|
|
135
|
+
/**
|
|
136
|
+
* The plugins' hyphenation exceptions, combined: a word that several give
|
|
137
|
+
* for one language breaks only where all of them let it. A project's own
|
|
138
|
+
* file decides over these (`combineExceptions`).
|
|
139
|
+
*/
|
|
140
|
+
readonly hyphenation: readonly HyphenationException[];
|
|
125
141
|
/**
|
|
126
142
|
* The penalty the plugins put at a break by an element: before it, after
|
|
127
143
|
* it, or inside it, every matching rule's combined.
|
|
@@ -136,6 +152,11 @@ export interface PluginRegistry {
|
|
|
136
152
|
* plugin wins by coming last.
|
|
137
153
|
*/
|
|
138
154
|
lineBreakers(element: Element): readonly Owned<LineBreaker>[];
|
|
155
|
+
/**
|
|
156
|
+
* The element breakers whose selector the element matches. More than one
|
|
157
|
+
* is a conflict for the caller to report: no plugin wins by being registered last.
|
|
158
|
+
*/
|
|
159
|
+
elementBreakers(element: Element): readonly Owned<ElementBreaker>[];
|
|
139
160
|
/** What `readConfig` checks the plugins' tables and editions against, by plugin name. */
|
|
140
161
|
declarations(): Record<string, PluginDeclarations>;
|
|
141
162
|
}
|
|
@@ -162,5 +183,16 @@ export declare function registerPlugins(plugins: readonly (Plugin | PluginDefini
|
|
|
162
183
|
registry: PluginRegistry;
|
|
163
184
|
problems: PluginProblem[];
|
|
164
185
|
};
|
|
186
|
+
/** The headings the plugins give their indexes, by name, as the core's `index` transform takes them (`IndexOptions.titles`). */
|
|
187
|
+
export declare function indexTitles(registry: PluginRegistry): Record<string, string>;
|
|
188
|
+
/**
|
|
189
|
+
* Hyphenation exceptions from the project's file and from plugins, as one
|
|
190
|
+
* list: a word the project lists, for any language, is the project's alone;
|
|
191
|
+
* a word several plugins give for one language breaks only where every one
|
|
192
|
+
* of them lets it, as a forbidden break stays forbidden. Words are the same
|
|
193
|
+
* whatever their case, as the hyphenator lower-cases them. No order of the
|
|
194
|
+
* plugins changes the result, which is sorted by language and word.
|
|
195
|
+
*/
|
|
196
|
+
export declare function combineExceptions(project: readonly HyphenationException[], plugins: readonly (readonly HyphenationException[])[]): HyphenationException[];
|
|
165
197
|
/** A registry with no plugins. (Last, after the class it needs.) */
|
|
166
198
|
export declare const EMPTY_REGISTRY: PluginRegistry;
|
package/dist/plugin/register.js
CHANGED
|
@@ -5,6 +5,7 @@ import { CORE_BLOCKS } from '../transform/run.js';
|
|
|
5
5
|
import { withoutClock, withoutClockSync } from '../reproducible/clock.js';
|
|
6
6
|
import { failsAs } from './failure.js';
|
|
7
7
|
import { NOWHERE } from '../problem.js';
|
|
8
|
+
import { SUBJECT_INDEX } from '../profile/profile.js';
|
|
8
9
|
import { definePlugin, PluginError, RENDER_FORMATS, } from './define.js';
|
|
9
10
|
/** The names the core owns, which no plugin may claim. */
|
|
10
11
|
export const CORE_CLAIMS = {
|
|
@@ -19,7 +20,10 @@ export const CORE_CLAIMS = {
|
|
|
19
20
|
command: ['new', 'dev', 'build', 'lint', 'test', 'add', 'convert', 'preflight', 'spike', 'profiles', 'help'],
|
|
20
21
|
// The test API's (test/matchers.ts).
|
|
21
22
|
matcher: ['toBeRecto', 'toFitOnOnePage', 'toStartPage', 'toHaveNoOverfullLines', 'toCite', 'toMatchPageSnapshot', 'toMatchHtmlSnapshot', 'toMatchTextSnapshot'],
|
|
22
|
-
insert: ['footnote'],
|
|
23
|
+
insert: ['footnote', 'top', 'bottom'],
|
|
24
|
+
flow: ['main'],
|
|
25
|
+
// The subject index, which `[text]{index="…"}` and `{.xi}` make.
|
|
26
|
+
index: [SUBJECT_INDEX],
|
|
23
27
|
};
|
|
24
28
|
/** Classes that are edition conditions, whatever node they are on: never a block's or inline's name. */
|
|
25
29
|
const CONDITION = /^(print-only|screen-only|edition-.+)$/;
|
|
@@ -27,7 +31,7 @@ const CONDITION = /^(print-only|screen-only|edition-.+)$/;
|
|
|
27
31
|
const KIND = {
|
|
28
32
|
plugin: 'the plugin name', theme: 'the theme', block: 'the block', inline: 'the inline', renderer: 'the renderer of', reader: 'the reader for',
|
|
29
33
|
output: 'the output', command: 'the command pw', matcher: 'the matcher', insert: 'the insert class', 'page-template': 'the page template',
|
|
30
|
-
flow: 'the flow', 'line-breaker': 'the line breaker for', 'asset-processor': 'the asset processor for',
|
|
34
|
+
flow: 'the flow', 'line-breaker': 'the line breaker for', 'element-breaker': 'the element breaker for', 'asset-processor': 'the asset processor for', index: 'the index',
|
|
31
35
|
};
|
|
32
36
|
/**
|
|
33
37
|
* The selector of the elements a plugin renders, which its stylesheet is
|
|
@@ -116,8 +120,13 @@ export function registerPlugins(plugins, options = {}) {
|
|
|
116
120
|
claims.claim('line-breaker', `language ${lang}`, p.name, at(p.name, 'layout', f));
|
|
117
121
|
for (const [selector, f] of Object.entries(p.layout.lineBreakers.elements))
|
|
118
122
|
claims.claim('line-breaker', `elements ${selector}`, p.name, at(p.name, 'layout', f));
|
|
123
|
+
for (const [selector, f] of Object.entries(p.layout.elementBreakers))
|
|
124
|
+
claims.claim('element-breaker', selector, p.name, at(p.name, 'layout', f));
|
|
119
125
|
for (const [ext, a] of Object.entries(p.assets))
|
|
120
126
|
claims.claim('asset-processor', ext, p.name, { ...a, process: later(p.name, 'assets', a.process) });
|
|
127
|
+
for (const [name, index] of Object.entries(p.indexes)) {
|
|
128
|
+
claims.claim('index', name, p.name, index.lookup ? { ...index, lookup: at(p.name, 'indexes', index.lookup) } : index);
|
|
129
|
+
}
|
|
121
130
|
}
|
|
122
131
|
claims.settle();
|
|
123
132
|
const blocks = claims.owned('block');
|
|
@@ -186,7 +195,9 @@ export function registerPlugins(plugins, options = {}) {
|
|
|
186
195
|
languages: new Map([...claims.owned('line-breaker')].filter(([k]) => k.startsWith('language ')).map(([k, v]) => [k.slice(9), v])),
|
|
187
196
|
elements: new Map([...claims.owned('line-breaker')].filter(([k]) => k.startsWith('elements ')).map(([k, v]) => [k.slice(9), v])),
|
|
188
197
|
},
|
|
198
|
+
elementBreakers: claims.owned('element-breaker'),
|
|
189
199
|
pageBuilder: unique.flatMap((p) => (p.layout.pageBuilder ? [{ plugin: p.name, definition: at(p.name, 'layout', p.layout.pageBuilder) }] : [])),
|
|
200
|
+
resolvers: unique.flatMap((p) => p.layout.resolvers.map((r) => ({ plugin: p.name, definition: at(p.name, 'layout', r) }))),
|
|
190
201
|
},
|
|
191
202
|
outputs: claims.owned('output'),
|
|
192
203
|
lintRules: sortMap(lintRules),
|
|
@@ -194,6 +205,8 @@ export function registerPlugins(plugins, options = {}) {
|
|
|
194
205
|
matchers: Object.fromEntries([...claims.owned('matcher')].map(([name, o]) => [name, o.definition])),
|
|
195
206
|
assets: claims.owned('asset-processor'),
|
|
196
207
|
commands: claims.owned('command'),
|
|
208
|
+
indexes: claims.owned('index'),
|
|
209
|
+
hyphenation: combineExceptions([], unique.map((p) => p.hyphenation)),
|
|
197
210
|
penalty(element, at) {
|
|
198
211
|
return combinePenalties(penalties.filter((r) => r.definition[at] !== undefined && element.matches(r.definition.selector)).map((r) => r.definition[at]));
|
|
199
212
|
},
|
|
@@ -210,6 +223,19 @@ export function registerPlugins(plugins, options = {}) {
|
|
|
210
223
|
}
|
|
211
224
|
return [];
|
|
212
225
|
},
|
|
226
|
+
elementBreakers(element) {
|
|
227
|
+
const matched = [];
|
|
228
|
+
for (const [selector, owned] of registry.layout.elementBreakers) {
|
|
229
|
+
try {
|
|
230
|
+
if (element.matches(selector))
|
|
231
|
+
matched.push(owned);
|
|
232
|
+
}
|
|
233
|
+
catch {
|
|
234
|
+
// A selector that isn't one matches nothing.
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
return matched;
|
|
238
|
+
},
|
|
213
239
|
outputWriters() {
|
|
214
240
|
return Object.fromEntries([...registry.outputs].map(([name, o]) => [name, { name, write: (ctx) => o.definition.write(ctx) }]));
|
|
215
241
|
},
|
|
@@ -220,6 +246,60 @@ export function registerPlugins(plugins, options = {}) {
|
|
|
220
246
|
problems.sort((a, b) => compare(a.plugins.join(), b.plugins.join()) || compare(a.code, b.code) || compare(a.message, b.message));
|
|
221
247
|
return { registry, problems };
|
|
222
248
|
}
|
|
249
|
+
/** The headings the plugins give their indexes, by name, as the core's `index` transform takes them (`IndexOptions.titles`). */
|
|
250
|
+
export function indexTitles(registry) {
|
|
251
|
+
return Object.fromEntries([...registry.indexes].flatMap(([name, o]) => (o.definition.title === undefined ? [] : [[name, o.definition.title.trim()]])));
|
|
252
|
+
}
|
|
253
|
+
/**
|
|
254
|
+
* Hyphenation exceptions from the project's file and from plugins, as one
|
|
255
|
+
* list: a word the project lists, for any language, is the project's alone;
|
|
256
|
+
* a word several plugins give for one language breaks only where every one
|
|
257
|
+
* of them lets it, as a forbidden break stays forbidden. Words are the same
|
|
258
|
+
* whatever their case, as the hyphenator lower-cases them. No order of the
|
|
259
|
+
* plugins changes the result, which is sorted by language and word.
|
|
260
|
+
*/
|
|
261
|
+
export function combineExceptions(project, plugins) {
|
|
262
|
+
const letters = (word) => word.replace(/-/g, '').toLowerCase();
|
|
263
|
+
const own = new Set(project.map((e) => letters(e.word)));
|
|
264
|
+
const byWord = new Map();
|
|
265
|
+
for (const list of plugins) {
|
|
266
|
+
for (const e of list) {
|
|
267
|
+
const l = letters(e.word);
|
|
268
|
+
if (own.has(l))
|
|
269
|
+
continue;
|
|
270
|
+
const lang = e.lang?.toLowerCase();
|
|
271
|
+
const key = `${lang ?? ''} ${l}`;
|
|
272
|
+
const points = new Set(breakPoints(e.word));
|
|
273
|
+
const seen = byWord.get(key);
|
|
274
|
+
if (seen)
|
|
275
|
+
for (const p of seen.points) {
|
|
276
|
+
if (!points.has(p))
|
|
277
|
+
seen.points.delete(p);
|
|
278
|
+
}
|
|
279
|
+
else
|
|
280
|
+
byWord.set(key, { letters: l, ...(lang === undefined ? {} : { lang }), points });
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
const combined = [...byWord.values()].map(({ letters: l, lang, points }) => {
|
|
284
|
+
let word = '';
|
|
285
|
+
for (const [i, c] of [...l].entries())
|
|
286
|
+
word += (points.has(i) ? '-' : '') + c;
|
|
287
|
+
return lang === undefined ? { word } : { word, lang };
|
|
288
|
+
}).sort((a, b) => compare(a.lang ?? '', b.lang ?? '') || compare(a.word, b.word));
|
|
289
|
+
return [...project, ...combined];
|
|
290
|
+
}
|
|
291
|
+
/** Where a word may break, as the number of letters before each hyphen. */
|
|
292
|
+
function breakPoints(word) {
|
|
293
|
+
const points = [];
|
|
294
|
+
let n = 0;
|
|
295
|
+
for (const c of word) {
|
|
296
|
+
if (c === '-')
|
|
297
|
+
points.push(n);
|
|
298
|
+
else
|
|
299
|
+
n++;
|
|
300
|
+
}
|
|
301
|
+
return points;
|
|
302
|
+
}
|
|
223
303
|
/** Claims of names, by kind: each name's claimers, and the problems once all have claimed. */
|
|
224
304
|
class Claims {
|
|
225
305
|
#byKind = new Map();
|
|
@@ -287,6 +367,7 @@ function describe(kind, name) {
|
|
|
287
367
|
case 'reader':
|
|
288
368
|
case 'asset-processor': return `.${name} files`;
|
|
289
369
|
case 'line-breaker': return name.startsWith('language ') ? `the language ${name.slice(9)}` : `the elements ${name.slice(9)}`;
|
|
370
|
+
case 'element-breaker': return name;
|
|
290
371
|
case 'theme': return '';
|
|
291
372
|
default: return name;
|
|
292
373
|
}
|