postext 1.3.3 → 1.4.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.
Files changed (41) hide show
  1. package/dist/__tests__/exports.test.js +2 -0
  2. package/dist/__tests__/exports.test.js.map +1 -1
  3. package/dist/__tests__/parse/containers.test.js +1 -1
  4. package/dist/__tests__/parse/containers.test.js.map +1 -1
  5. package/dist/__tests__/spaceDirective.test.d.ts +2 -0
  6. package/dist/__tests__/spaceDirective.test.d.ts.map +1 -0
  7. package/dist/__tests__/spaceDirective.test.js +103 -0
  8. package/dist/__tests__/spaceDirective.test.js.map +1 -0
  9. package/dist/index.d.ts +1 -1
  10. package/dist/index.d.ts.map +1 -1
  11. package/dist/index.js +1 -1
  12. package/dist/index.js.map +1 -1
  13. package/dist/parse/attrs.d.ts +8 -0
  14. package/dist/parse/attrs.d.ts.map +1 -1
  15. package/dist/parse/attrs.js +16 -0
  16. package/dist/parse/attrs.js.map +1 -1
  17. package/dist/parse/blockParser.d.ts +1 -1
  18. package/dist/parse/blockParser.d.ts.map +1 -1
  19. package/dist/parse/blockParser.js +2 -2
  20. package/dist/parse/blockParser.js.map +1 -1
  21. package/dist/parse/index.d.ts +1 -1
  22. package/dist/parse/index.d.ts.map +1 -1
  23. package/dist/parse/index.js +1 -1
  24. package/dist/parse/index.js.map +1 -1
  25. package/dist/parse/types.d.ts +1 -1
  26. package/dist/parse/types.d.ts.map +1 -1
  27. package/dist/pipeline/build.d.ts.map +1 -1
  28. package/dist/pipeline/build.js +18 -3
  29. package/dist/pipeline/build.js.map +1 -1
  30. package/dist/pipeline/buildHelpers.d.ts +4 -0
  31. package/dist/pipeline/buildHelpers.d.ts.map +1 -1
  32. package/dist/pipeline/buildHelpers.js +17 -0
  33. package/dist/pipeline/buildHelpers.js.map +1 -1
  34. package/dist/pipeline/calloutLayout.d.ts.map +1 -1
  35. package/dist/pipeline/calloutLayout.js +10 -0
  36. package/dist/pipeline/calloutLayout.js.map +1 -1
  37. package/dist/pipeline/measureContentBlock.d.ts.map +1 -1
  38. package/dist/pipeline/measureContentBlock.js +8 -2
  39. package/dist/pipeline/measureContentBlock.js.map +1 -1
  40. package/dist/types.d.ts +2 -2
  41. package/package.json +1 -1
@@ -2,7 +2,7 @@ import { applyTitleBreaks } from '../parse/inlineFormatting';
2
2
  import { dimensionToPx } from '../units';
3
3
  import { createVDTDocument, createVDTBlock, createBoundingBox, } from '../vdt';
4
4
  import { anchorBox } from '../design/layout';
5
- import { parseMarkdownMemo } from '../parse';
5
+ import { parseMarkdownMemo, spaceDirectiveLines } from '../parse';
6
6
  import { buildPageLabels, computeHeadingNumbers, } from '../numbering';
7
7
  import { extractFrontmatter } from '../frontmatter';
8
8
  import { initHyphenator } from '../measure';
@@ -14,7 +14,7 @@ import { resolveBodyStyle, resolveBlockquoteStyle } from './styles';
14
14
  import { computeLevelIndentsPx, computeOrderedLevelIndentsPx, computeOrderedListRunMetrics, } from './lists';
15
15
  import { resetLinePositions, createPageWithColumns, currentColumn, advanceToNextColumn, advanceToNextPageBoundary, enforcePageParity, placeBlockInColumn, placeAtomicBlock, createPartPage, pageHasContent, sideColumnOf, sideColumns, sideUsedBottom, pageIsOccupied, bandColumns, currentBand, isBandLevel, bandUsedBottom, closeBandAndInsertSpan, } from './placement';
16
16
  import { chooseParagraphSplit } from './orphanWidow';
17
- import { applyStyleAttrs, computePageMetrics, isMarkerBlock, nextNonMarkerBlock, prevNonMarkerBlock, rollbackTrailingBlocks, } from './buildHelpers';
17
+ import { applyStyleAttrs, computePageMetrics, isMarkerBlock, nextNonMarkerBlock, spaceLinesAfter, prevNonMarkerBlock, rollbackTrailingBlocks, } from './buildHelpers';
18
18
  import { measureContentBlock } from './measureContentBlock';
19
19
  import { planParagraphContainers } from './paragraphContainers';
20
20
  import { planParts, derivePartMeasureContext } from './parts';
@@ -2678,6 +2678,19 @@ export function buildDocumentPass(content, config, cache, options, hints = {}) {
2678
2678
  flushPendingNumberingAtBoundary();
2679
2679
  }
2680
2680
  }
2681
+ else if (name === 'space') {
2682
+ // Explicit vertical space (`:::space{lines=N}`), in body lines. It
2683
+ // adds to the margin between its neighbours (the pending margin
2684
+ // still collapses with the next block's top margin) and, like
2685
+ // LaTeX's `\vspace`, is discarded at a break: it vanishes at a
2686
+ // column top, and one that does not fit ends the column instead of
2687
+ // carrying over.
2688
+ const col = currentColumn(doc, cursor);
2689
+ if (col.blocks.length > 0) {
2690
+ const px = (spaceDirectiveLines(attrs) ?? 1) * baselineGrid;
2691
+ col.availableHeight = Math.max(0, col.availableHeight - px);
2692
+ }
2693
+ }
2681
2694
  else if (name === 'numbering') {
2682
2695
  const change = {};
2683
2696
  const fmt = attrs.format;
@@ -3273,7 +3286,9 @@ export function buildDocumentPass(content, config, cache, options, hints = {}) {
3273
3286
  const minLinesNeeded = resolved.bodyText.avoidWidows
3274
3287
  ? Math.max(1, resolved.bodyText.widowMinLines)
3275
3288
  : 1;
3276
- const minSpaceAfter = minLinesNeeded * bodyStyle.lineHeightPx;
3289
+ // A `:::space` between the heading and its text needs room too.
3290
+ const minSpaceAfter = minLinesNeeded * bodyStyle.lineHeightPx
3291
+ + spaceLinesAfter(contentBlocks, blockIdx) * baselineGrid;
3277
3292
  if (remainAfterHeading < minSpaceAfter) {
3278
3293
  if (curCol.blocks.length === 0)
3279
3294
  shortColumnMoves++;