postext 1.22.3 → 1.24.0
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/__tests__/bundle/bitmapInfo.test.d.ts +2 -0
- package/dist/__tests__/bundle/bitmapInfo.test.d.ts.map +1 -0
- package/dist/__tests__/bundle/bitmapInfo.test.js +78 -0
- package/dist/__tests__/bundle/bitmapInfo.test.js.map +1 -0
- package/dist/__tests__/bundle/designOverflowPin.test.d.ts +2 -0
- package/dist/__tests__/bundle/designOverflowPin.test.d.ts.map +1 -0
- package/dist/__tests__/bundle/designOverflowPin.test.js +87 -0
- package/dist/__tests__/bundle/designOverflowPin.test.js.map +1 -0
- package/dist/__tests__/bundle.test.js +1 -1
- package/dist/__tests__/bundle.test.js.map +1 -1
- package/dist/__tests__/codeBlocks.test.d.ts +2 -0
- package/dist/__tests__/codeBlocks.test.d.ts.map +1 -0
- package/dist/__tests__/codeBlocks.test.js +550 -0
- package/dist/__tests__/codeBlocks.test.js.map +1 -0
- package/dist/__tests__/design/designTextOverflow.test.d.ts +2 -0
- package/dist/__tests__/design/designTextOverflow.test.d.ts.map +1 -0
- package/dist/__tests__/design/designTextOverflow.test.js +102 -0
- package/dist/__tests__/design/designTextOverflow.test.js.map +1 -0
- package/dist/__tests__/exports.test.js +30 -0
- package/dist/__tests__/exports.test.js.map +1 -1
- package/dist/__tests__/frontmatterInvalid.test.d.ts +2 -0
- package/dist/__tests__/frontmatterInvalid.test.d.ts.map +1 -0
- package/dist/__tests__/frontmatterInvalid.test.js +101 -0
- package/dist/__tests__/frontmatterInvalid.test.js.map +1 -0
- package/dist/__tests__/hardBreaks.test.d.ts +2 -0
- package/dist/__tests__/hardBreaks.test.d.ts.map +1 -0
- package/dist/__tests__/hardBreaks.test.js +226 -0
- package/dist/__tests__/hardBreaks.test.js.map +1 -0
- package/dist/__tests__/headingFirstLineIndent.test.d.ts +2 -0
- package/dist/__tests__/headingFirstLineIndent.test.d.ts.map +1 -0
- package/dist/__tests__/headingFirstLineIndent.test.js +185 -0
- package/dist/__tests__/headingFirstLineIndent.test.js.map +1 -0
- package/dist/__tests__/headingInlineMarks.test.js +1 -1
- package/dist/__tests__/headingInlineMarks.test.js.map +1 -1
- package/dist/__tests__/headingLetterSpacing.test.js +1 -1
- package/dist/__tests__/headingLetterSpacing.test.js.map +1 -1
- package/dist/__tests__/lineNumbers.test.d.ts +2 -0
- package/dist/__tests__/lineNumbers.test.d.ts.map +1 -0
- package/dist/__tests__/lineNumbers.test.js +304 -0
- package/dist/__tests__/lineNumbers.test.js.map +1 -0
- package/dist/__tests__/mathSizeMigration.test.js +2 -2
- package/dist/__tests__/mathSizeMigration.test.js.map +1 -1
- package/dist/__tests__/paragraphDropCap.test.d.ts +2 -0
- package/dist/__tests__/paragraphDropCap.test.d.ts.map +1 -0
- package/dist/__tests__/paragraphDropCap.test.js +442 -0
- package/dist/__tests__/paragraphDropCap.test.js.map +1 -0
- package/dist/__tests__/paragraphStyleIndent.test.js +26 -2
- package/dist/__tests__/paragraphStyleIndent.test.js.map +1 -1
- package/dist/__tests__/pipeline/bitmapResolution.test.d.ts +2 -0
- package/dist/__tests__/pipeline/bitmapResolution.test.d.ts.map +1 -0
- package/dist/__tests__/pipeline/bitmapResolution.test.js +139 -0
- package/dist/__tests__/pipeline/bitmapResolution.test.js.map +1 -0
- package/dist/__tests__/pipeline/calloutInlineResourceGap.test.js +1 -1
- package/dist/__tests__/pipeline/calloutInlineResourceGap.test.js.map +1 -1
- package/dist/__tests__/pipeline/calloutSplitMinLinesChild.test.js +1 -1
- package/dist/__tests__/pipeline/calloutSplitMinLinesChild.test.js.map +1 -1
- package/dist/__tests__/pipeline/colonListRoom.test.js +1 -1
- package/dist/__tests__/pipeline/colonListRoom.test.js.map +1 -1
- package/dist/__tests__/pipeline/compoundBreaks.test.js +1 -1
- package/dist/__tests__/pipeline/compoundBreaks.test.js.map +1 -1
- package/dist/__tests__/pipeline/dashBreaks.test.js +1 -1
- package/dist/__tests__/pipeline/dashBreaks.test.js.map +1 -1
- package/dist/__tests__/pipeline/designTextTruncated.test.d.ts +2 -0
- package/dist/__tests__/pipeline/designTextTruncated.test.d.ts.map +1 -0
- package/dist/__tests__/pipeline/designTextTruncated.test.js +116 -0
- package/dist/__tests__/pipeline/designTextTruncated.test.js.map +1 -0
- package/dist/__tests__/pipeline/floatPlacement.test.js +3 -3
- package/dist/__tests__/pipeline/floatPlacement.test.js.map +1 -1
- package/dist/__tests__/pipeline/floatShrink.test.d.ts +2 -0
- package/dist/__tests__/pipeline/floatShrink.test.d.ts.map +1 -0
- package/dist/__tests__/pipeline/floatShrink.test.js +298 -0
- package/dist/__tests__/pipeline/floatShrink.test.js.map +1 -0
- package/dist/__tests__/pipeline/headingSplitOrphans.test.js +1 -1
- package/dist/__tests__/pipeline/headingSplitOrphans.test.js.map +1 -1
- package/dist/__tests__/pipeline/inlineFigureSpace.test.js +1 -1
- package/dist/__tests__/pipeline/inlineFigureSpace.test.js.map +1 -1
- package/dist/__tests__/pipeline/paragraphContainerTail.test.js +1 -1
- package/dist/__tests__/pipeline/paragraphContainerTail.test.js.map +1 -1
- package/dist/__tests__/pipeline/paragraphStyleFaces.test.js +7 -1
- package/dist/__tests__/pipeline/paragraphStyleFaces.test.js.map +1 -1
- package/dist/__tests__/pipeline/raggedOptimal.test.js +1 -1
- package/dist/__tests__/pipeline/raggedOptimal.test.js.map +1 -1
- package/dist/__tests__/pipeline/textWrap.test.d.ts +2 -0
- package/dist/__tests__/pipeline/textWrap.test.d.ts.map +1 -0
- package/dist/__tests__/pipeline/textWrap.test.js +453 -0
- package/dist/__tests__/pipeline/textWrap.test.js.map +1 -0
- package/dist/__tests__/preflight.test.js +30 -1
- package/dist/__tests__/preflight.test.js.map +1 -1
- package/dist/__tests__/presets/showcaseDesignOverflow.test.d.ts +2 -0
- package/dist/__tests__/presets/showcaseDesignOverflow.test.d.ts.map +1 -0
- package/dist/__tests__/presets/showcaseDesignOverflow.test.js +58 -0
- package/dist/__tests__/presets/showcaseDesignOverflow.test.js.map +1 -0
- package/dist/__tests__/tabStops.test.d.ts +2 -0
- package/dist/__tests__/tabStops.test.d.ts.map +1 -0
- package/dist/__tests__/tabStops.test.js +394 -0
- package/dist/__tests__/tabStops.test.js.map +1 -0
- package/dist/__tests__/table/booktabs.test.d.ts +2 -0
- package/dist/__tests__/table/booktabs.test.d.ts.map +1 -0
- package/dist/__tests__/table/booktabs.test.js +290 -0
- package/dist/__tests__/table/booktabs.test.js.map +1 -0
- package/dist/__tests__/textWrapMeasure.test.d.ts +2 -0
- package/dist/__tests__/textWrapMeasure.test.d.ts.map +1 -0
- package/dist/__tests__/textWrapMeasure.test.js +162 -0
- package/dist/__tests__/textWrapMeasure.test.js.map +1 -0
- package/dist/__tests__/verseLines.test.d.ts +2 -0
- package/dist/__tests__/verseLines.test.d.ts.map +1 -0
- package/dist/__tests__/verseLines.test.js +505 -0
- package/dist/__tests__/verseLines.test.js.map +1 -0
- package/dist/bitmapResolution.d.ts +42 -0
- package/dist/bitmapResolution.d.ts.map +1 -0
- package/dist/bitmapResolution.js +82 -0
- package/dist/bitmapResolution.js.map +1 -0
- package/dist/bundle/codec.d.ts +9 -2
- package/dist/bundle/codec.d.ts.map +1 -1
- package/dist/bundle/codec.js +24 -2
- package/dist/bundle/codec.js.map +1 -1
- package/dist/bundle/configVersion.d.ts +119 -8
- package/dist/bundle/configVersion.d.ts.map +1 -1
- package/dist/bundle/configVersion.js +395 -6
- package/dist/bundle/configVersion.js.map +1 -1
- package/dist/bundle/index.d.ts +3 -3
- package/dist/bundle/index.d.ts.map +1 -1
- package/dist/bundle/index.js +2 -2
- package/dist/bundle/index.js.map +1 -1
- package/dist/bundle/manifest.d.ts +12 -2
- package/dist/bundle/manifest.d.ts.map +1 -1
- package/dist/bundle/manifest.js +132 -6
- package/dist/bundle/manifest.js.map +1 -1
- package/dist/bundle/types.d.ts +28 -2
- package/dist/bundle/types.d.ts.map +1 -1
- package/dist/canvas-backend/blockRender.d.ts.map +1 -1
- package/dist/canvas-backend/blockRender.js +45 -9
- package/dist/canvas-backend/blockRender.js.map +1 -1
- package/dist/canvas-backend/index.d.ts.map +1 -1
- package/dist/canvas-backend/index.js +3 -0
- package/dist/canvas-backend/index.js.map +1 -1
- package/dist/canvas-backend/renderResourceBlock.d.ts.map +1 -1
- package/dist/canvas-backend/renderResourceBlock.js +15 -1
- package/dist/canvas-backend/renderResourceBlock.js.map +1 -1
- package/dist/cjkMarks.js +1 -1
- package/dist/cjkMarks.js.map +1 -1
- package/dist/code/highlight.d.ts +34 -0
- package/dist/code/highlight.d.ts.map +1 -0
- package/dist/code/highlight.js +406 -0
- package/dist/code/highlight.js.map +1 -0
- package/dist/configWarnings.d.ts.map +1 -1
- package/dist/configWarnings.js +220 -4
- package/dist/configWarnings.js.map +1 -1
- package/dist/defaults/bodyText.d.ts.map +1 -1
- package/dist/defaults/bodyText.js +25 -0
- package/dist/defaults/bodyText.js.map +1 -1
- package/dist/defaults/calloutStyles.d.ts.map +1 -1
- package/dist/defaults/calloutStyles.js +7 -0
- package/dist/defaults/calloutStyles.js.map +1 -1
- package/dist/defaults/codeStyle.d.ts +29 -0
- package/dist/defaults/codeStyle.d.ts.map +1 -0
- package/dist/defaults/codeStyle.js +284 -0
- package/dist/defaults/codeStyle.js.map +1 -0
- package/dist/defaults/dropCap.d.ts +49 -0
- package/dist/defaults/dropCap.d.ts.map +1 -0
- package/dist/defaults/dropCap.js +66 -0
- package/dist/defaults/dropCap.js.map +1 -0
- package/dist/defaults/headerFooter.d.ts +21 -6
- package/dist/defaults/headerFooter.d.ts.map +1 -1
- package/dist/defaults/headerFooter.js +37 -14
- package/dist/defaults/headerFooter.js.map +1 -1
- package/dist/defaults/headings.d.ts +5 -4
- package/dist/defaults/headings.d.ts.map +1 -1
- package/dist/defaults/headings.js +26 -4
- package/dist/defaults/headings.js.map +1 -1
- package/dist/defaults/index.d.ts +4 -1
- package/dist/defaults/index.d.ts.map +1 -1
- package/dist/defaults/index.js +20 -1
- package/dist/defaults/index.js.map +1 -1
- package/dist/defaults/layout.d.ts +30 -1
- package/dist/defaults/layout.d.ts.map +1 -1
- package/dist/defaults/layout.js +105 -1
- package/dist/defaults/layout.js.map +1 -1
- package/dist/defaults/lineNumbers.d.ts +19 -0
- package/dist/defaults/lineNumbers.d.ts.map +1 -0
- package/dist/defaults/lineNumbers.js +101 -0
- package/dist/defaults/lineNumbers.js.map +1 -0
- package/dist/defaults/paragraphStyles.d.ts.map +1 -1
- package/dist/defaults/paragraphStyles.js +20 -0
- package/dist/defaults/paragraphStyles.js.map +1 -1
- package/dist/defaults/parts.js +4 -4
- package/dist/defaults/parts.js.map +1 -1
- package/dist/defaults/tabStops.d.ts +29 -0
- package/dist/defaults/tabStops.d.ts.map +1 -0
- package/dist/defaults/tabStops.js +94 -0
- package/dist/defaults/tabStops.js.map +1 -0
- package/dist/defaults/tableStyle.d.ts.map +1 -1
- package/dist/defaults/tableStyle.js +44 -0
- package/dist/defaults/tableStyle.js.map +1 -1
- package/dist/defaults/toc.js +2 -2
- package/dist/defaults/verse.d.ts +11 -0
- package/dist/defaults/verse.d.ts.map +1 -0
- package/dist/defaults/verse.js +57 -0
- package/dist/defaults/verse.js.map +1 -0
- package/dist/design/layout.d.ts +15 -1
- package/dist/design/layout.d.ts.map +1 -1
- package/dist/design/layout.js +28 -4
- package/dist/design/layout.js.map +1 -1
- package/dist/fonts/usage.d.ts +7 -0
- package/dist/fonts/usage.d.ts.map +1 -1
- package/dist/fonts/usage.js +71 -0
- package/dist/fonts/usage.js.map +1 -1
- package/dist/frontmatter.d.ts +20 -0
- package/dist/frontmatter.d.ts.map +1 -1
- package/dist/frontmatter.js +69 -3
- package/dist/frontmatter.js.map +1 -1
- package/dist/html-backend.d.ts.map +1 -1
- package/dist/html-backend.js +107 -15
- package/dist/html-backend.js.map +1 -1
- package/dist/index.d.ts +18 -10
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +9 -4
- package/dist/index.js.map +1 -1
- package/dist/measure/bidiLines.d.ts +4 -3
- package/dist/measure/bidiLines.d.ts.map +1 -1
- package/dist/measure/bidiLines.js +14 -9
- package/dist/measure/bidiLines.js.map +1 -1
- package/dist/measure/cache.js +2 -2
- package/dist/measure/cache.js.map +1 -1
- package/dist/measure/cjkCompose.d.ts.map +1 -1
- package/dist/measure/cjkCompose.js +10 -6
- package/dist/measure/cjkCompose.js.map +1 -1
- package/dist/measure/hardBreaks.d.ts +46 -0
- package/dist/measure/hardBreaks.d.ts.map +1 -0
- package/dist/measure/hardBreaks.js +228 -0
- package/dist/measure/hardBreaks.js.map +1 -0
- package/dist/measure/index.d.ts +4 -3
- package/dist/measure/index.d.ts.map +1 -1
- package/dist/measure/index.js +5 -4
- package/dist/measure/index.js.map +1 -1
- package/dist/measure/leader.d.ts +20 -0
- package/dist/measure/leader.d.ts.map +1 -0
- package/dist/measure/leader.js +46 -0
- package/dist/measure/leader.js.map +1 -0
- package/dist/measure/links.js +1 -1
- package/dist/measure/links.js.map +1 -1
- package/dist/measure/plain.d.ts.map +1 -1
- package/dist/measure/plain.js +23 -26
- package/dist/measure/plain.js.map +1 -1
- package/dist/measure/rich.d.ts +19 -0
- package/dist/measure/rich.d.ts.map +1 -1
- package/dist/measure/rich.js +215 -39
- package/dist/measure/rich.js.map +1 -1
- package/dist/measure/tabs.d.ts +103 -0
- package/dist/measure/tabs.d.ts.map +1 -0
- package/dist/measure/tabs.js +123 -0
- package/dist/measure/tabs.js.map +1 -0
- package/dist/measure/types.d.ts +72 -2
- package/dist/measure/types.d.ts.map +1 -1
- package/dist/measure/types.js +87 -3
- package/dist/measure/types.js.map +1 -1
- package/dist/parse/blockParser.d.ts +13 -6
- package/dist/parse/blockParser.d.ts.map +1 -1
- package/dist/parse/blockParser.js +457 -87
- package/dist/parse/blockParser.js.map +1 -1
- package/dist/parse/codeFence.d.ts +18 -0
- package/dist/parse/codeFence.d.ts.map +1 -0
- package/dist/parse/codeFence.js +52 -0
- package/dist/parse/codeFence.js.map +1 -0
- package/dist/parse/index.d.ts +1 -1
- package/dist/parse/index.d.ts.map +1 -1
- package/dist/parse/index.js.map +1 -1
- package/dist/parse/indexMarks.d.ts +3 -1
- package/dist/parse/indexMarks.d.ts.map +1 -1
- package/dist/parse/indexMarks.js +22 -2
- package/dist/parse/indexMarks.js.map +1 -1
- package/dist/parse/inlineFormatting.d.ts +50 -0
- package/dist/parse/inlineFormatting.d.ts.map +1 -1
- package/dist/parse/inlineFormatting.js +94 -0
- package/dist/parse/inlineFormatting.js.map +1 -1
- package/dist/parse/sourceMapping.d.ts.map +1 -1
- package/dist/parse/sourceMapping.js +65 -1
- package/dist/parse/sourceMapping.js.map +1 -1
- package/dist/parse/types.d.ts +144 -9
- package/dist/parse/types.d.ts.map +1 -1
- package/dist/pipeline/build.d.ts.map +1 -1
- package/dist/pipeline/build.js +629 -47
- package/dist/pipeline/build.js.map +1 -1
- package/dist/pipeline/buildBlockKind.d.ts +5 -0
- package/dist/pipeline/buildBlockKind.d.ts.map +1 -1
- package/dist/pipeline/buildBlockKind.js +74 -2
- package/dist/pipeline/buildBlockKind.js.map +1 -1
- package/dist/pipeline/buildHelpers.d.ts +3 -0
- package/dist/pipeline/buildHelpers.d.ts.map +1 -1
- package/dist/pipeline/buildHelpers.js +7 -2
- package/dist/pipeline/buildHelpers.js.map +1 -1
- package/dist/pipeline/buildMeasurement.js +1 -1
- package/dist/pipeline/buildMeasurement.js.map +1 -1
- package/dist/pipeline/calloutLayout.d.ts.map +1 -1
- package/dist/pipeline/calloutLayout.js +33 -2
- package/dist/pipeline/calloutLayout.js.map +1 -1
- package/dist/pipeline/chips.d.ts.map +1 -1
- package/dist/pipeline/chips.js +4 -0
- package/dist/pipeline/chips.js.map +1 -1
- package/dist/pipeline/codeBlocks.d.ts +38 -0
- package/dist/pipeline/codeBlocks.d.ts.map +1 -0
- package/dist/pipeline/codeBlocks.js +146 -0
- package/dist/pipeline/codeBlocks.js.map +1 -0
- package/dist/pipeline/codeInline.d.ts +22 -0
- package/dist/pipeline/codeInline.d.ts.map +1 -0
- package/dist/pipeline/codeInline.js +93 -0
- package/dist/pipeline/codeInline.js.map +1 -0
- package/dist/pipeline/codeLines.d.ts +91 -0
- package/dist/pipeline/codeLines.d.ts.map +1 -0
- package/dist/pipeline/codeLines.js +399 -0
- package/dist/pipeline/codeLines.js.map +1 -0
- package/dist/pipeline/columnBalancing.d.ts.map +1 -1
- package/dist/pipeline/columnBalancing.js +5 -0
- package/dist/pipeline/columnBalancing.js.map +1 -1
- package/dist/pipeline/config.d.ts.map +1 -1
- package/dist/pipeline/config.js +8 -1
- package/dist/pipeline/config.js.map +1 -1
- package/dist/pipeline/contentWarnings.d.ts +25 -0
- package/dist/pipeline/contentWarnings.d.ts.map +1 -1
- package/dist/pipeline/contentWarnings.js +173 -19
- package/dist/pipeline/contentWarnings.js.map +1 -1
- package/dist/pipeline/continuation.d.ts.map +1 -1
- package/dist/pipeline/continuation.js +9 -2
- package/dist/pipeline/continuation.js.map +1 -1
- package/dist/pipeline/dropCap.d.ts +128 -0
- package/dist/pipeline/dropCap.d.ts.map +1 -0
- package/dist/pipeline/dropCap.js +412 -0
- package/dist/pipeline/dropCap.js.map +1 -0
- package/dist/pipeline/floatPlacement.d.ts +34 -4
- package/dist/pipeline/floatPlacement.d.ts.map +1 -1
- package/dist/pipeline/floatPlacement.js +35 -5
- package/dist/pipeline/floatPlacement.js.map +1 -1
- package/dist/pipeline/floatSlots.d.ts +7 -0
- package/dist/pipeline/floatSlots.d.ts.map +1 -1
- package/dist/pipeline/floatSlots.js.map +1 -1
- package/dist/pipeline/hardBreaks.d.ts +19 -0
- package/dist/pipeline/hardBreaks.d.ts.map +1 -0
- package/dist/pipeline/hardBreaks.js +36 -0
- package/dist/pipeline/hardBreaks.js.map +1 -0
- package/dist/pipeline/headerFooter.d.ts +4 -1
- package/dist/pipeline/headerFooter.d.ts.map +1 -1
- package/dist/pipeline/headerFooter.js +23 -6
- package/dist/pipeline/headerFooter.js.map +1 -1
- package/dist/pipeline/lineNumbers.d.ts +37 -0
- package/dist/pipeline/lineNumbers.d.ts.map +1 -0
- package/dist/pipeline/lineNumbers.js +441 -0
- package/dist/pipeline/lineNumbers.js.map +1 -0
- package/dist/pipeline/measureContentBlock.d.ts +38 -5
- package/dist/pipeline/measureContentBlock.d.ts.map +1 -1
- package/dist/pipeline/measureContentBlock.js +284 -69
- package/dist/pipeline/measureContentBlock.js.map +1 -1
- package/dist/pipeline/partPalette.d.ts +1 -1
- package/dist/pipeline/partPalette.d.ts.map +1 -1
- package/dist/pipeline/partPalette.js +24 -2
- package/dist/pipeline/partPalette.js.map +1 -1
- package/dist/pipeline/placement.d.ts.map +1 -1
- package/dist/pipeline/placement.js +7 -0
- package/dist/pipeline/placement.js.map +1 -1
- package/dist/pipeline/resourceLayout.d.ts +15 -0
- package/dist/pipeline/resourceLayout.d.ts.map +1 -1
- package/dist/pipeline/resourceLayout.js +95 -15
- package/dist/pipeline/resourceLayout.js.map +1 -1
- package/dist/pipeline/styles.d.ts +18 -2
- package/dist/pipeline/styles.d.ts.map +1 -1
- package/dist/pipeline/styles.js +23 -8
- package/dist/pipeline/styles.js.map +1 -1
- package/dist/pipeline/tabs.d.ts +35 -0
- package/dist/pipeline/tabs.d.ts.map +1 -0
- package/dist/pipeline/tabs.js +99 -0
- package/dist/pipeline/tabs.js.map +1 -0
- package/dist/pipeline/textWrap.d.ts +94 -0
- package/dist/pipeline/textWrap.d.ts.map +1 -0
- package/dist/pipeline/textWrap.js +188 -0
- package/dist/pipeline/textWrap.js.map +1 -0
- package/dist/pipeline/toc.d.ts.map +1 -1
- package/dist/pipeline/toc.js +3 -38
- package/dist/pipeline/toc.js.map +1 -1
- package/dist/pipeline/verseLines.d.ts +98 -0
- package/dist/pipeline/verseLines.d.ts.map +1 -0
- package/dist/pipeline/verseLines.js +293 -0
- package/dist/pipeline/verseLines.js.map +1 -0
- package/dist/preflight.d.ts +46 -1
- package/dist/preflight.d.ts.map +1 -1
- package/dist/preflight.js +43 -7
- package/dist/preflight.js.map +1 -1
- package/dist/table/booktabs.d.ts +37 -0
- package/dist/table/booktabs.d.ts.map +1 -0
- package/dist/table/booktabs.js +82 -0
- package/dist/table/booktabs.js.map +1 -0
- package/dist/types.d.ts +787 -12
- package/dist/types.d.ts.map +1 -1
- package/dist/vdt.d.ts +367 -9
- package/dist/vdt.d.ts.map +1 -1
- package/dist/vdt.js +9 -2
- package/dist/vdt.js.map +1 -1
- package/dist/word/docxRead.d.ts.map +1 -1
- package/dist/word/docxRead.js +15 -0
- package/dist/word/docxRead.js.map +1 -1
- package/dist/word/index.d.ts +1 -1
- package/dist/word/index.d.ts.map +1 -1
- package/dist/word/index.js +1 -1
- package/dist/word/index.js.map +1 -1
- package/dist/word/inline.d.ts +6 -1
- package/dist/word/inline.d.ts.map +1 -1
- package/dist/word/inline.js +35 -1
- package/dist/word/inline.js.map +1 -1
- package/dist/word/model.d.ts +14 -0
- package/dist/word/model.d.ts.map +1 -1
- package/dist/word/model.js.map +1 -1
- package/dist/word/template.d.ts +12 -3
- package/dist/word/template.d.ts.map +1 -1
- package/dist/word/template.js +13 -3
- package/dist/word/template.js.map +1 -1
- package/dist/word/toDocx.d.ts.map +1 -1
- package/dist/word/toDocx.js +52 -8
- package/dist/word/toDocx.js.map +1 -1
- package/dist/word/toMarkdown.d.ts +15 -1
- package/dist/word/toMarkdown.d.ts.map +1 -1
- package/dist/word/toMarkdown.js +133 -7
- package/dist/word/toMarkdown.js.map +1 -1
- package/dist/word/word.test.js +124 -2
- package/dist/word/word.test.js.map +1 -1
- package/dist/worker/fonts.d.ts +2 -1
- package/dist/worker/fonts.d.ts.map +1 -1
- package/dist/worker/fonts.js +6 -2
- package/dist/worker/fonts.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Verse line by line (#620): a `:::verse` poem whose lines carry no
|
|
3
|
+
* hemistich separator (or `layout="lines"` on its fence), set as it is
|
|
4
|
+
* written. Every source line is a line of verse, a run of blank lines a
|
|
5
|
+
* stanza break, leading whitespace an indent.
|
|
6
|
+
*
|
|
7
|
+
* - Each stanza is a paragraph block of its own (`VerseInfo.stanza`), so a
|
|
8
|
+
* column or page breaks between stanzas by the paragraph rules, and
|
|
9
|
+
* inside one by the orphan and widow rules, which then count the
|
|
10
|
+
* stanza's lines. The space between stanzas is the block's bottom
|
|
11
|
+
* margin (`stanzaSpace`, one line of the poem's leading by default).
|
|
12
|
+
* - A line's indent is its leading spaces × `indentStep` (a tab counts
|
|
13
|
+
* four spaces, an ideographic space two). A stepped line (`+ …`) starts
|
|
14
|
+
* where the line above ended, a word space on.
|
|
15
|
+
* - A line a little wider than the measure tightens its word spaces, down
|
|
16
|
+
* to `bodyText.minWordSpacing` of their natural width (the shrink limit
|
|
17
|
+
* of justified text), and stays on one line (`tighten`, default on); the
|
|
18
|
+
* segments carry the tighter spaces, so every renderer paints them.
|
|
19
|
+
* - A line still wider than the measure turns over: `turnover="hang"` sets the
|
|
20
|
+
* rest on the line after it, `hang` (the style's `hangingIndent`, else
|
|
21
|
+
* `bodyText.verse.hang`) in from the line's own start; `turnover="right"`
|
|
22
|
+
* sets it flush with the end side behind an opening bracket
|
|
23
|
+
* (`turnoverMark`). Turnovers break at word spaces (and hyphenate only
|
|
24
|
+
* when the poem's style asks for hyphenation itself).
|
|
25
|
+
* - `align="center"` (the default in horizontal text) centres the poem as a
|
|
26
|
+
* block on its longest line, every line flush with the block's start;
|
|
27
|
+
* `align="start"` (the default in vertical text, where the poem hangs
|
|
28
|
+
* from the head) sets it flush with the measure's start.
|
|
29
|
+
*
|
|
30
|
+
* The lines carry final segment widths and their own `bbox.x` (the block is
|
|
31
|
+
* set flush left), in the flow frame, as the bayt layout's do
|
|
32
|
+
* (`pipeline/verse.ts`): every renderer paints them as measured. A poem
|
|
33
|
+
* whose direction opposes its frame's (a Latin poem in an Arabic book) is
|
|
34
|
+
* measured from its own start side.
|
|
35
|
+
*/
|
|
36
|
+
import type { ContentBlock, InlineSpan } from '../parse';
|
|
37
|
+
import type { DirectiveAttrs } from '../parse/types';
|
|
38
|
+
import type { ResolvedConfig, VDTLineSegment } from '../vdt';
|
|
39
|
+
import type { MeasuredBlock, MeasurementCache } from '../measure';
|
|
40
|
+
import type { BlockStyle } from './styles';
|
|
41
|
+
/** A poem's line-layout settings, read from its fence over
|
|
42
|
+
* `bodyText.verse`. */
|
|
43
|
+
export interface VerseLinesSettings {
|
|
44
|
+
/** Width of one leading space, px. */
|
|
45
|
+
indentStepPx: number;
|
|
46
|
+
turnover: 'hang' | 'right';
|
|
47
|
+
/** Indent of a hanging turnover from its line's start, px. */
|
|
48
|
+
hangPx: number;
|
|
49
|
+
turnoverMark: string;
|
|
50
|
+
/** Space between two stanzas, px. */
|
|
51
|
+
stanzaSpacePx: number;
|
|
52
|
+
/** Stanzas of this many lines or fewer stay whole; 0: off. */
|
|
53
|
+
keepStanzas: number;
|
|
54
|
+
align: 'center' | 'start';
|
|
55
|
+
/** Whether a line too wide for the measure tightens its word spaces
|
|
56
|
+
* (down to `bodyText.minWordSpacing`) before it turns over. */
|
|
57
|
+
tighten: boolean;
|
|
58
|
+
}
|
|
59
|
+
/** Whether a stanza block is set line by line: a stanza of the line layout,
|
|
60
|
+
* unless the fence named no layout and the configuration was stored
|
|
61
|
+
* before #620 (`bodyText.verse.layout: 'bayt'`), when it is set as single
|
|
62
|
+
* hemistichs, as postext 1.22 set a poem with no separator. */
|
|
63
|
+
export declare function versesLineByLine(raw: ContentBlock, resolved: ResolvedConfig): boolean;
|
|
64
|
+
/** A poem's settings (see {@link VerseLinesSettings}). */
|
|
65
|
+
export declare function verseLinesSettings(attrs: DirectiveAttrs, style: Pick<BlockStyle, 'fontSizePx' | 'lineHeightPx'>, resolved: ResolvedConfig, vertical: boolean): VerseLinesSettings;
|
|
66
|
+
/** A stanza's lines of verse: its spans cut at the line feeds. */
|
|
67
|
+
export declare function stanzaRows(spans: readonly InlineSpan[]): InlineSpan[][];
|
|
68
|
+
export interface VerseLinesInput {
|
|
69
|
+
/** The stanza, its spans resolved for measuring. */
|
|
70
|
+
contentBlock: ContentBlock;
|
|
71
|
+
/** Every stanza of the poem in order, spans resolved likewise; the
|
|
72
|
+
* stanza being set among them (at `contentBlock.verse.stanza.index`). */
|
|
73
|
+
poem: readonly ContentBlock[];
|
|
74
|
+
style: BlockStyle;
|
|
75
|
+
/** The measure, px. */
|
|
76
|
+
measureMaxWidth: number;
|
|
77
|
+
settings: VerseLinesSettings;
|
|
78
|
+
/** The poem's direction and its frame's. */
|
|
79
|
+
direction: 'ltr' | 'rtl';
|
|
80
|
+
frameDirection: 'ltr' | 'rtl';
|
|
81
|
+
/** `bodyText.minWordSpacing`: how far a word space may tighten, as a
|
|
82
|
+
* share of its natural width. */
|
|
83
|
+
minWordSpacing: number;
|
|
84
|
+
cache?: MeasurementCache;
|
|
85
|
+
}
|
|
86
|
+
/** A line's word spaces tightened, down to `minWordSpacing` of their
|
|
87
|
+
* natural width each and in proportion to what each can give, so the
|
|
88
|
+
* line comes to `excess` px narrower; undefined when they cannot give
|
|
89
|
+
* that much. Fixed spaces (a `keepSpaces` caesura) are text and never
|
|
90
|
+
* tighten, nor does a CJK autospace. The segments are copies: the
|
|
91
|
+
* measured line stays as the cache holds it. */
|
|
92
|
+
export declare function tightenedSegments(segments: readonly VDTLineSegment[], excess: number, minWordSpacing: number): {
|
|
93
|
+
segments: VDTLineSegment[];
|
|
94
|
+
ratio: number;
|
|
95
|
+
} | undefined;
|
|
96
|
+
/** Lay a stanza out (see the module comment). */
|
|
97
|
+
export declare function measureVerseLines(input: VerseLinesInput): MeasuredBlock;
|
|
98
|
+
//# sourceMappingURL=verseLines.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"verseLines.d.ts","sourceRoot":"","sources":["../../src/pipeline/verseLines.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AAEH,OAAO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IAC9B,KAAK,EAAE,UAAU,CAAC;IAClB,uBAAuB;IACvB,eAAe,EAAE,MAAM,CAAC;IACxB,QAAQ,EAAE,kBAAkB,CAAC;IAC7B,4CAA4C;IAC5C,SAAS,EAAE,KAAK,GAAG,KAAK,CAAC;IACzB,cAAc,EAAE,KAAK,GAAG,KAAK,CAAC;IAC9B;sCACkC;IAClC,cAAc,EAAE,MAAM,CAAC;IACvB,KAAK,CAAC,EAAE,gBAAgB,CAAC;CAC1B;AAED;;;;;iDAKiD;AACjD,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,SAAS,cAAc,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,GAAG;IAAE,QAAQ,EAAE,cAAc,EAAE,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,GAAG,SAAS,CAmBxK;AAED,iDAAiD;AACjD,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,eAAe,GAAG,aAAa,CA4IvE"}
|
|
@@ -0,0 +1,293 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Verse line by line (#620): a `:::verse` poem whose lines carry no
|
|
3
|
+
* hemistich separator (or `layout="lines"` on its fence), set as it is
|
|
4
|
+
* written. Every source line is a line of verse, a run of blank lines a
|
|
5
|
+
* stanza break, leading whitespace an indent.
|
|
6
|
+
*
|
|
7
|
+
* - Each stanza is a paragraph block of its own (`VerseInfo.stanza`), so a
|
|
8
|
+
* column or page breaks between stanzas by the paragraph rules, and
|
|
9
|
+
* inside one by the orphan and widow rules, which then count the
|
|
10
|
+
* stanza's lines. The space between stanzas is the block's bottom
|
|
11
|
+
* margin (`stanzaSpace`, one line of the poem's leading by default).
|
|
12
|
+
* - A line's indent is its leading spaces × `indentStep` (a tab counts
|
|
13
|
+
* four spaces, an ideographic space two). A stepped line (`+ …`) starts
|
|
14
|
+
* where the line above ended, a word space on.
|
|
15
|
+
* - A line a little wider than the measure tightens its word spaces, down
|
|
16
|
+
* to `bodyText.minWordSpacing` of their natural width (the shrink limit
|
|
17
|
+
* of justified text), and stays on one line (`tighten`, default on); the
|
|
18
|
+
* segments carry the tighter spaces, so every renderer paints them.
|
|
19
|
+
* - A line still wider than the measure turns over: `turnover="hang"` sets the
|
|
20
|
+
* rest on the line after it, `hang` (the style's `hangingIndent`, else
|
|
21
|
+
* `bodyText.verse.hang`) in from the line's own start; `turnover="right"`
|
|
22
|
+
* sets it flush with the end side behind an opening bracket
|
|
23
|
+
* (`turnoverMark`). Turnovers break at word spaces (and hyphenate only
|
|
24
|
+
* when the poem's style asks for hyphenation itself).
|
|
25
|
+
* - `align="center"` (the default in horizontal text) centres the poem as a
|
|
26
|
+
* block on its longest line, every line flush with the block's start;
|
|
27
|
+
* `align="start"` (the default in vertical text, where the poem hangs
|
|
28
|
+
* from the head) sets it flush with the measure's start.
|
|
29
|
+
*
|
|
30
|
+
* The lines carry final segment widths and their own `bbox.x` (the block is
|
|
31
|
+
* set flush left), in the flow frame, as the bayt layout's do
|
|
32
|
+
* (`pipeline/verse.ts`): every renderer paints them as measured. A poem
|
|
33
|
+
* whose direction opposes its frame's (a Latin poem in an Arabic book) is
|
|
34
|
+
* measured from its own start side.
|
|
35
|
+
*/
|
|
36
|
+
import { createBoundingBox } from '../vdt';
|
|
37
|
+
import { measureRichBlock } from '../measure';
|
|
38
|
+
import { cachedMeasureRichBlock } from '../measure/cache';
|
|
39
|
+
import { pickSpanFont, textWidth } from '../measure/rich';
|
|
40
|
+
import { normalSpaceWidthFor } from '../measure/canvas';
|
|
41
|
+
import { lineBaselineOffset } from '../measure/vertical';
|
|
42
|
+
import { sliceSpan } from '../parse/links';
|
|
43
|
+
import { dimensionToPx } from '../units';
|
|
44
|
+
import { lengthAttr } from './verse';
|
|
45
|
+
/** Measure a line of verse on one line. */
|
|
46
|
+
const ONE_LINE = 1e7;
|
|
47
|
+
/** Whether a stanza block is set line by line: a stanza of the line layout,
|
|
48
|
+
* unless the fence named no layout and the configuration was stored
|
|
49
|
+
* before #620 (`bodyText.verse.layout: 'bayt'`), when it is set as single
|
|
50
|
+
* hemistichs, as postext 1.22 set a poem with no separator. */
|
|
51
|
+
export function versesLineByLine(raw, resolved) {
|
|
52
|
+
const stanza = raw.verse?.stanza;
|
|
53
|
+
return stanza !== undefined && !(stanza.auto && resolved.bodyText.verse.layout === 'bayt');
|
|
54
|
+
}
|
|
55
|
+
/** `tighten=false` / `tighten=true` on a fence; undefined when absent or
|
|
56
|
+
* neither. */
|
|
57
|
+
function switchAttr(value) {
|
|
58
|
+
const v = value?.trim().toLowerCase();
|
|
59
|
+
return v === 'true' || v === '' ? true : v === 'false' ? false : undefined;
|
|
60
|
+
}
|
|
61
|
+
/** A whole number of lines or none (`keepStanzas=5`). */
|
|
62
|
+
function countAttr(value) {
|
|
63
|
+
const m = /^\s*(\d+)\s*$/.exec(value ?? '');
|
|
64
|
+
return m ? Number(m[1]) : undefined;
|
|
65
|
+
}
|
|
66
|
+
/** The space between stanzas a fence asks for: a bare number counts lines
|
|
67
|
+
* of the poem's leading (`stanzaSpace=0.5`), a length is that length
|
|
68
|
+
* (`stanzaSpace=6pt`). */
|
|
69
|
+
function stanzaSpaceAttr(value, lineHeightPx, dpi, fontSizePx) {
|
|
70
|
+
const v = value?.trim();
|
|
71
|
+
if (!v)
|
|
72
|
+
return undefined;
|
|
73
|
+
if (/^(\d+(?:\.\d+)?|\.\d+)$/.test(v))
|
|
74
|
+
return Number(v) * lineHeightPx;
|
|
75
|
+
return lengthAttr(v, dpi, fontSizePx);
|
|
76
|
+
}
|
|
77
|
+
/** The hanging indent of the paragraph style a poem's fence names, px;
|
|
78
|
+
* undefined when it names none, or one that sets none. */
|
|
79
|
+
function styleHangPx(attrs, resolved, fontSizePx) {
|
|
80
|
+
const id = attrs.style?.trim();
|
|
81
|
+
if (!id)
|
|
82
|
+
return undefined;
|
|
83
|
+
const cfg = resolved.paragraphStyles.find((s) => s.id === id);
|
|
84
|
+
if (!cfg)
|
|
85
|
+
return undefined;
|
|
86
|
+
const px = dimensionToPx(cfg.hangingIndent, resolved.page.dpi, fontSizePx);
|
|
87
|
+
return px > 0 ? px : undefined;
|
|
88
|
+
}
|
|
89
|
+
/** A poem's settings (see {@link VerseLinesSettings}). */
|
|
90
|
+
export function verseLinesSettings(attrs, style, resolved, vertical) {
|
|
91
|
+
const cfg = resolved.bodyText.verse;
|
|
92
|
+
const dpi = resolved.page.dpi;
|
|
93
|
+
const em = style.fontSizePx;
|
|
94
|
+
const turnover = attrs.turnover?.trim();
|
|
95
|
+
const align = attrs.align?.trim();
|
|
96
|
+
return {
|
|
97
|
+
indentStepPx: Math.max(0, lengthAttr(attrs.indentStep, dpi, em) ?? dimensionToPx(cfg.indentStep, dpi, em)),
|
|
98
|
+
turnover: turnover === 'right' || turnover === 'hang' ? turnover : cfg.turnover,
|
|
99
|
+
hangPx: Math.max(0, lengthAttr(attrs.hang, dpi, em) ?? styleHangPx(attrs, resolved, em) ?? dimensionToPx(cfg.hang, dpi, em)),
|
|
100
|
+
turnoverMark: attrs.turnoverMark ?? cfg.turnoverMark,
|
|
101
|
+
stanzaSpacePx: Math.max(0, stanzaSpaceAttr(attrs.stanzaSpace, style.lineHeightPx, dpi, em) ?? cfg.stanzaSpace * style.lineHeightPx),
|
|
102
|
+
keepStanzas: countAttr(attrs.keepStanzas) ?? cfg.keepStanzas,
|
|
103
|
+
align: align === 'start' || align === 'center' ? align : vertical ? 'start' : 'center',
|
|
104
|
+
tighten: switchAttr(attrs.tighten) ?? cfg.tighten,
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
/** A stanza's lines of verse: its spans cut at the line feeds. */
|
|
108
|
+
export function stanzaRows(spans) {
|
|
109
|
+
const rows = [[]];
|
|
110
|
+
for (const span of spans) {
|
|
111
|
+
let from = 0;
|
|
112
|
+
for (let i = 0; i <= span.text.length; i++) {
|
|
113
|
+
if (i < span.text.length && span.text[i] !== '\n')
|
|
114
|
+
continue;
|
|
115
|
+
if (i > from)
|
|
116
|
+
rows[rows.length - 1].push(sliceSpan(span, from, i));
|
|
117
|
+
if (i < span.text.length)
|
|
118
|
+
rows.push([]);
|
|
119
|
+
from = i + 1;
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
return rows;
|
|
123
|
+
}
|
|
124
|
+
/** A line's word spaces tightened, down to `minWordSpacing` of their
|
|
125
|
+
* natural width each and in proportion to what each can give, so the
|
|
126
|
+
* line comes to `excess` px narrower; undefined when they cannot give
|
|
127
|
+
* that much. Fixed spaces (a `keepSpaces` caesura) are text and never
|
|
128
|
+
* tighten, nor does a CJK autospace. The segments are copies: the
|
|
129
|
+
* measured line stays as the cache holds it. */
|
|
130
|
+
export function tightenedSegments(segments, excess, minWordSpacing) {
|
|
131
|
+
const floor = Math.max(0, Math.min(1, minWordSpacing));
|
|
132
|
+
const give = (seg) => (seg.kind === 'space' && !seg.autospace && !seg.labelTab ? Math.max(0, seg.width * (1 - floor)) : 0);
|
|
133
|
+
let natural = 0;
|
|
134
|
+
let shrinkable = 0;
|
|
135
|
+
for (const seg of segments) {
|
|
136
|
+
const g = give(seg);
|
|
137
|
+
if (g > 0) {
|
|
138
|
+
natural += seg.width;
|
|
139
|
+
shrinkable += g;
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
if (excess <= 0 || shrinkable <= 0 || excess > shrinkable + 1e-6)
|
|
143
|
+
return undefined;
|
|
144
|
+
const share = Math.min(1, excess / shrinkable);
|
|
145
|
+
const out = segments.map((seg) => {
|
|
146
|
+
const g = give(seg);
|
|
147
|
+
return g > 0 ? { ...seg, width: seg.width - g * share } : seg;
|
|
148
|
+
});
|
|
149
|
+
return { segments: out, ratio: (natural - shrinkable * share) / natural };
|
|
150
|
+
}
|
|
151
|
+
/** Lay a stanza out (see the module comment). */
|
|
152
|
+
export function measureVerseLines(input) {
|
|
153
|
+
const { contentBlock, style, measureMaxWidth: measure, settings, direction } = input;
|
|
154
|
+
const stanza = contentBlock.verse?.stanza;
|
|
155
|
+
if (!stanza)
|
|
156
|
+
return { lines: [], totalHeight: 0 };
|
|
157
|
+
const fonts = {
|
|
158
|
+
normal: style.fontString,
|
|
159
|
+
bold: style.boldFontString ?? style.fontString,
|
|
160
|
+
italic: style.italicFontString ?? style.fontString,
|
|
161
|
+
boldItalic: style.boldItalicFontString ?? style.fontString,
|
|
162
|
+
};
|
|
163
|
+
const lineHeight = style.lineHeightPx;
|
|
164
|
+
const base = {
|
|
165
|
+
textAlign: 'left',
|
|
166
|
+
direction,
|
|
167
|
+
hyphenate: style.hyphenate,
|
|
168
|
+
...(style.hyphenationZonePx !== undefined ? { hyphenationZonePx: style.hyphenationZonePx } : {}),
|
|
169
|
+
};
|
|
170
|
+
const measureSpans = (spans, width, options) => (input.cache
|
|
171
|
+
? cachedMeasureRichBlock(spans, fonts.normal, fonts.bold, fonts.italic, fonts.boldItalic, width, lineHeight, options, input.cache)
|
|
172
|
+
: measureRichBlock(spans, fonts.normal, fonts.bold, fonts.italic, fonts.boldItalic, width, lineHeight, options)).lines;
|
|
173
|
+
const widthOf = (line) => (line?.segments ?? []).reduce((s, seg) => s + seg.width, 0);
|
|
174
|
+
const space = normalSpaceWidthFor(fonts.normal);
|
|
175
|
+
// How a line too wide for the measure is broken: at word spaces, the
|
|
176
|
+
// turnovers in from its start (`hang`), or set behind the mark flush
|
|
177
|
+
// with the end side (`right`).
|
|
178
|
+
const markSeg = () => {
|
|
179
|
+
const seg = { kind: 'text', text: settings.turnoverMark, width: 0, inserted: true };
|
|
180
|
+
seg.width = textWidth(seg.text, pickSpanFont(false, false, fonts.normal, fonts.bold, fonts.italic, fonts.boldItalic), false);
|
|
181
|
+
return seg;
|
|
182
|
+
};
|
|
183
|
+
const turnoverLines = (spans, indent) => {
|
|
184
|
+
const room = Math.max(1, measure - indent);
|
|
185
|
+
const rest = settings.turnover === 'right'
|
|
186
|
+
? Math.min(markSeg().width + space, room / 2)
|
|
187
|
+
: Math.min(settings.hangPx, room / 2);
|
|
188
|
+
return measureSpans(spans, room, { ...base, lineIndentsPx: [0, rest] });
|
|
189
|
+
};
|
|
190
|
+
/** Where a too-wide line's last turnover ends, from the poem's start. */
|
|
191
|
+
const endOfTurnover = (spans, indent) => {
|
|
192
|
+
const lines = turnoverLines(spans, indent);
|
|
193
|
+
const last = lines[lines.length - 1];
|
|
194
|
+
if (!last || lines.length < 2)
|
|
195
|
+
return Math.min(measure, indent + widthOf(last));
|
|
196
|
+
return settings.turnover === 'right' ? measure : indent + last.bbox.x + widthOf(last);
|
|
197
|
+
};
|
|
198
|
+
const rows = [];
|
|
199
|
+
let prevEnd = 0;
|
|
200
|
+
for (const block of input.poem) {
|
|
201
|
+
const st = block.verse?.stanza;
|
|
202
|
+
if (!st)
|
|
203
|
+
continue;
|
|
204
|
+
stanzaRows(block.spans).forEach((spans, i) => {
|
|
205
|
+
const info = st.lines[i] ?? { indent: 0 };
|
|
206
|
+
const line = measureSpans(spans, ONE_LINE, base)[0];
|
|
207
|
+
let width = widthOf(line);
|
|
208
|
+
// An indent past half the measure would leave its turnovers no room.
|
|
209
|
+
let indent = Math.min(info.indent * settings.indentStepPx, measure / 2);
|
|
210
|
+
if (info.stepped && rows.length > 0)
|
|
211
|
+
indent = Math.max(0, Math.min(prevEnd + space, measure - width));
|
|
212
|
+
const tight = settings.tighten && line && indent + width > measure + 0.01
|
|
213
|
+
? tightenedSegments(line.segments ?? [], indent + width - measure, input.minWordSpacing)
|
|
214
|
+
: undefined;
|
|
215
|
+
if (tight)
|
|
216
|
+
width = measure - indent;
|
|
217
|
+
rows.push({ spans, line, width, indent, stanza: st.index, ...(tight ? { tight } : {}) });
|
|
218
|
+
prevEnd = indent + width <= measure + 0.01 ? indent + width : endOfTurnover(spans, indent);
|
|
219
|
+
});
|
|
220
|
+
}
|
|
221
|
+
// The poem's block: as wide as its longest line (the measure when one
|
|
222
|
+
// turns over), centred or flush with the start.
|
|
223
|
+
const poemWidth = rows.reduce((w, r) => Math.max(w, Math.min(measure, r.indent + r.width)), 0);
|
|
224
|
+
const x0 = settings.align === 'center' ? Math.max(0, (measure - poemWidth) / 2) : 0;
|
|
225
|
+
const same = direction === input.frameDirection;
|
|
226
|
+
/** Flow x of a line `width` wide starting `start` px from the poem's
|
|
227
|
+
* start side. */
|
|
228
|
+
const place = (start, width) => (same ? start : Math.max(0, measure - start - width));
|
|
229
|
+
const baselineOffset = lineBaselineOffset(lineHeight, fonts.normal);
|
|
230
|
+
const lines = [];
|
|
231
|
+
const push = (line, segments, start, verseLine) => {
|
|
232
|
+
const y = lines.length * lineHeight;
|
|
233
|
+
const width = segments.reduce((s, seg) => s + seg.width, 0);
|
|
234
|
+
const { verse: _bayt, measure: _measure, isLastLine: _last, ...rest } = line;
|
|
235
|
+
void _bayt;
|
|
236
|
+
void _measure;
|
|
237
|
+
void _last;
|
|
238
|
+
lines.push({
|
|
239
|
+
...rest,
|
|
240
|
+
segments,
|
|
241
|
+
bbox: createBoundingBox(place(start, width), y, width, lineHeight),
|
|
242
|
+
baseline: y + baselineOffset,
|
|
243
|
+
isLastLine: false,
|
|
244
|
+
verseLine,
|
|
245
|
+
});
|
|
246
|
+
};
|
|
247
|
+
rows.forEach((row, i) => {
|
|
248
|
+
if (row.stanza !== stanza.index)
|
|
249
|
+
return;
|
|
250
|
+
const verseLine = (turnover) => ({ stanza: stanza.index, line: i, turnover, ...(!turnover && row.indent > 0 ? { indent: row.indent } : {}) });
|
|
251
|
+
if (row.tight && row.line) {
|
|
252
|
+
push(row.line, row.tight.segments, x0 + row.indent, { ...verseLine(false), spaceRatio: row.tight.ratio });
|
|
253
|
+
return;
|
|
254
|
+
}
|
|
255
|
+
if (row.indent + row.width <= measure + 0.01) {
|
|
256
|
+
const line = row.line;
|
|
257
|
+
if (line)
|
|
258
|
+
push(line, line.segments ?? [], x0 + row.indent, verseLine(false));
|
|
259
|
+
return;
|
|
260
|
+
}
|
|
261
|
+
// Turned over: the block spans the measure (x0 is 0).
|
|
262
|
+
turnoverLines(row.spans, row.indent).forEach((line, k) => {
|
|
263
|
+
const segments = line.segments ?? [];
|
|
264
|
+
if (k === 0) {
|
|
265
|
+
push(line, segments, row.indent, verseLine(false));
|
|
266
|
+
}
|
|
267
|
+
else if (settings.turnover === 'right') {
|
|
268
|
+
// Flush with the end side, behind the mark, which stands on the
|
|
269
|
+
// turnover's start side (the left of a left-to-right poem).
|
|
270
|
+
const marked = [markSeg(), ...segments];
|
|
271
|
+
const width = marked.reduce((s, seg) => s + seg.width, 0);
|
|
272
|
+
const inner = line.order && line.order.length === segments.length ? line.order.map((o) => o + 1) : segments.map((_, j) => j + 1);
|
|
273
|
+
const order = direction === 'rtl' ? [...inner, 0] : [0, ...inner];
|
|
274
|
+
const { order: _order, ...unordered } = line;
|
|
275
|
+
void _order;
|
|
276
|
+
push(order.every((v, j) => v === j) ? unordered : { ...unordered, order }, marked, Math.max(row.indent, measure - width), verseLine(true));
|
|
277
|
+
}
|
|
278
|
+
else {
|
|
279
|
+
push(line, segments, row.indent + line.bbox.x, verseLine(true));
|
|
280
|
+
}
|
|
281
|
+
});
|
|
282
|
+
});
|
|
283
|
+
// The last line of a stanza another follows: copied text leaves a blank
|
|
284
|
+
// line under it.
|
|
285
|
+
if (lines.length > 0) {
|
|
286
|
+
const last = lines[lines.length - 1];
|
|
287
|
+
last.isLastLine = true;
|
|
288
|
+
if (!stanza.last)
|
|
289
|
+
last.verseLine = { ...last.verseLine, stanzaEnd: true };
|
|
290
|
+
}
|
|
291
|
+
return { lines, totalHeight: lines.length * lineHeight };
|
|
292
|
+
}
|
|
293
|
+
//# sourceMappingURL=verseLines.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"verseLines.js","sourceRoot":"","sources":["../../src/pipeline/verseLines.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AAKH,OAAO,EAAE,iBAAiB,EAAE,MAAM,QAAQ,CAAC;AAE3C,OAAO,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAC9C,OAAO,EAAE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printed size (pixels per
|
|
8
8
|
* inch, crop included) falls under `print.preflight.minImageResolution`
|
|
9
9
|
* (critical under `criticalImageResolution`): figures, table-cell
|
|
10
|
-
* pictures, design images, comic panels.
|
|
10
|
+
* pictures, design images, comic panels. The pixels are the file's when
|
|
11
|
+
* the host knows them (`imageSize`), else the resource's declaration.
|
|
12
|
+
* - Bitmaps whose declared pixel size and file disagree (#631).
|
|
11
13
|
* - RGB pictures in a CMYK job (converted on export, or kept RGB by a
|
|
12
14
|
* PDF/X-4 that does not convert them), when the host says which
|
|
13
15
|
* pictures are RGB (`imageColor`).
|
|
@@ -36,6 +38,23 @@ export type PreflightIssue = {
|
|
|
36
38
|
resourceId?: string;
|
|
37
39
|
ppi: number;
|
|
38
40
|
minimum: number;
|
|
41
|
+
}
|
|
42
|
+
/** A bitmap that declares a pixel size its file does not have (more
|
|
43
|
+
* than a pixel off either way): its print size and resolution are
|
|
44
|
+
* worked out from the declaration. Reported once, where it is first
|
|
45
|
+
* placed; `warning` when the declaration exceeds the file. */
|
|
46
|
+
| {
|
|
47
|
+
kind: 'declaredPixelsMismatch';
|
|
48
|
+
fileId: string;
|
|
49
|
+
resourceId?: string;
|
|
50
|
+
declared: {
|
|
51
|
+
width: number;
|
|
52
|
+
height: number;
|
|
53
|
+
};
|
|
54
|
+
actual: {
|
|
55
|
+
width: number;
|
|
56
|
+
height: number;
|
|
57
|
+
};
|
|
39
58
|
} | {
|
|
40
59
|
kind: 'rgbImage';
|
|
41
60
|
fileId: string;
|
|
@@ -79,11 +98,37 @@ export interface PreflightOptions {
|
|
|
79
98
|
* coverage exactly. Without it a neutral counts one ink and any other
|
|
80
99
|
* colour three, and coverage is not checked. */
|
|
81
100
|
transform?: OutputTransform;
|
|
101
|
+
/** The real pixel size of a bitmap's file (the decoded image, or
|
|
102
|
+
* `bitmapInfo` on its bytes), when the host knows it: the resolution is
|
|
103
|
+
* worked out from it, and a declaration that disagrees is reported
|
|
104
|
+
* (`declaredPixelsMismatch`). */
|
|
105
|
+
imageSize?: (fileId: string) => {
|
|
106
|
+
width: number;
|
|
107
|
+
height: number;
|
|
108
|
+
} | undefined;
|
|
82
109
|
/** Whether a picture's file is RGB, CMYK or gray (from its bytes). */
|
|
83
110
|
imageColor?: (fileId: string) => 'rgb' | 'cmyk' | 'gray' | undefined;
|
|
84
111
|
/** The job is CMYK (a PDF/X standard, or a CMYK PDF). Defaults to true
|
|
85
112
|
* when a PDF/X standard is set. */
|
|
86
113
|
cmyk?: boolean;
|
|
87
114
|
}
|
|
115
|
+
/** One placed bitmap and its effective resolution there (#631): the
|
|
116
|
+
* file's pixels shown (crop and safe area counted) over its printed size
|
|
117
|
+
* in inches, the smaller of the two axes. */
|
|
118
|
+
export interface PlacedImageResolution {
|
|
119
|
+
fileId: string;
|
|
120
|
+
resourceId?: string;
|
|
121
|
+
/** Book-absolute page index. */
|
|
122
|
+
pageIndex: number;
|
|
123
|
+
ppi: number;
|
|
124
|
+
/** Printed size, layout px. */
|
|
125
|
+
width: number;
|
|
126
|
+
height: number;
|
|
127
|
+
}
|
|
128
|
+
/** Every bitmap placed in `doc` with its effective resolution: figures,
|
|
129
|
+
* table-cell pictures, design images and comic panels, one entry per
|
|
130
|
+
* placement. Uses `options.resources` and `options.imageSize` as
|
|
131
|
+
* {@link preflightDocument} does; runs whether or not preflight is on. */
|
|
132
|
+
export declare function placedImageResolutions(doc: VDTDocument, options?: Pick<PreflightOptions, 'resources' | 'imageSize'>): PlacedImageResolution[];
|
|
88
133
|
export declare function preflightDocument(doc: VDTDocument, options?: PreflightOptions): PreflightIssue[];
|
|
89
134
|
//# sourceMappingURL=preflight.d.ts.map
|
package/dist/preflight.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"preflight.d.ts","sourceRoot":"","sources":["../src/preflight.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"preflight.d.ts","sourceRoot":"","sources":["../src/preflight.ts"],"names":[],"mappings":"AAAA;;;;;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O,CAAC;CAChB;AAqCD;;8CAE8C;AAC9C,MAAM,WAAW,qBAAqB;IACpC,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,gCAAgC;IAChC,SAAS,EAAE,MAAM,CAAC;IAClB,GAAG,EAAE,MAAM,CAAC;IACZ,+BAA+B;IAC/B,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;CAChB;AAED;;;2EAG2E;AAC3E,wBAAgB,sBAAsB,CAAC,GAAG,EAAE,WAAW,EAAE,OAAO,GAAE,IAAI,CAAC,gBAAgB,EAAE,WAAW,GAAG,WAAW,CAAM,GAAG,qBAAqB,EAAE,CAIjJ;AAED,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,WAAW,EAAE,OAAO,GAAE,gBAAqB,GAAG,cAAc,EAAE,CAEpG"}
|
package/dist/preflight.js
CHANGED
|
@@ -7,7 +7,9 @@
|
|
|
7
7
|
* - Pictures whose effective resolution at their printed size (pixels per
|
|
8
8
|
* inch, crop included) falls under `print.preflight.minImageResolution`
|
|
9
9
|
* (critical under `criticalImageResolution`): figures, table-cell
|
|
10
|
-
* pictures, design images, comic panels.
|
|
10
|
+
* pictures, design images, comic panels. The pixels are the file's when
|
|
11
|
+
* the host knows them (`imageSize`), else the resource's declaration.
|
|
12
|
+
* - Bitmaps whose declared pixel size and file disagree (#631).
|
|
11
13
|
* - RGB pictures in a CMYK job (converted on export, or kept RGB by a
|
|
12
14
|
* PDF/X-4 that does not convert them), when the host says which
|
|
13
15
|
* pictures are RGB (`imageColor`).
|
|
@@ -59,10 +61,22 @@ function bitmapSizes(doc, resources) {
|
|
|
59
61
|
note(f.resourceBlock?.resource);
|
|
60
62
|
return out;
|
|
61
63
|
}
|
|
64
|
+
/** Every bitmap placed in `doc` with its effective resolution: figures,
|
|
65
|
+
* table-cell pictures, design images and comic panels, one entry per
|
|
66
|
+
* placement. Uses `options.resources` and `options.imageSize` as
|
|
67
|
+
* {@link preflightDocument} does; runs whether or not preflight is on. */
|
|
68
|
+
export function placedImageResolutions(doc, options = {}) {
|
|
69
|
+
const placed = [];
|
|
70
|
+
runPreflight(doc, { ...options, print: undefined }, placed);
|
|
71
|
+
return placed;
|
|
72
|
+
}
|
|
62
73
|
export function preflightDocument(doc, options = {}) {
|
|
74
|
+
return runPreflight(doc, options);
|
|
75
|
+
}
|
|
76
|
+
function runPreflight(doc, options, placed) {
|
|
63
77
|
const print = options.print ?? doc.config.print ?? resolvePrintConfig();
|
|
64
78
|
const pf = print.preflight;
|
|
65
|
-
if (!pf.enabled)
|
|
79
|
+
if (!pf.enabled && !placed)
|
|
66
80
|
return [];
|
|
67
81
|
const dpi = doc.config.page.dpi;
|
|
68
82
|
const pxToPt = (px) => (px / dpi) * 72;
|
|
@@ -112,14 +126,31 @@ export function preflightDocument(doc, options = {}) {
|
|
|
112
126
|
out.push({ kind: 'inkLimit', severity: 'warning', pageIndex, color: hex, coverage: Math.round(coverage), limit: print.inkLimit, ...(rect ? { rect } : {}) });
|
|
113
127
|
}
|
|
114
128
|
};
|
|
129
|
+
// The file's pixels against the declaration, once per file.
|
|
130
|
+
const mismatchSeen = new Set();
|
|
115
131
|
const checkImage = (fileId, placedW, placedH, fracW, fracH, pageIndex, rect, resourceId, src) => {
|
|
116
132
|
if (!fileId)
|
|
117
133
|
return;
|
|
118
|
-
const
|
|
134
|
+
const declared = sizes.get(fileId);
|
|
135
|
+
const real = options.imageSize?.(fileId);
|
|
136
|
+
const actual = real && real.width > 0 && real.height > 0 ? { w: real.width, h: real.height } : undefined;
|
|
137
|
+
const size = actual ?? declared;
|
|
119
138
|
const source = src?.start !== undefined ? { sourceStart: src.start, ...(src.end !== undefined ? { sourceEnd: src.end } : {}) } : {};
|
|
120
|
-
const rid = resourceId ??
|
|
139
|
+
const rid = resourceId ?? declared?.id;
|
|
140
|
+
if (pf.enabled && declared && actual && !mismatchSeen.has(fileId) && (Math.abs(declared.w - actual.w) > 1 || Math.abs(declared.h - actual.h) > 1)) {
|
|
141
|
+
mismatchSeen.add(fileId);
|
|
142
|
+
const over = declared.w > actual.w + 1 || declared.h > actual.h + 1;
|
|
143
|
+
out.push({
|
|
144
|
+
kind: 'declaredPixelsMismatch', severity: over ? 'warning' : 'info', pageIndex, rect, fileId,
|
|
145
|
+
declared: { width: declared.w, height: declared.h }, actual: { width: actual.w, height: actual.h },
|
|
146
|
+
...(rid ? { resourceId: rid } : {}), ...source,
|
|
147
|
+
});
|
|
148
|
+
}
|
|
121
149
|
if (size && placedW > 0 && placedH > 0) {
|
|
122
150
|
const ppi = Math.min((size.w * fracW) / (placedW / dpi), (size.h * fracH) / (placedH / dpi));
|
|
151
|
+
placed?.push({ fileId, ...(rid ? { resourceId: rid } : {}), pageIndex, ppi, width: placedW, height: placedH });
|
|
152
|
+
if (!pf.enabled)
|
|
153
|
+
return;
|
|
123
154
|
if (ppi < pf.minImageResolution - EPS) {
|
|
124
155
|
out.push({
|
|
125
156
|
kind: 'lowImageResolution',
|
|
@@ -129,7 +160,7 @@ export function preflightDocument(doc, options = {}) {
|
|
|
129
160
|
});
|
|
130
161
|
}
|
|
131
162
|
}
|
|
132
|
-
if (cmykJob && options.imageColor?.(fileId) === 'rgb') {
|
|
163
|
+
if (pf.enabled && cmykJob && options.imageColor?.(fileId) === 'rgb') {
|
|
133
164
|
const converted = print.standard === 'pdfx1a' || print.convertImages;
|
|
134
165
|
out.push({ kind: 'rgbImage', severity: converted ? 'info' : 'warning', pageIndex, rect, fileId, converted, ...(rid ? { resourceId: rid } : {}), ...source });
|
|
135
166
|
}
|
|
@@ -288,8 +319,12 @@ export function preflightDocument(doc, options = {}) {
|
|
|
288
319
|
}
|
|
289
320
|
const table = rb.table;
|
|
290
321
|
if (table) {
|
|
291
|
-
|
|
292
|
-
|
|
322
|
+
// Booktabs strokes (#625) have their own widths: the thinnest counts.
|
|
323
|
+
const rulePx = table.strokes
|
|
324
|
+
? table.strokes.reduce((min, s) => Math.min(min, s.widthPx), Infinity)
|
|
325
|
+
: table.borderWidthPx;
|
|
326
|
+
if (rulePx > 0 && Number.isFinite(rulePx))
|
|
327
|
+
checkRule(rulePx, table.borderColor, pageIndex, body);
|
|
293
328
|
for (const cell of table.cells ?? []) {
|
|
294
329
|
const img = cell.image;
|
|
295
330
|
if (img && img.kind === 'bitmap')
|
|
@@ -306,6 +341,7 @@ export function preflightDocument(doc, options = {}) {
|
|
|
306
341
|
checkSlot(page.header);
|
|
307
342
|
checkSlot(page.footer);
|
|
308
343
|
checkSlot(page.openerBand);
|
|
344
|
+
checkSlot(page.lineNumbers);
|
|
309
345
|
checkComic(page.comic);
|
|
310
346
|
}
|
|
311
347
|
// The rich-black recipe against the limit.
|