postext 1.27.1 → 1.28.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 (544) hide show
  1. package/dist/__tests__/bundle/balloonPlacementPin.test.d.ts +2 -0
  2. package/dist/__tests__/bundle/balloonPlacementPin.test.d.ts.map +1 -0
  3. package/dist/__tests__/bundle/balloonPlacementPin.test.js +71 -0
  4. package/dist/__tests__/bundle/balloonPlacementPin.test.js.map +1 -0
  5. package/dist/__tests__/bundle/cjkRulesPin.test.js +131 -7
  6. package/dist/__tests__/bundle/cjkRulesPin.test.js.map +1 -1
  7. package/dist/__tests__/bundle/designOverflowPin.test.js +3 -3
  8. package/dist/__tests__/bundle/designOverflowPin.test.js.map +1 -1
  9. package/dist/__tests__/bundle/flowColumnsPin.test.js +3 -1
  10. package/dist/__tests__/bundle/flowColumnsPin.test.js.map +1 -1
  11. package/dist/__tests__/bundle/gridBalancingPin.test.js +14 -5
  12. package/dist/__tests__/bundle/gridBalancingPin.test.js.map +1 -1
  13. package/dist/__tests__/bundle/gridBreakRulesPin.test.d.ts +2 -0
  14. package/dist/__tests__/bundle/gridBreakRulesPin.test.d.ts.map +1 -0
  15. package/dist/__tests__/bundle/gridBreakRulesPin.test.js +144 -0
  16. package/dist/__tests__/bundle/gridBreakRulesPin.test.js.map +1 -0
  17. package/dist/__tests__/bundle/indexGroupSplitPin.test.d.ts +2 -0
  18. package/dist/__tests__/bundle/indexGroupSplitPin.test.d.ts.map +1 -0
  19. package/dist/__tests__/bundle/indexGroupSplitPin.test.js +55 -0
  20. package/dist/__tests__/bundle/indexGroupSplitPin.test.js.map +1 -0
  21. package/dist/__tests__/bundle/inlineCaptionSidePin.test.d.ts +2 -0
  22. package/dist/__tests__/bundle/inlineCaptionSidePin.test.d.ts.map +1 -0
  23. package/dist/__tests__/bundle/inlineCaptionSidePin.test.js +60 -0
  24. package/dist/__tests__/bundle/inlineCaptionSidePin.test.js.map +1 -0
  25. package/dist/__tests__/bundle/inlineTableSplitPin.test.js +3 -1
  26. package/dist/__tests__/bundle/inlineTableSplitPin.test.js.map +1 -1
  27. package/dist/__tests__/bundle/looseOrderPin.test.d.ts +2 -0
  28. package/dist/__tests__/bundle/looseOrderPin.test.d.ts.map +1 -0
  29. package/dist/__tests__/bundle/looseOrderPin.test.js +76 -0
  30. package/dist/__tests__/bundle/looseOrderPin.test.js.map +1 -0
  31. package/dist/__tests__/bundle/openerHeadFloatsPin.test.js +2 -1
  32. package/dist/__tests__/bundle/openerHeadFloatsPin.test.js.map +1 -1
  33. package/dist/__tests__/bundle/refLabelBreaksPin.test.d.ts +2 -0
  34. package/dist/__tests__/bundle/refLabelBreaksPin.test.d.ts.map +1 -0
  35. package/dist/__tests__/bundle/refLabelBreaksPin.test.js +72 -0
  36. package/dist/__tests__/bundle/refLabelBreaksPin.test.js.map +1 -0
  37. package/dist/__tests__/bundle/scriptContextPin.test.d.ts +2 -0
  38. package/dist/__tests__/bundle/scriptContextPin.test.d.ts.map +1 -0
  39. package/dist/__tests__/bundle/scriptContextPin.test.js +66 -0
  40. package/dist/__tests__/bundle/scriptContextPin.test.js.map +1 -0
  41. package/dist/__tests__/bundle/trailingStepPin.test.d.ts +2 -0
  42. package/dist/__tests__/bundle/trailingStepPin.test.d.ts.map +1 -0
  43. package/dist/__tests__/bundle/trailingStepPin.test.js +59 -0
  44. package/dist/__tests__/bundle/trailingStepPin.test.js.map +1 -0
  45. package/dist/__tests__/bundle/wideFloatStretchPin.test.d.ts +2 -0
  46. package/dist/__tests__/bundle/wideFloatStretchPin.test.d.ts.map +1 -0
  47. package/dist/__tests__/bundle/wideFloatStretchPin.test.js +59 -0
  48. package/dist/__tests__/bundle/wideFloatStretchPin.test.js.map +1 -0
  49. package/dist/__tests__/bundle.test.js +8 -6
  50. package/dist/__tests__/bundle.test.js.map +1 -1
  51. package/dist/__tests__/cjk/annotations.test.js +223 -0
  52. package/dist/__tests__/cjk/annotations.test.js.map +1 -1
  53. package/dist/__tests__/cjk/annotationsRender.test.js +3 -3
  54. package/dist/__tests__/cjk/annotationsRender.test.js.map +1 -1
  55. package/dist/__tests__/cjk/chipLatinSpacing.test.js +13 -2
  56. package/dist/__tests__/cjk/chipLatinSpacing.test.js.map +1 -1
  57. package/dist/__tests__/cjk/designNumberSeams.test.d.ts +2 -0
  58. package/dist/__tests__/cjk/designNumberSeams.test.d.ts.map +1 -0
  59. package/dist/__tests__/cjk/designNumberSeams.test.js +221 -0
  60. package/dist/__tests__/cjk/designNumberSeams.test.js.map +1 -0
  61. package/dist/__tests__/cjk/grid.test.js +1 -1
  62. package/dist/__tests__/cjk/grid.test.js.map +1 -1
  63. package/dist/__tests__/cjk/gridBalancing.test.js +3 -1
  64. package/dist/__tests__/cjk/gridBalancing.test.js.map +1 -1
  65. package/dist/__tests__/cjk/japaneseSpacing.test.js +3 -1
  66. package/dist/__tests__/cjk/japaneseSpacing.test.js.map +1 -1
  67. package/dist/__tests__/cjk/keepAll.test.js +3 -1
  68. package/dist/__tests__/cjk/keepAll.test.js.map +1 -1
  69. package/dist/__tests__/cjk/keepAllLatinQuotation.test.d.ts +2 -0
  70. package/dist/__tests__/cjk/keepAllLatinQuotation.test.d.ts.map +1 -0
  71. package/dist/__tests__/cjk/keepAllLatinQuotation.test.js +166 -0
  72. package/dist/__tests__/cjk/keepAllLatinQuotation.test.js.map +1 -0
  73. package/dist/__tests__/cjk/latinSpacingEdge.test.d.ts +2 -0
  74. package/dist/__tests__/cjk/latinSpacingEdge.test.d.ts.map +1 -0
  75. package/dist/__tests__/cjk/latinSpacingEdge.test.js +179 -0
  76. package/dist/__tests__/cjk/latinSpacingEdge.test.js.map +1 -0
  77. package/dist/__tests__/cjk/runt.test.js +92 -1
  78. package/dist/__tests__/cjk/runt.test.js.map +1 -1
  79. package/dist/__tests__/codeBlocks.test.js +1 -1
  80. package/dist/__tests__/columnBalancing.test.js +216 -0
  81. package/dist/__tests__/columnBalancing.test.js.map +1 -1
  82. package/dist/__tests__/columnRuleBands.test.js +78 -0
  83. package/dist/__tests__/columnRuleBands.test.js.map +1 -1
  84. package/dist/__tests__/comics/readingDirection.test.js +52 -0
  85. package/dist/__tests__/comics/readingDirection.test.js.map +1 -1
  86. package/dist/__tests__/comics/script.test.js +5 -0
  87. package/dist/__tests__/comics/script.test.js.map +1 -1
  88. package/dist/__tests__/contrast.test.d.ts +2 -0
  89. package/dist/__tests__/contrast.test.d.ts.map +1 -0
  90. package/dist/__tests__/contrast.test.js +258 -0
  91. package/dist/__tests__/contrast.test.js.map +1 -0
  92. package/dist/__tests__/defaults/cjk.test.js +4 -4
  93. package/dist/__tests__/defaults/cjk.test.js.map +1 -1
  94. package/dist/__tests__/defaults/gridBreakRules.test.d.ts +2 -0
  95. package/dist/__tests__/defaults/gridBreakRules.test.d.ts.map +1 -0
  96. package/dist/__tests__/defaults/gridBreakRules.test.js +152 -0
  97. package/dist/__tests__/defaults/gridBreakRules.test.js.map +1 -0
  98. package/dist/__tests__/defaults/headingsBalancing.test.js +25 -0
  99. package/dist/__tests__/defaults/headingsBalancing.test.js.map +1 -1
  100. package/dist/__tests__/defaults/stripContextDefaults.test.js +41 -0
  101. package/dist/__tests__/defaults/stripContextDefaults.test.js.map +1 -1
  102. package/dist/__tests__/defaults/stripRoundTrip.test.js +8 -5
  103. package/dist/__tests__/defaults/stripRoundTrip.test.js.map +1 -1
  104. package/dist/__tests__/exports.test.js +30 -0
  105. package/dist/__tests__/exports.test.js.map +1 -1
  106. package/dist/__tests__/fontUsage.test.d.ts +2 -0
  107. package/dist/__tests__/fontUsage.test.d.ts.map +1 -0
  108. package/dist/__tests__/fontUsage.test.js +113 -0
  109. package/dist/__tests__/fontUsage.test.js.map +1 -0
  110. package/dist/__tests__/hardBreaks.test.js +1 -1
  111. package/dist/__tests__/headingInlineMarks.test.js +7 -5
  112. package/dist/__tests__/headingInlineMarks.test.js.map +1 -1
  113. package/dist/__tests__/hyphenationRules.test.d.ts +2 -0
  114. package/dist/__tests__/hyphenationRules.test.d.ts.map +1 -0
  115. package/dist/__tests__/hyphenationRules.test.js +295 -0
  116. package/dist/__tests__/hyphenationRules.test.js.map +1 -0
  117. package/dist/__tests__/indexGroupSplit.test.d.ts +2 -0
  118. package/dist/__tests__/indexGroupSplit.test.d.ts.map +1 -0
  119. package/dist/__tests__/indexGroupSplit.test.js +175 -0
  120. package/dist/__tests__/indexGroupSplit.test.js.map +1 -0
  121. package/dist/__tests__/mathSizeMigration.test.js +7 -5
  122. package/dist/__tests__/mathSizeMigration.test.js.map +1 -1
  123. package/dist/__tests__/multipleColumns.test.js +19 -0
  124. package/dist/__tests__/multipleColumns.test.js.map +1 -1
  125. package/dist/__tests__/pipeline/calloutInlineResourceGap.test.js +1 -1
  126. package/dist/__tests__/pipeline/calloutSplitMinLinesChild.test.js +3 -3
  127. package/dist/__tests__/pipeline/calloutSplitMinLinesChild.test.js.map +1 -1
  128. package/dist/__tests__/pipeline/closingBandUnderOpener.test.d.ts +2 -0
  129. package/dist/__tests__/pipeline/closingBandUnderOpener.test.d.ts.map +1 -0
  130. package/dist/__tests__/pipeline/closingBandUnderOpener.test.js +90 -0
  131. package/dist/__tests__/pipeline/closingBandUnderOpener.test.js.map +1 -0
  132. package/dist/__tests__/pipeline/colonListRoom.test.js +5 -4
  133. package/dist/__tests__/pipeline/colonListRoom.test.js.map +1 -1
  134. package/dist/__tests__/pipeline/columnHeadSpace.test.d.ts +2 -0
  135. package/dist/__tests__/pipeline/columnHeadSpace.test.d.ts.map +1 -0
  136. package/dist/__tests__/pipeline/columnHeadSpace.test.js +175 -0
  137. package/dist/__tests__/pipeline/columnHeadSpace.test.js.map +1 -0
  138. package/dist/__tests__/pipeline/compoundBreaks.test.js +6 -6
  139. package/dist/__tests__/pipeline/compoundBreaks.test.js.map +1 -1
  140. package/dist/__tests__/pipeline/dashBreaks.test.js +5 -5
  141. package/dist/__tests__/pipeline/dashBreaks.test.js.map +1 -1
  142. package/dist/__tests__/pipeline/flowColumns.test.js +100 -0
  143. package/dist/__tests__/pipeline/flowColumns.test.js.map +1 -1
  144. package/dist/__tests__/pipeline/headingShortBand.test.js +2 -1
  145. package/dist/__tests__/pipeline/headingShortBand.test.js.map +1 -1
  146. package/dist/__tests__/pipeline/headingSplitOrphans.test.js +6 -5
  147. package/dist/__tests__/pipeline/headingSplitOrphans.test.js.map +1 -1
  148. package/dist/__tests__/pipeline/hyphenAcrossColumns.test.js +188 -1
  149. package/dist/__tests__/pipeline/hyphenAcrossColumns.test.js.map +1 -1
  150. package/dist/__tests__/pipeline/inlineCaptionSide.test.d.ts +2 -0
  151. package/dist/__tests__/pipeline/inlineCaptionSide.test.d.ts.map +1 -0
  152. package/dist/__tests__/pipeline/inlineCaptionSide.test.js +270 -0
  153. package/dist/__tests__/pipeline/inlineCaptionSide.test.js.map +1 -0
  154. package/dist/__tests__/pipeline/inlineFigureSpace.test.js +5 -5
  155. package/dist/__tests__/pipeline/inlineFigureSpace.test.js.map +1 -1
  156. package/dist/__tests__/pipeline/inlineRefRender.test.js +8 -6
  157. package/dist/__tests__/pipeline/inlineRefRender.test.js.map +1 -1
  158. package/dist/__tests__/pipeline/looseBeforeHeadingLines.test.d.ts +2 -0
  159. package/dist/__tests__/pipeline/looseBeforeHeadingLines.test.d.ts.map +1 -0
  160. package/dist/__tests__/pipeline/looseBeforeHeadingLines.test.js +73 -0
  161. package/dist/__tests__/pipeline/looseBeforeHeadingLines.test.js.map +1 -0
  162. package/dist/__tests__/pipeline/openerFloats.test.d.ts +2 -0
  163. package/dist/__tests__/pipeline/openerFloats.test.d.ts.map +1 -0
  164. package/dist/__tests__/pipeline/openerFloats.test.js +137 -0
  165. package/dist/__tests__/pipeline/openerFloats.test.js.map +1 -0
  166. package/dist/__tests__/pipeline/orderedNumberWidthItem.test.d.ts +2 -0
  167. package/dist/__tests__/pipeline/orderedNumberWidthItem.test.d.ts.map +1 -0
  168. package/dist/__tests__/pipeline/orderedNumberWidthItem.test.js +162 -0
  169. package/dist/__tests__/pipeline/orderedNumberWidthItem.test.js.map +1 -0
  170. package/dist/__tests__/pipeline/paragraphContainerTail.test.js +68 -8
  171. package/dist/__tests__/pipeline/paragraphContainerTail.test.js.map +1 -1
  172. package/dist/__tests__/pipeline/paragraphStyleFaces.test.js +1 -1
  173. package/dist/__tests__/pipeline/paragraphStyleFaces.test.js.map +1 -1
  174. package/dist/__tests__/pipeline/raggedLineAndRuntFix.test.d.ts +2 -0
  175. package/dist/__tests__/pipeline/raggedLineAndRuntFix.test.d.ts.map +1 -0
  176. package/dist/__tests__/pipeline/raggedLineAndRuntFix.test.js +151 -0
  177. package/dist/__tests__/pipeline/raggedLineAndRuntFix.test.js.map +1 -0
  178. package/dist/__tests__/pipeline/raggedOptimal.test.js +6 -6
  179. package/dist/__tests__/pipeline/raggedOptimal.test.js.map +1 -1
  180. package/dist/__tests__/pipeline/refLabelBreaks.test.d.ts +2 -0
  181. package/dist/__tests__/pipeline/refLabelBreaks.test.d.ts.map +1 -0
  182. package/dist/__tests__/pipeline/refLabelBreaks.test.js +324 -0
  183. package/dist/__tests__/pipeline/refLabelBreaks.test.js.map +1 -0
  184. package/dist/__tests__/pipeline/resourceTemplateStyles.test.d.ts +2 -0
  185. package/dist/__tests__/pipeline/resourceTemplateStyles.test.d.ts.map +1 -0
  186. package/dist/__tests__/pipeline/resourceTemplateStyles.test.js +145 -0
  187. package/dist/__tests__/pipeline/resourceTemplateStyles.test.js.map +1 -0
  188. package/dist/__tests__/pipeline/shortListSplit.test.d.ts +2 -0
  189. package/dist/__tests__/pipeline/shortListSplit.test.d.ts.map +1 -0
  190. package/dist/__tests__/pipeline/shortListSplit.test.js +181 -0
  191. package/dist/__tests__/pipeline/shortListSplit.test.js.map +1 -0
  192. package/dist/__tests__/pipeline/snapTailAtColumnFoot.test.d.ts +2 -0
  193. package/dist/__tests__/pipeline/snapTailAtColumnFoot.test.d.ts.map +1 -0
  194. package/dist/__tests__/pipeline/snapTailAtColumnFoot.test.js +133 -0
  195. package/dist/__tests__/pipeline/snapTailAtColumnFoot.test.js.map +1 -0
  196. package/dist/__tests__/pipeline/stretchAfterDisplays.test.d.ts +2 -0
  197. package/dist/__tests__/pipeline/stretchAfterDisplays.test.d.ts.map +1 -0
  198. package/dist/__tests__/pipeline/stretchAfterDisplays.test.js +51 -0
  199. package/dist/__tests__/pipeline/stretchAfterDisplays.test.js.map +1 -0
  200. package/dist/__tests__/pipeline/trailingCapFloatHead.test.js +26 -0
  201. package/dist/__tests__/pipeline/trailingCapFloatHead.test.js.map +1 -1
  202. package/dist/__tests__/pipeline/trailingStep.test.d.ts +2 -0
  203. package/dist/__tests__/pipeline/trailingStep.test.d.ts.map +1 -0
  204. package/dist/__tests__/pipeline/trailingStep.test.js +187 -0
  205. package/dist/__tests__/pipeline/trailingStep.test.js.map +1 -0
  206. package/dist/__tests__/pipeline/wideFloatStretch.test.d.ts +2 -0
  207. package/dist/__tests__/pipeline/wideFloatStretch.test.d.ts.map +1 -0
  208. package/dist/__tests__/pipeline/wideFloatStretch.test.js +84 -0
  209. package/dist/__tests__/pipeline/wideFloatStretch.test.js.map +1 -0
  210. package/dist/__tests__/scriptContext.test.d.ts +2 -0
  211. package/dist/__tests__/scriptContext.test.d.ts.map +1 -0
  212. package/dist/__tests__/scriptContext.test.js +919 -0
  213. package/dist/__tests__/scriptContext.test.js.map +1 -0
  214. package/dist/__tests__/softHyphenEdges.test.d.ts +2 -0
  215. package/dist/__tests__/softHyphenEdges.test.d.ts.map +1 -0
  216. package/dist/__tests__/softHyphenEdges.test.js +217 -0
  217. package/dist/__tests__/softHyphenEdges.test.js.map +1 -0
  218. package/dist/__tests__/spaceLimitRatio.test.d.ts +2 -0
  219. package/dist/__tests__/spaceLimitRatio.test.d.ts.map +1 -0
  220. package/dist/__tests__/spaceLimitRatio.test.js +226 -0
  221. package/dist/__tests__/spaceLimitRatio.test.js.map +1 -0
  222. package/dist/__tests__/trackedLigatures.test.js +365 -24
  223. package/dist/__tests__/trackedLigatures.test.js.map +1 -1
  224. package/dist/__tests__/verseLines.test.js +9 -7
  225. package/dist/__tests__/verseLines.test.js.map +1 -1
  226. package/dist/bundle/configVersion.d.ts +201 -6
  227. package/dist/bundle/configVersion.d.ts.map +1 -1
  228. package/dist/bundle/configVersion.js +440 -6
  229. package/dist/bundle/configVersion.js.map +1 -1
  230. package/dist/bundle/index.d.ts +8 -0
  231. package/dist/bundle/index.d.ts.map +1 -1
  232. package/dist/bundle/index.js +8 -0
  233. package/dist/bundle/index.js.map +1 -1
  234. package/dist/canvas-backend/blockRender.d.ts.map +1 -1
  235. package/dist/canvas-backend/blockRender.js +3 -2
  236. package/dist/canvas-backend/blockRender.js.map +1 -1
  237. package/dist/canvas-backend/chip.js +1 -1
  238. package/dist/canvas-backend/chip.js.map +1 -1
  239. package/dist/canvas-backend/headerFooter.d.ts.map +1 -1
  240. package/dist/canvas-backend/headerFooter.js +17 -2
  241. package/dist/canvas-backend/headerFooter.js.map +1 -1
  242. package/dist/canvas-backend/runDirection.d.ts +10 -6
  243. package/dist/canvas-backend/runDirection.d.ts.map +1 -1
  244. package/dist/canvas-backend/runDirection.js +12 -7
  245. package/dist/canvas-backend/runDirection.js.map +1 -1
  246. package/dist/canvas-backend/scriptText.d.ts +11 -0
  247. package/dist/canvas-backend/scriptText.d.ts.map +1 -0
  248. package/dist/canvas-backend/scriptText.js +75 -0
  249. package/dist/canvas-backend/scriptText.js.map +1 -0
  250. package/dist/canvas-backend/segmentText.d.ts.map +1 -1
  251. package/dist/canvas-backend/segmentText.js +9 -1
  252. package/dist/canvas-backend/segmentText.js.map +1 -1
  253. package/dist/canvas-backend/trackedText.d.ts +35 -20
  254. package/dist/canvas-backend/trackedText.d.ts.map +1 -1
  255. package/dist/canvas-backend/trackedText.js +58 -22
  256. package/dist/canvas-backend/trackedText.js.map +1 -1
  257. package/dist/canvas-backend/verticalText.d.ts.map +1 -1
  258. package/dist/canvas-backend/verticalText.js +10 -2
  259. package/dist/canvas-backend/verticalText.js.map +1 -1
  260. package/dist/canvas-backend/wordRuns.d.ts +14 -5
  261. package/dist/canvas-backend/wordRuns.d.ts.map +1 -1
  262. package/dist/canvas-backend/wordRuns.js +20 -7
  263. package/dist/canvas-backend/wordRuns.js.map +1 -1
  264. package/dist/citations/names.d.ts +8 -0
  265. package/dist/citations/names.d.ts.map +1 -0
  266. package/dist/citations/names.js +25 -0
  267. package/dist/citations/names.js.map +1 -0
  268. package/dist/columnClip.d.ts +8 -1
  269. package/dist/columnClip.d.ts.map +1 -1
  270. package/dist/columnClip.js +32 -3
  271. package/dist/columnClip.js.map +1 -1
  272. package/dist/columnRule.d.ts +6 -3
  273. package/dist/columnRule.d.ts.map +1 -1
  274. package/dist/columnRule.js +6 -3
  275. package/dist/columnRule.js.map +1 -1
  276. package/dist/comics/layoutPage.d.ts.map +1 -1
  277. package/dist/comics/layoutPage.js +51 -22
  278. package/dist/comics/layoutPage.js.map +1 -1
  279. package/dist/comics/lettering/__tests__/bystanderFaces.test.d.ts +2 -0
  280. package/dist/comics/lettering/__tests__/bystanderFaces.test.d.ts.map +1 -0
  281. package/dist/comics/lettering/__tests__/bystanderFaces.test.js +204 -0
  282. package/dist/comics/lettering/__tests__/bystanderFaces.test.js.map +1 -0
  283. package/dist/comics/lettering/__tests__/shapeTextDash.test.d.ts +2 -0
  284. package/dist/comics/lettering/__tests__/shapeTextDash.test.d.ts.map +1 -0
  285. package/dist/comics/lettering/__tests__/shapeTextDash.test.js +173 -0
  286. package/dist/comics/lettering/__tests__/shapeTextDash.test.js.map +1 -0
  287. package/dist/comics/lettering/__tests__/strictPlacement.test.d.ts +2 -0
  288. package/dist/comics/lettering/__tests__/strictPlacement.test.d.ts.map +1 -0
  289. package/dist/comics/lettering/__tests__/strictPlacement.test.js +130 -0
  290. package/dist/comics/lettering/__tests__/strictPlacement.test.js.map +1 -0
  291. package/dist/comics/lettering/letter.js +21 -8
  292. package/dist/comics/lettering/letter.js.map +1 -1
  293. package/dist/comics/lettering/placement.d.ts.map +1 -1
  294. package/dist/comics/lettering/placement.js +12 -3
  295. package/dist/comics/lettering/placement.js.map +1 -1
  296. package/dist/comics/lettering/shape-text.d.ts +3 -0
  297. package/dist/comics/lettering/shape-text.d.ts.map +1 -1
  298. package/dist/comics/lettering/shape-text.js +71 -12
  299. package/dist/comics/lettering/shape-text.js.map +1 -1
  300. package/dist/comics/lettering/text.d.ts +5 -0
  301. package/dist/comics/lettering/text.d.ts.map +1 -1
  302. package/dist/comics/lettering/text.js +6 -1
  303. package/dist/comics/lettering/text.js.map +1 -1
  304. package/dist/comics/lettering/types.d.ts +12 -2
  305. package/dist/comics/lettering/types.d.ts.map +1 -1
  306. package/dist/comics/script.js +1 -1
  307. package/dist/comics/script.js.map +1 -1
  308. package/dist/comics/types.d.ts +7 -3
  309. package/dist/comics/types.d.ts.map +1 -1
  310. package/dist/configWarnings.d.ts.map +1 -1
  311. package/dist/configWarnings.js +33 -6
  312. package/dist/configWarnings.js.map +1 -1
  313. package/dist/contrast.d.ts +188 -0
  314. package/dist/contrast.d.ts.map +1 -0
  315. package/dist/contrast.js +583 -0
  316. package/dist/contrast.js.map +1 -0
  317. package/dist/defaults/bodyText.d.ts +31 -3
  318. package/dist/defaults/bodyText.d.ts.map +1 -1
  319. package/dist/defaults/bodyText.js +76 -8
  320. package/dist/defaults/bodyText.js.map +1 -1
  321. package/dist/defaults/citations.d.ts.map +1 -1
  322. package/dist/defaults/citations.js +4 -0
  323. package/dist/defaults/citations.js.map +1 -1
  324. package/dist/defaults/cjk.d.ts +11 -1
  325. package/dist/defaults/cjk.d.ts.map +1 -1
  326. package/dist/defaults/cjk.js +41 -3
  327. package/dist/defaults/cjk.js.map +1 -1
  328. package/dist/defaults/comics.d.ts.map +1 -1
  329. package/dist/defaults/comics.js +2 -0
  330. package/dist/defaults/comics.js.map +1 -1
  331. package/dist/defaults/contrast.d.ts +11 -0
  332. package/dist/defaults/contrast.d.ts.map +1 -0
  333. package/dist/defaults/contrast.js +65 -0
  334. package/dist/defaults/contrast.js.map +1 -0
  335. package/dist/defaults/crossRefs.d.ts +1 -1
  336. package/dist/defaults/crossRefs.d.ts.map +1 -1
  337. package/dist/defaults/crossRefs.js +6 -1
  338. package/dist/defaults/crossRefs.js.map +1 -1
  339. package/dist/defaults/footnotes.d.ts.map +1 -1
  340. package/dist/defaults/footnotes.js +5 -0
  341. package/dist/defaults/footnotes.js.map +1 -1
  342. package/dist/defaults/headings.d.ts +5 -1
  343. package/dist/defaults/headings.d.ts.map +1 -1
  344. package/dist/defaults/headings.js +41 -1
  345. package/dist/defaults/headings.js.map +1 -1
  346. package/dist/defaults/index.d.ts +3 -2
  347. package/dist/defaults/index.d.ts.map +1 -1
  348. package/dist/defaults/index.js +15 -4
  349. package/dist/defaults/index.js.map +1 -1
  350. package/dist/defaults/indexConfig.d.ts +1 -0
  351. package/dist/defaults/indexConfig.d.ts.map +1 -1
  352. package/dist/defaults/indexConfig.js +7 -1
  353. package/dist/defaults/indexConfig.js.map +1 -1
  354. package/dist/defaults/layout.d.ts.map +1 -1
  355. package/dist/defaults/layout.js +13 -1
  356. package/dist/defaults/layout.js.map +1 -1
  357. package/dist/defaults/orderedLists.js +1 -1
  358. package/dist/defaults/orderedLists.js.map +1 -1
  359. package/dist/defaults/paragraphStyles.d.ts.map +1 -1
  360. package/dist/defaults/paragraphStyles.js +5 -0
  361. package/dist/defaults/paragraphStyles.js.map +1 -1
  362. package/dist/defaults/shared.d.ts +4 -1
  363. package/dist/defaults/shared.d.ts.map +1 -1
  364. package/dist/defaults/shared.js +5 -0
  365. package/dist/defaults/shared.js.map +1 -1
  366. package/dist/design/cjkText.d.ts +7 -2
  367. package/dist/design/cjkText.d.ts.map +1 -1
  368. package/dist/design/cjkText.js +8 -2
  369. package/dist/design/cjkText.js.map +1 -1
  370. package/dist/design/layout.d.ts.map +1 -1
  371. package/dist/design/layout.js +85 -12
  372. package/dist/design/layout.js.map +1 -1
  373. package/dist/design/richText.d.ts.map +1 -1
  374. package/dist/design/richText.js +7 -3
  375. package/dist/design/richText.js.map +1 -1
  376. package/dist/fonts/usage.d.ts.map +1 -1
  377. package/dist/fonts/usage.js +89 -0
  378. package/dist/fonts/usage.js.map +1 -1
  379. package/dist/html-backend.d.ts.map +1 -1
  380. package/dist/html-backend.js +97 -27
  381. package/dist/html-backend.js.map +1 -1
  382. package/dist/hyphenate.d.ts +58 -1
  383. package/dist/hyphenate.d.ts.map +1 -1
  384. package/dist/hyphenate.js +228 -19
  385. package/dist/hyphenate.js.map +1 -1
  386. package/dist/hyphenationExceptions.d.ts +10 -0
  387. package/dist/hyphenationExceptions.d.ts.map +1 -0
  388. package/dist/hyphenationExceptions.js +29 -0
  389. package/dist/hyphenationExceptions.js.map +1 -0
  390. package/dist/index.d.ts +12 -4
  391. package/dist/index.d.ts.map +1 -1
  392. package/dist/index.js +10 -3
  393. package/dist/index.js.map +1 -1
  394. package/dist/knuthPlass/pretextAdapter.d.ts.map +1 -1
  395. package/dist/knuthPlass/pretextAdapter.js +4 -17
  396. package/dist/knuthPlass/pretextAdapter.js.map +1 -1
  397. package/dist/knuthPlass/richAdapter.d.ts +9 -0
  398. package/dist/knuthPlass/richAdapter.d.ts.map +1 -1
  399. package/dist/knuthPlass/richAdapter.js +15 -18
  400. package/dist/knuthPlass/richAdapter.js.map +1 -1
  401. package/dist/looseLines.d.ts +15 -4
  402. package/dist/looseLines.d.ts.map +1 -1
  403. package/dist/looseLines.js +17 -4
  404. package/dist/looseLines.js.map +1 -1
  405. package/dist/measure/cache.d.ts.map +1 -1
  406. package/dist/measure/cache.js +14 -4
  407. package/dist/measure/cache.js.map +1 -1
  408. package/dist/measure/canvas.d.ts +18 -0
  409. package/dist/measure/canvas.d.ts.map +1 -1
  410. package/dist/measure/canvas.js +104 -0
  411. package/dist/measure/canvas.js.map +1 -1
  412. package/dist/measure/cjkAnnotate.d.ts +11 -6
  413. package/dist/measure/cjkAnnotate.d.ts.map +1 -1
  414. package/dist/measure/cjkAnnotate.js +27 -11
  415. package/dist/measure/cjkAnnotate.js.map +1 -1
  416. package/dist/measure/cjkCompose.d.ts +6 -2
  417. package/dist/measure/cjkCompose.d.ts.map +1 -1
  418. package/dist/measure/cjkCompose.js +146 -30
  419. package/dist/measure/cjkCompose.js.map +1 -1
  420. package/dist/measure/cjkPunctuation.d.ts +17 -0
  421. package/dist/measure/cjkPunctuation.d.ts.map +1 -1
  422. package/dist/measure/cjkPunctuation.js +15 -1
  423. package/dist/measure/cjkPunctuation.js.map +1 -1
  424. package/dist/measure/font.d.ts +2 -1
  425. package/dist/measure/font.d.ts.map +1 -1
  426. package/dist/measure/font.js +4 -2
  427. package/dist/measure/font.js.map +1 -1
  428. package/dist/measure/hardBreaks.d.ts.map +1 -1
  429. package/dist/measure/hardBreaks.js +6 -2
  430. package/dist/measure/hardBreaks.js.map +1 -1
  431. package/dist/measure/kashida.d.ts.map +1 -1
  432. package/dist/measure/kashida.js +8 -11
  433. package/dist/measure/kashida.js.map +1 -1
  434. package/dist/measure/plain.d.ts +3 -0
  435. package/dist/measure/plain.d.ts.map +1 -1
  436. package/dist/measure/plain.js +70 -5
  437. package/dist/measure/plain.js.map +1 -1
  438. package/dist/measure/rich.d.ts +32 -0
  439. package/dist/measure/rich.d.ts.map +1 -1
  440. package/dist/measure/rich.js +227 -35
  441. package/dist/measure/rich.js.map +1 -1
  442. package/dist/measure/script.d.ts +180 -0
  443. package/dist/measure/script.d.ts.map +1 -0
  444. package/dist/measure/script.js +329 -0
  445. package/dist/measure/script.js.map +1 -0
  446. package/dist/measure/spaceRatios.d.ts +28 -0
  447. package/dist/measure/spaceRatios.d.ts.map +1 -0
  448. package/dist/measure/spaceRatios.js +48 -0
  449. package/dist/measure/spaceRatios.js.map +1 -0
  450. package/dist/measure/spaces.d.ts +10 -0
  451. package/dist/measure/spaces.d.ts.map +1 -1
  452. package/dist/measure/spaces.js +36 -0
  453. package/dist/measure/spaces.js.map +1 -1
  454. package/dist/measure/types.d.ts +9 -0
  455. package/dist/measure/types.d.ts.map +1 -1
  456. package/dist/measure/types.js.map +1 -1
  457. package/dist/numbering.d.ts +5 -0
  458. package/dist/numbering.d.ts.map +1 -1
  459. package/dist/numbering.js +5 -1
  460. package/dist/numbering.js.map +1 -1
  461. package/dist/parse/types.d.ts +13 -0
  462. package/dist/parse/types.d.ts.map +1 -1
  463. package/dist/pipeline/bandCaps.d.ts +35 -1
  464. package/dist/pipeline/bandCaps.d.ts.map +1 -1
  465. package/dist/pipeline/bandCaps.js +95 -3
  466. package/dist/pipeline/bandCaps.js.map +1 -1
  467. package/dist/pipeline/build.d.ts.map +1 -1
  468. package/dist/pipeline/build.js +754 -49
  469. package/dist/pipeline/build.js.map +1 -1
  470. package/dist/pipeline/buildHelpers.d.ts.map +1 -1
  471. package/dist/pipeline/buildHelpers.js +5 -1
  472. package/dist/pipeline/buildHelpers.js.map +1 -1
  473. package/dist/pipeline/buildMeasurement.d.ts +9 -0
  474. package/dist/pipeline/buildMeasurement.d.ts.map +1 -1
  475. package/dist/pipeline/buildMeasurement.js +3 -2
  476. package/dist/pipeline/buildMeasurement.js.map +1 -1
  477. package/dist/pipeline/calloutLayout.d.ts +10 -1
  478. package/dist/pipeline/calloutLayout.d.ts.map +1 -1
  479. package/dist/pipeline/calloutLayout.js +45 -9
  480. package/dist/pipeline/calloutLayout.js.map +1 -1
  481. package/dist/pipeline/columnBalancing.d.ts +44 -7
  482. package/dist/pipeline/columnBalancing.d.ts.map +1 -1
  483. package/dist/pipeline/columnBalancing.js +167 -40
  484. package/dist/pipeline/columnBalancing.js.map +1 -1
  485. package/dist/pipeline/config.d.ts +2 -2
  486. package/dist/pipeline/config.d.ts.map +1 -1
  487. package/dist/pipeline/config.js +18 -3
  488. package/dist/pipeline/config.js.map +1 -1
  489. package/dist/pipeline/contentWarnings.d.ts +6 -0
  490. package/dist/pipeline/contentWarnings.d.ts.map +1 -1
  491. package/dist/pipeline/contentWarnings.js +32 -0
  492. package/dist/pipeline/contentWarnings.js.map +1 -1
  493. package/dist/pipeline/crossRefs.d.ts +12 -1
  494. package/dist/pipeline/crossRefs.d.ts.map +1 -1
  495. package/dist/pipeline/crossRefs.js +22 -14
  496. package/dist/pipeline/crossRefs.js.map +1 -1
  497. package/dist/pipeline/flowColumns.d.ts +2 -1
  498. package/dist/pipeline/flowColumns.d.ts.map +1 -1
  499. package/dist/pipeline/flowColumns.js +12 -2
  500. package/dist/pipeline/flowColumns.js.map +1 -1
  501. package/dist/pipeline/footnotes.d.ts.map +1 -1
  502. package/dist/pipeline/footnotes.js +3 -0
  503. package/dist/pipeline/footnotes.js.map +1 -1
  504. package/dist/pipeline/indexDirective.d.ts.map +1 -1
  505. package/dist/pipeline/indexDirective.js +15 -0
  506. package/dist/pipeline/indexDirective.js.map +1 -1
  507. package/dist/pipeline/lists.d.ts +1 -1
  508. package/dist/pipeline/lists.d.ts.map +1 -1
  509. package/dist/pipeline/lists.js +9 -1
  510. package/dist/pipeline/lists.js.map +1 -1
  511. package/dist/pipeline/measureContentBlock.d.ts +18 -0
  512. package/dist/pipeline/measureContentBlock.d.ts.map +1 -1
  513. package/dist/pipeline/measureContentBlock.js +13 -3
  514. package/dist/pipeline/measureContentBlock.js.map +1 -1
  515. package/dist/pipeline/paragraphContainers.d.ts +4 -1
  516. package/dist/pipeline/paragraphContainers.d.ts.map +1 -1
  517. package/dist/pipeline/paragraphContainers.js +2 -0
  518. package/dist/pipeline/paragraphContainers.js.map +1 -1
  519. package/dist/pipeline/placement.d.ts +15 -0
  520. package/dist/pipeline/placement.d.ts.map +1 -1
  521. package/dist/pipeline/placement.js +36 -4
  522. package/dist/pipeline/placement.js.map +1 -1
  523. package/dist/pipeline/raggedLines.d.ts +8 -6
  524. package/dist/pipeline/raggedLines.d.ts.map +1 -1
  525. package/dist/pipeline/raggedLines.js +13 -10
  526. package/dist/pipeline/raggedLines.js.map +1 -1
  527. package/dist/pipeline/resourceLayout.d.ts +4 -0
  528. package/dist/pipeline/resourceLayout.d.ts.map +1 -1
  529. package/dist/pipeline/resourceLayout.js +22 -7
  530. package/dist/pipeline/resourceLayout.js.map +1 -1
  531. package/dist/pipeline/resourceNumbering.d.ts +6 -3
  532. package/dist/pipeline/resourceNumbering.d.ts.map +1 -1
  533. package/dist/pipeline/resourceNumbering.js +36 -19
  534. package/dist/pipeline/resourceNumbering.js.map +1 -1
  535. package/dist/pipeline/toc.d.ts +0 -3
  536. package/dist/pipeline/toc.d.ts.map +1 -1
  537. package/dist/pipeline/toc.js +19 -2
  538. package/dist/pipeline/toc.js.map +1 -1
  539. package/dist/types.d.ts +411 -15
  540. package/dist/types.d.ts.map +1 -1
  541. package/dist/vdt.d.ts +90 -7
  542. package/dist/vdt.d.ts.map +1 -1
  543. package/dist/vdt.js.map +1 -1
  544. package/package.json +1 -1
@@ -36,17 +36,18 @@ import { createBoundingBox } from '../vdt';
36
36
  import { isJapaneseLanguage } from '../locale';
37
37
  import { lineIndentAt, lineInsetsAt, lineMeasure, markInsetLines } from './types';
38
38
  import { measureInkBox, measureInkExtent, measureTextWidth, normalSpaceWidthFor } from './canvas';
39
- import { atomicSpanToken, setLabelTabs, emergencySplit, expandSmallCaps, pickSpanFont, scriptMetrics, setsObject, spanScriptFields, stackedScriptPairs, textWidth, tokenSegment, URL_LIKE_RE, urlBreakIndices, } from './rich';
39
+ import { atomicSpanToken, refLabelTokens, setLabelTabs, emergencySplit, expandSmallCaps, pickSpanFont, scriptMetrics, setsObject, spanScriptFields, stackedScriptPairs, textWidth, tokenSegment, URL_LIKE_RE, urlBreakIndices, } from './rich';
40
40
  import { cjkBreakAllowed, cjkClassOf, getCjkLineBreak, isCjkGrapheme, isFullwidthAlnum, isFullwidthDigit, isJapaneseLineBreak, getCjkCircledNumbers, isLabelEndProhibited, isLineEndProhibited, isLineStartProhibited, isWordInnerMark, setCjkCircledNumbers, } from './cjkClasses';
41
41
  import { hasCJK } from './cjk';
42
42
  import { graphemeCount, graphemesOf, lastGrapheme } from './graphemes';
43
+ import { ratiosOf } from './spaceRatios';
43
44
  import { isBreakingSpace } from './spaces';
44
45
  import { trimChipLineEdges } from './chipEdges';
45
46
  import { cellAdvance, flowTextWidth, fontEm, fontFamilyOf, getMeasureRegion, getMeasureUprightDigits, getMeasureWritingMode, lineBaselineOffset, measureCentralBaseline, verticalTrackCount, withMeasureWritingMode } from './vertical';
46
47
  import { isUprightMarkPair, verticalRuns } from '../writingMode';
47
48
  import { foldWidth, isZhuyin, kuntenGeometry, noteRowBaselines, readingAdvance, readingBaseline, rubyGeometry, splitNote, withFontSize, ZHUYIN_SIZE_RATIO } from './cjkAnnotate';
48
49
  import { boxesWidth, fullSizeKana, layoutJisRuby, layoutJukugo } from './rubyJis';
49
- import { applyLineEdges, blankEnd, blankStart, boxCut, carryStopBlank, compositionFor, compressPair, DEFAULT_TITLE_MIN_CHARS, getCjkComposition, isLatinSpacingHan, isLatinSpacingLatin, isJlreqSpacing, isPlainComposition, jlreqShrinkStep, latinSpacingPx, lineEdgeCut, joinsDashPairs, mayHang, punctuationBox, punctuationShrink, routesSharedMarks, shrinkPunctuation, shrinkStep, } from './cjkPunctuation';
50
+ import { applyLineEdges, blankEnd, blankStart, boxCut, carryStopBlank, compositionFor, compressPair, DEFAULT_NOTE_MIN_CHARS, DEFAULT_TITLE_MIN_CHARS, getCjkComposition, isLatinSpacingHan, isLatinSpacingLatin, isJlreqSpacing, isPlainComposition, jlreqShrinkStep, latinSpacingPx, lineEdgeCut, joinsDashPairs, mayHang, punctuationBox, punctuationShrink, routesSharedMarks, shrinkPunctuation, shrinkStep, } from './cjkPunctuation';
50
51
  /** Fit tolerance of the breaker (px): running sums of many widths may
51
52
  * land a hair past a measure they fill exactly. */
52
53
  const FIT_EPS = 1e-6;
@@ -655,9 +656,30 @@ function buildUnits(spans, fonts, letterSpacingPx, vertical = false, route = fal
655
656
  zwsp = false;
656
657
  continue;
657
658
  }
658
- const atomic = atomicSpanToken(span, fonts.normal, fonts.bold, fonts.italic, fonts.boldItalic, letterSpacingPx);
659
- if (atomic) {
659
+ // A reference whose label is words (#702): one unit per word and per
660
+ // space, each carrying the reference; only the first is glued to the
661
+ // text before it, so a line may break after a space of the label.
662
+ const whole = refLabelTokens(span, fonts.normal, fonts.bold, fonts.italic, fonts.boldItalic, letterSpacingPx)
663
+ ?? atomicSpanToken(span, fonts.normal, fonts.bold, fonts.italic, fonts.boldItalic, letterSpacingPx);
664
+ const atomics = whole === undefined ? [] : Array.isArray(whole) ? whole : [whole];
665
+ for (const [k, atomic] of atomics.entries()) {
660
666
  const style = styleOf(span, fonts, vertical);
667
+ if (atomic.kind === 'space') {
668
+ units.push({
669
+ kind: 'space',
670
+ text: atomic.text,
671
+ width: atomic.width,
672
+ graphemes: graphemeCount(atomic.text),
673
+ first: 'western',
674
+ last: 'western',
675
+ firstCjk: false,
676
+ lastCjk: false,
677
+ style,
678
+ at: 0,
679
+ token: atomic,
680
+ });
681
+ continue;
682
+ }
661
683
  const graphemes = graphemesOf(atomic.text);
662
684
  const object = atomic.chip !== undefined || atomic.mathRender !== undefined || atomic.swatch !== undefined;
663
685
  const firstG = graphemes[0] ?? '';
@@ -674,13 +696,14 @@ function buildUnits(spans, fonts, letterSpacingPx, vertical = false, route = fal
674
696
  style,
675
697
  at: 0,
676
698
  token: atomic,
677
- ...(atomic.refResourceId !== undefined || atomic.footnoteId !== undefined ? { glueBefore: true } : {}),
699
+ ...((atomic.refResourceId !== undefined || atomic.footnoteId !== undefined) && k === 0 ? { glueBefore: true } : {}),
678
700
  ...(zwsp ? { zwspBefore: true } : {}),
679
701
  ...glue(),
680
702
  });
681
703
  zwsp = false;
682
- continue;
683
704
  }
705
+ if (atomics.length > 0)
706
+ continue;
684
707
  if (span.text.length === 0)
685
708
  continue;
686
709
  const style = styleOf(span, fonts, vertical);
@@ -1269,7 +1292,7 @@ function labelEndUnit(units, labelLength) {
1269
1292
  * ・ between kanji numerals is set solid (`Unit.solid`), and with
1270
1293
  * `spaceAfterQuestion` a ? or ! takes its one-em space (`Unit.aki`).
1271
1294
  */
1272
- function prepareUnits(units, c, letterSpacingPx, labelLength = 0) {
1295
+ function prepareUnits(units, c, letterSpacingPx, labelLength = 0, seams) {
1273
1296
  const plain = isPlainComposition(c);
1274
1297
  // Down the line the mainland interpunct's cell is half an em already.
1275
1298
  if (plain && (c.region !== 'mainland' || c.vertical))
@@ -1293,14 +1316,18 @@ function prepareUnits(units, c, letterSpacingPx, labelLength = 0) {
1293
1316
  // 二、三日, 三・一四: the mark between two kanji numerals is its glyph
1294
1317
  // alone (JLReq §3.1.3), and the number is not broken there.
1295
1318
  // A heading's number is not half of a number with its title (#679):
1296
- // the unit that ends it is where the rule stops reading.
1319
+ // the unit that ends it is where the rule stops reading. So is the
1320
+ // seam between a number and a title in a design text (#724).
1297
1321
  const labelEnd = labelLength > 0 ? labelEndUnit(units, labelLength) : -1;
1322
+ const seamEnds = seams?.length ? new Set(seams.filter((s) => s > 0).map((s) => labelEndUnit(units, s))) : undefined;
1298
1323
  for (let k = 1; k + 1 < units.length; k++) {
1299
1324
  const u = units[k];
1300
1325
  if (!u.punct || (u.text !== '、' && u.text !== '・'))
1301
1326
  continue;
1302
1327
  if (k === labelEnd || k - 1 === labelEnd)
1303
1328
  continue;
1329
+ if (seamEnds && (seamEnds.has(k) || seamEnds.has(k - 1)))
1330
+ continue;
1304
1331
  if (!charUnitIn(units[k - 1], KANJI_DIGITS) || !charUnitIn(units[k + 1], KANJI_DIGITS) || units[k + 1].glueBefore)
1305
1332
  continue;
1306
1333
  shrinkPunctuation(u.punct, u.punct.blank);
@@ -1332,14 +1359,17 @@ function prepareUnits(units, c, letterSpacingPx, labelLength = 0) {
1332
1359
  * their logical order; undefined for a unit that is not a chip, or a chip
1333
1360
  * in a superscript or a subscript. */
1334
1361
  function chipEdgeGrapheme(u, edge) {
1335
- const runs = u.kind === 'atomic' && !u.style.script ? u.token?.chip?.runs : undefined;
1336
- if (!runs)
1337
- return undefined;
1338
- const text = runs.map((r) => r.text).join('');
1362
+ const text = chipText(u);
1339
1363
  if (text === '')
1340
1364
  return undefined;
1341
1365
  return edge === 'first' ? String.fromCodePoint(text.codePointAt(0)) : lastGrapheme(text);
1342
1366
  }
1367
+ /** The words of a chip in their logical order; empty for a unit that is
1368
+ * not a chip, or a chip in a superscript or a subscript. */
1369
+ function chipText(u) {
1370
+ const runs = u.kind === 'atomic' && !u.style.script ? u.token?.chip?.runs : undefined;
1371
+ return runs ? runs.map((r) => r.text).join('') : '';
1372
+ }
1343
1373
  /** `units` with the Han–Latin spaces of `cjk.latinSpacing` (see
1344
1374
  * {@link prepareUnits}).
1345
1375
  *
@@ -1353,9 +1383,37 @@ function chipEdgeGrapheme(u, edge) {
1353
1383
  * goes at a line end and is dropped at a line start like any space, and
1354
1384
  * a bracket, a mark or a sign next to the chip is neither Han nor Latin,
1355
1385
  * so 「:chip[x]」 takes none. Down a vertical line the chip is set
1356
- * sideways, as a Latin run is, and the same rule holds. */
1386
+ * sideways, as a Latin run is, and the same rule holds.
1387
+ *
1388
+ * Which edge of a Western word is Latin follows `cjk.latinSpacingEdge`
1389
+ * (#721). `'letters'`: one that is a letter or a digit. `'western'` (the
1390
+ * Japan region's): any edge of a word that holds a letter or a digit,
1391
+ * its brackets and signs being Western characters too (JLReq §3.2.6,
1392
+ * §3.9.2), but for a mark that binds to the other side: an opening
1393
+ * bracket or a prefix sign that ends the word, a closing bracket, a
1394
+ * pause, a stop or a postfix sign that opens it. A word of marks alone
1395
+ * (`(`, `!`) stands in Japanese context and takes none. */
1357
1396
  function latinSpaces(units, c) {
1358
1397
  const out = [];
1398
+ const western = c.latinSpacingEdge === 'western';
1399
+ /** Whether `text` holds a letter or a digit that is not CJK. */
1400
+ const holdsLetter = (text) => {
1401
+ for (const g of text)
1402
+ if (isLatinSpacingLatin(g) && !isCjkGrapheme(g) && !isLatinSpacingHan(g))
1403
+ return true;
1404
+ return false;
1405
+ };
1406
+ /** Whether the edge `g` of the Western word `text` takes the space. */
1407
+ const latinEdge = (text, g, edge) => {
1408
+ if (isLatinSpacingLatin(g))
1409
+ return true;
1410
+ if (!western || g === '\u00A0' || g === '\u202F')
1411
+ return false;
1412
+ const cls = cjkClassOf(g);
1413
+ if (edge === 'last' ? cls === 'opening' || cls === 'prefix' : cls === 'closing' || cls === 'pause' || cls === 'stop' || cls === 'postfix')
1414
+ return false;
1415
+ return holdsLetter(text);
1416
+ };
1359
1417
  const han = (u, edge) => {
1360
1418
  if (!u)
1361
1419
  return false;
@@ -1372,10 +1430,11 @@ function latinSpaces(units, c) {
1372
1430
  if (!u)
1373
1431
  return false;
1374
1432
  const chipEdge = chipEdgeGrapheme(u, edge);
1375
- if (chipEdge !== undefined)
1376
- return !isCjkGrapheme(chipEdge) && !isLatinSpacingHan(chipEdge) && isLatinSpacingLatin(chipEdge);
1433
+ if (chipEdge !== undefined) {
1434
+ return !isCjkGrapheme(chipEdge) && !isLatinSpacingHan(chipEdge) && latinEdge(chipText(u), chipEdge, edge);
1435
+ }
1377
1436
  return u.kind === 'text' && !!u.run && !u.note && !u.style.script && !(edge === 'first' ? u.cellStart : u.cellEnd)
1378
- && isLatinSpacingLatin(edge === 'first' ? String.fromCodePoint(u.text.codePointAt(0)) : lastGrapheme(u.text));
1437
+ && latinEdge(u.text, edge === 'first' ? String.fromCodePoint(u.text.codePointAt(0)) : lastGrapheme(u.text), edge);
1379
1438
  };
1380
1439
  const spaceOf = (h) => latinSpacingPx(c, emOfFont(h.style.font));
1381
1440
  for (let k = 0; k < units.length; k++) {
@@ -1663,6 +1722,47 @@ function titleBreaks(units, breaks, min) {
1663
1722
  }
1664
1723
  return out ?? breaks;
1665
1724
  }
1725
+ /**
1726
+ * The breaks of `breaks` that leave fewer than `min` characters of a
1727
+ * warichu note on either side of them taken out (`cjk.warichu.minChars`,
1728
+ * #720): a line never ends on the first character of a note, and none
1729
+ * opens on its last one with the stop that closes it. A character is a
1730
+ * unit of the note that is a letter ({@link isLetterEdge}: a CJK
1731
+ * character, a Western word, an inline box); marks and the note's word
1732
+ * spaces do not count, so `異。` is one character. The note's brackets are
1733
+ * not part of it. `breaks` itself when no note holds such a break.
1734
+ */
1735
+ function noteBreaks(units, breaks, min) {
1736
+ if (min <= 1)
1737
+ return breaks;
1738
+ const counts = (u) => !u.noteSpace && (isLetterEdge(u, 'first') || isLetterEdge(u, 'last'));
1739
+ let out;
1740
+ for (let from = 0; from < units.length;) {
1741
+ const note = units[from].note;
1742
+ if (!note) {
1743
+ from++;
1744
+ continue;
1745
+ }
1746
+ let to = from + 1;
1747
+ while (to < units.length && units[to].note === note)
1748
+ to++;
1749
+ let total = 0;
1750
+ for (let k = from; k < to; k++)
1751
+ if (counts(units[k]))
1752
+ total++;
1753
+ let before = 0;
1754
+ for (let k = from; k < to; k++) {
1755
+ if (k > from && breaks[k] && (before < min || total - before < min)) {
1756
+ out ??= breaks.slice();
1757
+ out[k] = 0;
1758
+ }
1759
+ if (counts(units[k]))
1760
+ before++;
1761
+ }
1762
+ from = to;
1763
+ }
1764
+ return out ?? breaks;
1765
+ }
1666
1766
  /** Whether a unit opens (`first`) or ends (`last`) with a letter, which
1667
1767
  * `keep-all` never parts from a letter next to it: a CJK character (kanji,
1668
1768
  * kana, hangul, an iteration mark, ー), a Western run or a sign glued to
@@ -2433,6 +2533,9 @@ function composeLine(units, range, li, isLast, ctx) {
2433
2533
  let tracking = 0;
2434
2534
  let loose = false;
2435
2535
  let spaceRatio;
2536
+ // The same spacing as the breaker bounds it, when the line's own spaces
2537
+ // are not regular ones (#704, `justifiedSpaceRatios`).
2538
+ let spaceLimitRatio;
2436
2539
  let ragged = false;
2437
2540
  const stretches = [];
2438
2541
  if (justify) {
@@ -2472,8 +2575,7 @@ function composeLine(units, range, li, isLast, ctx) {
2472
2575
  // Word spaces first, up to half an em each, all set alike.
2473
2576
  spaceWidth = Math.max(widest, Math.min((natural + slack) / spaces, Math.max(ctx.em / 2, widest)));
2474
2577
  slack -= spaceWidth * spaces - natural;
2475
- if (ctx.normalSpace > 0)
2476
- spaceRatio = spaceWidth / ctx.normalSpace;
2578
+ ({ justifiedSpaceRatio: spaceRatio, justifiedSpaceLimitRatio: spaceLimitRatio } = ratiosOf(spaceWidth * spaces, natural, spaces, ctx.normalSpace));
2477
2579
  }
2478
2580
  if (autos.length > 0 && slack > FIT_EPS) {
2479
2581
  // Then the Han–Latin spaces, up to half an em each (clreq
@@ -2512,8 +2614,7 @@ function composeLine(units, range, li, isLast, ctx) {
2512
2614
  // Latin words only (an English sentence in a CJK paragraph): the
2513
2615
  // spaces take it all, as in a Latin line (the renderers stretch
2514
2616
  // them, and a line past the ratio is set ragged).
2515
- if (ctx.normalSpace > 0)
2516
- spaceRatio = (natural + slack) / spaces / ctx.normalSpace;
2617
+ ({ justifiedSpaceRatio: spaceRatio, justifiedSpaceLimitRatio: spaceLimitRatio } = ratiosOf(natural + slack, natural, spaces, ctx.normalSpace));
2517
2618
  }
2518
2619
  else if (us.some((u) => u.kind === 'text' && (u.firstCjk || u.lastCjk))) {
2519
2620
  // A CJK character with nothing to spread against.
@@ -2608,7 +2709,11 @@ function composeLine(units, range, li, isLast, ctx) {
2608
2709
  continue;
2609
2710
  }
2610
2711
  if (u.kind === 'space') {
2611
- pieces.push({ seg: { kind: 'space', text: u.text, width: spaceWidth ?? u.width }, parts: [u.text], key: undefined });
2712
+ // A space inside a reference label (#702) is of the reference.
2713
+ const ref = u.token?.refResourceId !== undefined
2714
+ ? { refResourceId: u.token.refResourceId, ...(u.token.refAnchor ? { refAnchor: true } : {}), ...(u.token.refPageIndex !== undefined ? { refPageIndex: u.token.refPageIndex } : {}), refContinues: true }
2715
+ : {};
2716
+ pieces.push({ seg: { kind: 'space', text: u.text, width: spaceWidth ?? u.width, ...ref }, parts: [u.text], key: undefined });
2612
2717
  continue;
2613
2718
  }
2614
2719
  if (u.kind === 'atomic') {
@@ -2709,7 +2814,7 @@ function composeLine(units, range, li, isLast, ctx) {
2709
2814
  ...(range.hyphenated && range.hardHyphen ? { hardHyphen: true } : {}),
2710
2815
  segments: trimmed,
2711
2816
  isLastLine: isLast,
2712
- ...(spaceRatio !== undefined && !loose ? { justifiedSpaceRatio: spaceRatio } : {}),
2817
+ ...(spaceRatio !== undefined && !loose ? { justifiedSpaceRatio: spaceRatio, ...(spaceLimitRatio !== undefined ? { justifiedSpaceLimitRatio: spaceLimitRatio } : {}) } : {}),
2713
2818
  ...(loose ? { ragged: true, cjkLoose: true } : ragged ? { ragged: true } : {}),
2714
2819
  cjkComposed: true,
2715
2820
  };
@@ -2788,7 +2893,7 @@ export function composeCjkParagraph(spans, normalFont, boldFont, italicFont, bol
2788
2893
  const plainText = spans.map((s) => s.text).join('');
2789
2894
  // Japanese text: only its two-em dashes, drawn as one stroke (#680).
2790
2895
  const route = routesSharedMarks(composition, plainText) || (joinsDashPairs(composition, plainText) ? 'dashes' : false);
2791
- const units = prepareUnits(buildAllUnits(spans, fonts, letterSpacingPx, vertical, route), composition, letterSpacingPx, options?.labelLength);
2896
+ const units = prepareUnits(buildAllUnits(spans, fonts, letterSpacingPx, vertical, route), composition, letterSpacingPx, options?.labelLength, options?.numberSeams);
2792
2897
  // A bibliography label's column (#290).
2793
2898
  if (options?.labelColumnPx !== undefined) {
2794
2899
  setLabelTabs(units, (u) => u.token?.labelTab, options.labelColumnPx, (u, w) => {
@@ -2813,8 +2918,11 @@ export function composeCjkParagraph(spans, normalFont, boldFont, italicFont, bol
2813
2918
  // Book titles keep `cjk.titleMinChars` characters on either side of a
2814
2919
  // break (#637); a line with no other break falls back on the level's.
2815
2920
  const titled = titleBreaks(units, levelBreaks, composition.titleMinChars ?? DEFAULT_TITLE_MIN_CHARS);
2816
- const breaks = keepAll ? keepAllBreaks(units, titled) : titled;
2817
- const emergency = keepAll || titled !== levelBreaks ? levelBreaks : undefined;
2921
+ // A warichu note keeps `cjk.warichu.minChars` of its characters on
2922
+ // either side of a break too (#720), with the same fallback.
2923
+ const noted = noteBreaks(units, titled, composition.noteMinChars ?? DEFAULT_NOTE_MIN_CHARS);
2924
+ const breaks = keepAll ? keepAllBreaks(units, noted) : noted;
2925
+ const emergency = keepAll || noted !== levelBreaks ? levelBreaks : undefined;
2818
2926
  // The first line's indent gives way to an opening bracket that starts it
2819
2927
  // (`paragraphStartIndent`); the others are as asked (`lineIndentAt`).
2820
2928
  const firstIndent = paragraphStartIndent(units, lineIndentAt(options, 0), composition);
@@ -2852,7 +2960,10 @@ export function composeCjkParagraph(spans, normalFont, boldFont, italicFont, bol
2852
2960
  // would need more than the tracking cap, the runt stays. Japanese text
2853
2961
  // (泣き別れ) first tries the other way JLReq prefers (§3.8.2): the line
2854
2962
  // above takes the character in by giving up blank (push-in), and the
2855
- // paragraph is a line shorter.
2963
+ // paragraph is a line shorter. A paragraph that is not justified gives
2964
+ // the character up too, its line above one short. On manuscript paper
2965
+ // (`cjk.grid.fullLines`, #718) it does not: the line above would stay
2966
+ // one cell short, so only a justified line, which is spread, gives it up.
2856
2967
  if ((options?.runtPenalty ?? 0) > 0 && endsOnOneCharacter(lines) && fit?.jlreq) {
2857
2968
  const pulled = breakUnits(units, breaks, measureOf, 0, letterSpacingPx, fit, level, undefined, ranges.length - 2, emergency);
2858
2969
  if (pulled.length === ranges.length - 1) {
@@ -2861,7 +2972,7 @@ export function composeCjkParagraph(spans, normalFont, boldFont, italicFont, bol
2861
2972
  lines = set;
2862
2973
  }
2863
2974
  }
2864
- if ((options?.runtPenalty ?? 0) > 0 && endsOnOneCharacter(lines)) {
2975
+ if ((options?.runtPenalty ?? 0) > 0 && (textAlign === 'justify' || !composition.gridFullLines) && endsOnOneCharacter(lines)) {
2865
2976
  const li = ranges.length - 2;
2866
2977
  const above = ranges[li];
2867
2978
  let at = above.end - 1;
@@ -2922,12 +3033,17 @@ function endsOnOneCharacter(lines) {
2922
3033
  * paragraph quoting CJK): next to its CJK characters, under the document's
2923
3034
  * line-break rules. Each unit is measured once and the widths before a
2924
3035
  * break come from their running sums, so a long run of ideographs costs
2925
- * linear time.
3036
+ * linear time. With `keepAll` (`cjk.wordBreak: 'keep-all'`, or the block's
3037
+ * own rule) no break is left between two letters, as in a paragraph the
3038
+ * composer sets ({@link keepAllBreaks}): a quotation of a few characters
3039
+ * stays whole, and a break next to its punctuation stays where the level
3040
+ * allows it (#705).
2926
3041
  */
2927
- export function cjkWordBreaks(word, font, smallCaps, letterSpacingPx, level = getCjkLineBreak()) {
3042
+ export function cjkWordBreaks(word, font, smallCaps, letterSpacingPx, level = getCjkLineBreak(), keepAll = false) {
2928
3043
  const span = { text: word, bold: false, italic: false, ...(smallCaps ? { smallCaps: true } : {}) };
2929
3044
  const units = buildUnits([span], { normal: font, bold: font, italic: font, boldItalic: font }, letterSpacingPx, getMeasureWritingMode() === 'vertical-rl');
2930
- const opportunities = breakOpportunities(units, level);
3045
+ const levelBreaks = breakOpportunities(units, level);
3046
+ const opportunities = keepAll ? keepAllBreaks(units, levelBreaks) : levelBreaks;
2931
3047
  const starts = [];
2932
3048
  const sums = [0];
2933
3049
  const breaks = [];