postext 1.15.0 → 1.16.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 (423) hide show
  1. package/dist/__tests__/arabic/harakatProfile.test.d.ts +2 -0
  2. package/dist/__tests__/arabic/harakatProfile.test.d.ts.map +1 -0
  3. package/dist/__tests__/arabic/harakatProfile.test.js +105 -0
  4. package/dist/__tests__/arabic/harakatProfile.test.js.map +1 -0
  5. package/dist/__tests__/bundleLocaleAndBytes.test.js +9 -9
  6. package/dist/__tests__/bundleLocaleAndBytes.test.js.map +1 -1
  7. package/dist/__tests__/chineseLocale.test.js +10 -5
  8. package/dist/__tests__/chineseLocale.test.js.map +1 -1
  9. package/dist/__tests__/cjk/annotationsRender.test.js +5 -2
  10. package/dist/__tests__/cjk/annotationsRender.test.js.map +1 -1
  11. package/dist/__tests__/cjk/chipTracking.test.d.ts +2 -0
  12. package/dist/__tests__/cjk/chipTracking.test.d.ts.map +1 -0
  13. package/dist/__tests__/cjk/chipTracking.test.js +52 -0
  14. package/dist/__tests__/cjk/chipTracking.test.js.map +1 -0
  15. package/dist/__tests__/cjk/japaneseHtml.test.d.ts +2 -0
  16. package/dist/__tests__/cjk/japaneseHtml.test.d.ts.map +1 -0
  17. package/dist/__tests__/cjk/japaneseHtml.test.js +163 -0
  18. package/dist/__tests__/cjk/japaneseHtml.test.js.map +1 -0
  19. package/dist/__tests__/cjk/japaneseMarks.test.d.ts +2 -0
  20. package/dist/__tests__/cjk/japaneseMarks.test.d.ts.map +1 -0
  21. package/dist/__tests__/cjk/japaneseMarks.test.js +289 -0
  22. package/dist/__tests__/cjk/japaneseMarks.test.js.map +1 -0
  23. package/dist/__tests__/cjk/japaneseMarksRender.test.d.ts +2 -0
  24. package/dist/__tests__/cjk/japaneseMarksRender.test.d.ts.map +1 -0
  25. package/dist/__tests__/cjk/japaneseMarksRender.test.js +161 -0
  26. package/dist/__tests__/cjk/japaneseMarksRender.test.js.map +1 -0
  27. package/dist/__tests__/cjk/japaneseRuby.test.d.ts +2 -0
  28. package/dist/__tests__/cjk/japaneseRuby.test.d.ts.map +1 -0
  29. package/dist/__tests__/cjk/japaneseRuby.test.js +457 -0
  30. package/dist/__tests__/cjk/japaneseRuby.test.js.map +1 -0
  31. package/dist/__tests__/cjk/japaneseSegmentLanguage.test.d.ts +2 -0
  32. package/dist/__tests__/cjk/japaneseSegmentLanguage.test.d.ts.map +1 -0
  33. package/dist/__tests__/cjk/japaneseSegmentLanguage.test.js +50 -0
  34. package/dist/__tests__/cjk/japaneseSegmentLanguage.test.js.map +1 -0
  35. package/dist/__tests__/cjk/japaneseSpacing.test.d.ts +2 -0
  36. package/dist/__tests__/cjk/japaneseSpacing.test.d.ts.map +1 -0
  37. package/dist/__tests__/cjk/japaneseSpacing.test.js +417 -0
  38. package/dist/__tests__/cjk/japaneseSpacing.test.js.map +1 -0
  39. package/dist/__tests__/cjk/kanbunKunten.test.d.ts +2 -0
  40. package/dist/__tests__/cjk/kanbunKunten.test.d.ts.map +1 -0
  41. package/dist/__tests__/cjk/kanbunKunten.test.js +230 -0
  42. package/dist/__tests__/cjk/kanbunKunten.test.js.map +1 -0
  43. package/dist/__tests__/cjk/kanbunKuntenRender.test.d.ts +2 -0
  44. package/dist/__tests__/cjk/kanbunKuntenRender.test.d.ts.map +1 -0
  45. package/dist/__tests__/cjk/kanbunKuntenRender.test.js +127 -0
  46. package/dist/__tests__/cjk/kanbunKuntenRender.test.js.map +1 -0
  47. package/dist/__tests__/cjk/kinsokuJa.test.d.ts +2 -0
  48. package/dist/__tests__/cjk/kinsokuJa.test.d.ts.map +1 -0
  49. package/dist/__tests__/cjk/kinsokuJa.test.js +388 -0
  50. package/dist/__tests__/cjk/kinsokuJa.test.js.map +1 -0
  51. package/dist/__tests__/cjk/kinsokuJaBuild.test.d.ts +2 -0
  52. package/dist/__tests__/cjk/kinsokuJaBuild.test.d.ts.map +1 -0
  53. package/dist/__tests__/cjk/kinsokuJaBuild.test.js +38 -0
  54. package/dist/__tests__/cjk/kinsokuJaBuild.test.js.map +1 -0
  55. package/dist/__tests__/cjk/resourceAnnotations.test.d.ts +2 -0
  56. package/dist/__tests__/cjk/resourceAnnotations.test.d.ts.map +1 -0
  57. package/dist/__tests__/cjk/resourceAnnotations.test.js +223 -0
  58. package/dist/__tests__/cjk/resourceAnnotations.test.js.map +1 -0
  59. package/dist/__tests__/defaults/cjk.test.js +10 -2
  60. package/dist/__tests__/defaults/cjk.test.js.map +1 -1
  61. package/dist/__tests__/exports.test.js +36 -0
  62. package/dist/__tests__/exports.test.js.map +1 -1
  63. package/dist/__tests__/headingLetterSpacing.test.js +2 -1
  64. package/dist/__tests__/headingLetterSpacing.test.js.map +1 -1
  65. package/dist/__tests__/indexChinese.test.js +1 -1
  66. package/dist/__tests__/indexJapanese.test.d.ts +2 -0
  67. package/dist/__tests__/indexJapanese.test.d.ts.map +1 -0
  68. package/dist/__tests__/indexJapanese.test.js +242 -0
  69. package/dist/__tests__/indexJapanese.test.js.map +1 -0
  70. package/dist/__tests__/japaneseHeadings.test.d.ts +2 -0
  71. package/dist/__tests__/japaneseHeadings.test.d.ts.map +1 -0
  72. package/dist/__tests__/japaneseHeadings.test.js +319 -0
  73. package/dist/__tests__/japaneseHeadings.test.js.map +1 -0
  74. package/dist/__tests__/japaneseLocale.test.d.ts +2 -0
  75. package/dist/__tests__/japaneseLocale.test.d.ts.map +1 -0
  76. package/dist/__tests__/japaneseLocale.test.js +201 -0
  77. package/dist/__tests__/japaneseLocale.test.js.map +1 -0
  78. package/dist/__tests__/japaneseNotes.test.d.ts +2 -0
  79. package/dist/__tests__/japaneseNotes.test.d.ts.map +1 -0
  80. package/dist/__tests__/japaneseNotes.test.js +336 -0
  81. package/dist/__tests__/japaneseNotes.test.js.map +1 -0
  82. package/dist/__tests__/japaneseNumbering.test.d.ts +2 -0
  83. package/dist/__tests__/japaneseNumbering.test.d.ts.map +1 -0
  84. package/dist/__tests__/japaneseNumbering.test.js +292 -0
  85. package/dist/__tests__/japaneseNumbering.test.js.map +1 -0
  86. package/dist/__tests__/parse/anchors.test.js +17 -0
  87. package/dist/__tests__/parse/anchors.test.js.map +1 -1
  88. package/dist/__tests__/pipeline/citationsJapanese.test.d.ts +2 -0
  89. package/dist/__tests__/pipeline/citationsJapanese.test.d.ts.map +1 -0
  90. package/dist/__tests__/pipeline/citationsJapanese.test.js +110 -0
  91. package/dist/__tests__/pipeline/citationsJapanese.test.js.map +1 -0
  92. package/dist/__tests__/pipeline/paragraphStyleFaces.test.js +1 -1
  93. package/dist/__tests__/pipeline/paragraphStyleFaces.test.js.map +1 -1
  94. package/dist/__tests__/pipeline/safeArea.test.d.ts +2 -0
  95. package/dist/__tests__/pipeline/safeArea.test.d.ts.map +1 -0
  96. package/dist/__tests__/pipeline/safeArea.test.js +207 -0
  97. package/dist/__tests__/pipeline/safeArea.test.js.map +1 -0
  98. package/dist/__tests__/vertical/compositionPaint.test.js +6 -5
  99. package/dist/__tests__/vertical/compositionPaint.test.js.map +1 -1
  100. package/dist/__tests__/vertical/japaneseVertical.test.d.ts +2 -0
  101. package/dist/__tests__/vertical/japaneseVertical.test.d.ts.map +1 -0
  102. package/dist/__tests__/vertical/japaneseVertical.test.js +247 -0
  103. package/dist/__tests__/vertical/japaneseVertical.test.js.map +1 -0
  104. package/dist/__tests__/vertical/verticalSpans.d.ts +2 -1
  105. package/dist/__tests__/vertical/verticalSpans.d.ts.map +1 -1
  106. package/dist/__tests__/vertical/verticalSpans.js +3 -2
  107. package/dist/__tests__/vertical/verticalSpans.js.map +1 -1
  108. package/dist/__tests__/video.test.d.ts +2 -0
  109. package/dist/__tests__/video.test.d.ts.map +1 -0
  110. package/dist/__tests__/video.test.js +305 -0
  111. package/dist/__tests__/video.test.js.map +1 -0
  112. package/dist/arabicMarks.d.ts +11 -1
  113. package/dist/arabicMarks.d.ts.map +1 -1
  114. package/dist/arabicMarks.js +72 -5
  115. package/dist/arabicMarks.js.map +1 -1
  116. package/dist/bundle/adapters.d.ts +6 -0
  117. package/dist/bundle/adapters.d.ts.map +1 -1
  118. package/dist/bundle/adapters.js +30 -0
  119. package/dist/bundle/adapters.js.map +1 -1
  120. package/dist/bundle/codec.d.ts.map +1 -1
  121. package/dist/bundle/codec.js +67 -3
  122. package/dist/bundle/codec.js.map +1 -1
  123. package/dist/bundle/index.d.ts +2 -2
  124. package/dist/bundle/index.d.ts.map +1 -1
  125. package/dist/bundle/index.js +2 -2
  126. package/dist/bundle/index.js.map +1 -1
  127. package/dist/bundle/manifest.d.ts +8 -0
  128. package/dist/bundle/manifest.d.ts.map +1 -1
  129. package/dist/bundle/manifest.js +48 -1
  130. package/dist/bundle/manifest.js.map +1 -1
  131. package/dist/bundle/types.d.ts +5 -0
  132. package/dist/bundle/types.d.ts.map +1 -1
  133. package/dist/bundle/zip.js +1 -1
  134. package/dist/bundle/zip.js.map +1 -1
  135. package/dist/canvas-backend/annotations.d.ts +20 -5
  136. package/dist/canvas-backend/annotations.d.ts.map +1 -1
  137. package/dist/canvas-backend/annotations.js +59 -6
  138. package/dist/canvas-backend/annotations.js.map +1 -1
  139. package/dist/canvas-backend/blockRender.d.ts.map +1 -1
  140. package/dist/canvas-backend/blockRender.js +29 -3
  141. package/dist/canvas-backend/blockRender.js.map +1 -1
  142. package/dist/canvas-backend/renderResourceBlock.d.ts +6 -1
  143. package/dist/canvas-backend/renderResourceBlock.d.ts.map +1 -1
  144. package/dist/canvas-backend/renderResourceBlock.js +124 -5
  145. package/dist/canvas-backend/renderResourceBlock.js.map +1 -1
  146. package/dist/canvas-backend/verticalText.d.ts +9 -4
  147. package/dist/canvas-backend/verticalText.d.ts.map +1 -1
  148. package/dist/canvas-backend/verticalText.js +20 -9
  149. package/dist/canvas-backend/verticalText.js.map +1 -1
  150. package/dist/chineseNumerals.d.ts +3 -2
  151. package/dist/chineseNumerals.d.ts.map +1 -1
  152. package/dist/chineseNumerals.js +11 -8
  153. package/dist/chineseNumerals.js.map +1 -1
  154. package/dist/citations/bibtex.d.ts.map +1 -1
  155. package/dist/citations/bibtex.js +4 -0
  156. package/dist/citations/bibtex.js.map +1 -1
  157. package/dist/citations/data.d.ts.map +1 -1
  158. package/dist/citations/data.js +6 -1
  159. package/dist/citations/data.js.map +1 -1
  160. package/dist/citations/types.d.ts +8 -0
  161. package/dist/citations/types.d.ts.map +1 -1
  162. package/dist/cjkMarks.d.ts +23 -14
  163. package/dist/cjkMarks.d.ts.map +1 -1
  164. package/dist/cjkMarks.js +251 -49
  165. package/dist/cjkMarks.js.map +1 -1
  166. package/dist/configWarnings.js +9 -3
  167. package/dist/configWarnings.js.map +1 -1
  168. package/dist/defaults/cjk.d.ts +64 -14
  169. package/dist/defaults/cjk.d.ts.map +1 -1
  170. package/dist/defaults/cjk.js +203 -29
  171. package/dist/defaults/cjk.js.map +1 -1
  172. package/dist/defaults/footnotes.d.ts +27 -4
  173. package/dist/defaults/footnotes.d.ts.map +1 -1
  174. package/dist/defaults/footnotes.js +95 -36
  175. package/dist/defaults/footnotes.js.map +1 -1
  176. package/dist/defaults/headings.d.ts +5 -0
  177. package/dist/defaults/headings.d.ts.map +1 -1
  178. package/dist/defaults/headings.js +46 -1
  179. package/dist/defaults/headings.js.map +1 -1
  180. package/dist/defaults/index.d.ts +3 -2
  181. package/dist/defaults/index.d.ts.map +1 -1
  182. package/dist/defaults/index.js +12 -3
  183. package/dist/defaults/index.js.map +1 -1
  184. package/dist/defaults/indexConfig.d.ts.map +1 -1
  185. package/dist/defaults/indexConfig.js +7 -4
  186. package/dist/defaults/indexConfig.js.map +1 -1
  187. package/dist/defaults/paragraphStyles.d.ts.map +1 -1
  188. package/dist/defaults/paragraphStyles.js +4 -0
  189. package/dist/defaults/paragraphStyles.js.map +1 -1
  190. package/dist/defaults/resourceTypes.d.ts +16 -3
  191. package/dist/defaults/resourceTypes.d.ts.map +1 -1
  192. package/dist/defaults/resourceTypes.js +56 -8
  193. package/dist/defaults/resourceTypes.js.map +1 -1
  194. package/dist/defaults/shared.d.ts.map +1 -1
  195. package/dist/defaults/shared.js +21 -0
  196. package/dist/defaults/shared.js.map +1 -1
  197. package/dist/defaults/tableStyle.d.ts.map +1 -1
  198. package/dist/defaults/tableStyle.js +4 -1
  199. package/dist/defaults/tableStyle.js.map +1 -1
  200. package/dist/defaults/videoStyle.d.ts +9 -0
  201. package/dist/defaults/videoStyle.d.ts.map +1 -0
  202. package/dist/defaults/videoStyle.js +130 -0
  203. package/dist/defaults/videoStyle.js.map +1 -0
  204. package/dist/design/placeholders.d.ts.map +1 -1
  205. package/dist/design/placeholders.js +5 -3
  206. package/dist/design/placeholders.js.map +1 -1
  207. package/dist/html-backend.d.ts +13 -0
  208. package/dist/html-backend.d.ts.map +1 -1
  209. package/dist/html-backend.js +233 -26
  210. package/dist/html-backend.js.map +1 -1
  211. package/dist/htmlAnnotations.d.ts +47 -9
  212. package/dist/htmlAnnotations.d.ts.map +1 -1
  213. package/dist/htmlAnnotations.js +89 -17
  214. package/dist/htmlAnnotations.js.map +1 -1
  215. package/dist/index.d.ts +13 -7
  216. package/dist/index.d.ts.map +1 -1
  217. package/dist/index.js +8 -4
  218. package/dist/index.js.map +1 -1
  219. package/dist/japaneseNumerals.d.ts +44 -0
  220. package/dist/japaneseNumerals.d.ts.map +1 -0
  221. package/dist/japaneseNumerals.js +100 -0
  222. package/dist/japaneseNumerals.js.map +1 -0
  223. package/dist/knuthPlass/richAdapter.d.ts +5 -1
  224. package/dist/knuthPlass/richAdapter.d.ts.map +1 -1
  225. package/dist/knuthPlass/richAdapter.js +2 -0
  226. package/dist/knuthPlass/richAdapter.js.map +1 -1
  227. package/dist/locale.d.ts +19 -12
  228. package/dist/locale.d.ts.map +1 -1
  229. package/dist/locale.js +24 -12
  230. package/dist/locale.js.map +1 -1
  231. package/dist/measure/cache.d.ts.map +1 -1
  232. package/dist/measure/cache.js +17 -8
  233. package/dist/measure/cache.js.map +1 -1
  234. package/dist/measure/canvas.d.ts +21 -0
  235. package/dist/measure/canvas.d.ts.map +1 -1
  236. package/dist/measure/canvas.js +82 -0
  237. package/dist/measure/canvas.js.map +1 -1
  238. package/dist/measure/cjk.d.ts +3 -1
  239. package/dist/measure/cjk.d.ts.map +1 -1
  240. package/dist/measure/cjk.js +4 -2
  241. package/dist/measure/cjk.js.map +1 -1
  242. package/dist/measure/cjkAnnotate.d.ts +62 -3
  243. package/dist/measure/cjkAnnotate.d.ts.map +1 -1
  244. package/dist/measure/cjkAnnotate.js +99 -2
  245. package/dist/measure/cjkAnnotate.js.map +1 -1
  246. package/dist/measure/cjkClasses.d.ts +93 -13
  247. package/dist/measure/cjkClasses.d.ts.map +1 -1
  248. package/dist/measure/cjkClasses.js +204 -14
  249. package/dist/measure/cjkClasses.js.map +1 -1
  250. package/dist/measure/cjkCompose.d.ts +10 -4
  251. package/dist/measure/cjkCompose.d.ts.map +1 -1
  252. package/dist/measure/cjkCompose.js +715 -75
  253. package/dist/measure/cjkCompose.js.map +1 -1
  254. package/dist/measure/cjkPunctuation.d.ts +68 -14
  255. package/dist/measure/cjkPunctuation.d.ts.map +1 -1
  256. package/dist/measure/cjkPunctuation.js +96 -21
  257. package/dist/measure/cjkPunctuation.js.map +1 -1
  258. package/dist/measure/plain.js +2 -2
  259. package/dist/measure/plain.js.map +1 -1
  260. package/dist/measure/rich.d.ts +12 -2
  261. package/dist/measure/rich.d.ts.map +1 -1
  262. package/dist/measure/rich.js +46 -8
  263. package/dist/measure/rich.js.map +1 -1
  264. package/dist/measure/rubyJis.d.ts +96 -0
  265. package/dist/measure/rubyJis.d.ts.map +1 -0
  266. package/dist/measure/rubyJis.js +245 -0
  267. package/dist/measure/rubyJis.js.map +1 -0
  268. package/dist/measure/vertical.d.ts +13 -5
  269. package/dist/measure/vertical.d.ts.map +1 -1
  270. package/dist/measure/vertical.js +16 -6
  271. package/dist/measure/vertical.js.map +1 -1
  272. package/dist/numberWords.d.ts +4 -3
  273. package/dist/numberWords.d.ts.map +1 -1
  274. package/dist/numberWords.js +15 -5
  275. package/dist/numberWords.js.map +1 -1
  276. package/dist/numbering.d.ts +24 -12
  277. package/dist/numbering.d.ts.map +1 -1
  278. package/dist/numbering.js +57 -11
  279. package/dist/numbering.js.map +1 -1
  280. package/dist/parse/annotations.d.ts +21 -18
  281. package/dist/parse/annotations.d.ts.map +1 -1
  282. package/dist/parse/annotations.js +140 -51
  283. package/dist/parse/annotations.js.map +1 -1
  284. package/dist/parse/index.d.ts +1 -1
  285. package/dist/parse/index.d.ts.map +1 -1
  286. package/dist/parse/index.js.map +1 -1
  287. package/dist/parse/indexMarks.d.ts.map +1 -1
  288. package/dist/parse/indexMarks.js +74 -10
  289. package/dist/parse/indexMarks.js.map +1 -1
  290. package/dist/parse/inlineFormatting.d.ts +4 -3
  291. package/dist/parse/inlineFormatting.d.ts.map +1 -1
  292. package/dist/parse/inlineFormatting.js +9 -8
  293. package/dist/parse/inlineFormatting.js.map +1 -1
  294. package/dist/parse/types.d.ts +93 -5
  295. package/dist/parse/types.d.ts.map +1 -1
  296. package/dist/pipeline/annotations.d.ts +25 -15
  297. package/dist/pipeline/annotations.d.ts.map +1 -1
  298. package/dist/pipeline/annotations.js +102 -16
  299. package/dist/pipeline/annotations.js.map +1 -1
  300. package/dist/pipeline/build.d.ts.map +1 -1
  301. package/dist/pipeline/build.js +284 -31
  302. package/dist/pipeline/build.js.map +1 -1
  303. package/dist/pipeline/buildBlockKind.js +2 -1
  304. package/dist/pipeline/buildBlockKind.js.map +1 -1
  305. package/dist/pipeline/buildHelpers.d.ts +2 -0
  306. package/dist/pipeline/buildHelpers.d.ts.map +1 -1
  307. package/dist/pipeline/buildHelpers.js +17 -0
  308. package/dist/pipeline/buildHelpers.js.map +1 -1
  309. package/dist/pipeline/buildMeasurement.d.ts +3 -0
  310. package/dist/pipeline/buildMeasurement.d.ts.map +1 -1
  311. package/dist/pipeline/buildMeasurement.js +1 -0
  312. package/dist/pipeline/buildMeasurement.js.map +1 -1
  313. package/dist/pipeline/calloutLayout.d.ts +2 -0
  314. package/dist/pipeline/calloutLayout.d.ts.map +1 -1
  315. package/dist/pipeline/calloutLayout.js +5 -5
  316. package/dist/pipeline/calloutLayout.js.map +1 -1
  317. package/dist/pipeline/citations.d.ts +1 -1
  318. package/dist/pipeline/citations.d.ts.map +1 -1
  319. package/dist/pipeline/citations.js +15 -7
  320. package/dist/pipeline/citations.js.map +1 -1
  321. package/dist/pipeline/columnBalancing.d.ts +22 -0
  322. package/dist/pipeline/columnBalancing.d.ts.map +1 -1
  323. package/dist/pipeline/columnBalancing.js +80 -3
  324. package/dist/pipeline/columnBalancing.js.map +1 -1
  325. package/dist/pipeline/config.d.ts.map +1 -1
  326. package/dist/pipeline/config.js +3 -2
  327. package/dist/pipeline/config.js.map +1 -1
  328. package/dist/pipeline/contentWarnings.d.ts.map +1 -1
  329. package/dist/pipeline/contentWarnings.js +19 -0
  330. package/dist/pipeline/contentWarnings.js.map +1 -1
  331. package/dist/pipeline/continuation.d.ts.map +1 -1
  332. package/dist/pipeline/continuation.js +3 -3
  333. package/dist/pipeline/continuation.js.map +1 -1
  334. package/dist/pipeline/crossRefs.d.ts.map +1 -1
  335. package/dist/pipeline/crossRefs.js +3 -0
  336. package/dist/pipeline/crossRefs.js.map +1 -1
  337. package/dist/pipeline/footnotes.d.ts +20 -12
  338. package/dist/pipeline/footnotes.d.ts.map +1 -1
  339. package/dist/pipeline/footnotes.js +62 -16
  340. package/dist/pipeline/footnotes.js.map +1 -1
  341. package/dist/pipeline/headingStyles.js +1 -1
  342. package/dist/pipeline/headingStyles.js.map +1 -1
  343. package/dist/pipeline/indexDirective.d.ts.map +1 -1
  344. package/dist/pipeline/indexDirective.js +89 -12
  345. package/dist/pipeline/indexDirective.js.map +1 -1
  346. package/dist/pipeline/indexGroups.d.ts +5 -3
  347. package/dist/pipeline/indexGroups.d.ts.map +1 -1
  348. package/dist/pipeline/indexGroups.js +9 -4
  349. package/dist/pipeline/indexGroups.js.map +1 -1
  350. package/dist/pipeline/indexJapanese.d.ts +75 -0
  351. package/dist/pipeline/indexJapanese.d.ts.map +1 -0
  352. package/dist/pipeline/indexJapanese.js +264 -0
  353. package/dist/pipeline/indexJapanese.js.map +1 -0
  354. package/dist/pipeline/lineSpan.d.ts +36 -0
  355. package/dist/pipeline/lineSpan.d.ts.map +1 -0
  356. package/dist/pipeline/lineSpan.js +36 -0
  357. package/dist/pipeline/lineSpan.js.map +1 -0
  358. package/dist/pipeline/lists.js +2 -2
  359. package/dist/pipeline/lists.js.map +1 -1
  360. package/dist/pipeline/measureContentBlock.d.ts +4 -0
  361. package/dist/pipeline/measureContentBlock.d.ts.map +1 -1
  362. package/dist/pipeline/measureContentBlock.js +54 -5
  363. package/dist/pipeline/measureContentBlock.js.map +1 -1
  364. package/dist/pipeline/outline.d.ts.map +1 -1
  365. package/dist/pipeline/outline.js +3 -1
  366. package/dist/pipeline/outline.js.map +1 -1
  367. package/dist/pipeline/paragraphContainers.d.ts +25 -2
  368. package/dist/pipeline/paragraphContainers.d.ts.map +1 -1
  369. package/dist/pipeline/paragraphContainers.js +82 -2
  370. package/dist/pipeline/paragraphContainers.js.map +1 -1
  371. package/dist/pipeline/parts.d.ts +2 -2
  372. package/dist/pipeline/parts.js +3 -3
  373. package/dist/pipeline/parts.js.map +1 -1
  374. package/dist/pipeline/placement.d.ts.map +1 -1
  375. package/dist/pipeline/placement.js +2 -2
  376. package/dist/pipeline/placement.js.map +1 -1
  377. package/dist/pipeline/resourceLayout.d.ts +6 -0
  378. package/dist/pipeline/resourceLayout.d.ts.map +1 -1
  379. package/dist/pipeline/resourceLayout.js +85 -15
  380. package/dist/pipeline/resourceLayout.js.map +1 -1
  381. package/dist/pipeline/resourceNumbering.d.ts +5 -2
  382. package/dist/pipeline/resourceNumbering.d.ts.map +1 -1
  383. package/dist/pipeline/resourceNumbering.js +12 -7
  384. package/dist/pipeline/resourceNumbering.js.map +1 -1
  385. package/dist/pipeline/safeArea.d.ts +29 -0
  386. package/dist/pipeline/safeArea.d.ts.map +1 -0
  387. package/dist/pipeline/safeArea.js +89 -0
  388. package/dist/pipeline/safeArea.js.map +1 -0
  389. package/dist/pipeline/styles.d.ts +12 -0
  390. package/dist/pipeline/styles.d.ts.map +1 -1
  391. package/dist/pipeline/styles.js +7 -1
  392. package/dist/pipeline/styles.js.map +1 -1
  393. package/dist/pipeline/verse.d.ts +3 -0
  394. package/dist/pipeline/verse.d.ts.map +1 -1
  395. package/dist/pipeline/verse.js +1 -1
  396. package/dist/pipeline/verse.js.map +1 -1
  397. package/dist/pipeline/verticalMetrics.d.ts.map +1 -1
  398. package/dist/pipeline/verticalMetrics.js +4 -0
  399. package/dist/pipeline/verticalMetrics.js.map +1 -1
  400. package/dist/pipeline/videoOverlay.d.ts +24 -0
  401. package/dist/pipeline/videoOverlay.d.ts.map +1 -0
  402. package/dist/pipeline/videoOverlay.js +134 -0
  403. package/dist/pipeline/videoOverlay.js.map +1 -0
  404. package/dist/types.d.ts +567 -50
  405. package/dist/types.d.ts.map +1 -1
  406. package/dist/uprightArabic.js +1 -1
  407. package/dist/uprightArabic.js.map +1 -1
  408. package/dist/vdt.d.ts +221 -17
  409. package/dist/vdt.d.ts.map +1 -1
  410. package/dist/vdt.js.map +1 -1
  411. package/dist/video/qr.d.ts +21 -0
  412. package/dist/video/qr.d.ts.map +1 -0
  413. package/dist/video/qr.js +326 -0
  414. package/dist/video/qr.js.map +1 -0
  415. package/dist/video/url.d.ts +62 -0
  416. package/dist/video/url.d.ts.map +1 -0
  417. package/dist/video/url.js +206 -0
  418. package/dist/video/url.js.map +1 -0
  419. package/dist/writingMode.d.ts +74 -20
  420. package/dist/writingMode.d.ts.map +1 -1
  421. package/dist/writingMode.js +146 -27
  422. package/dist/writingMode.js.map +1 -1
  423. package/package.json +1 -1
@@ -4,14 +4,16 @@ import { dimensionToPx } from './units';
4
4
  import { documentInkHex, isSingleInkSvgUrl, singleInkColorMatrix } from './svg/singleInk';
5
5
  import { lineInkExtent, lineTrailingTracking } from './lineInk';
6
6
  import { CHARACTER_GRID_COLOR, cjkGridCells } from './pipeline/cjkGrid';
7
- import { renderLangOf } from './locale';
7
+ import { isJapaneseLanguage, renderLangOf } from './locale';
8
8
  import { hasCJK } from './measure/cjk';
9
9
  import { joiningScriptIn } from './measure/joining';
10
10
  import { DEFAULT_CENTRAL_BASELINE, verticalFlowOf } from './vdt';
11
11
  import { holdsTurnedMark, segmentOrientation, verticalRuns } from './writingMode';
12
12
  import { graphemesOf } from './measure/graphemes';
13
13
  import { fontFamilyOf } from './measure/vertical';
14
- import { lineMarksHtml, rubyHtml, verticalLineMarksHtml, warichuHtml } from './htmlAnnotations';
14
+ import { lineMarksHtml, rubyHtml, verticalLineMarksHtml, warichuHtml, sideMarkerHtml, RT_OPEN, RUBY_OPEN, rubyGroupOf, kuntenHtml, verticalKuntenTateHtml } from './htmlAnnotations';
15
+ import { playMarkTriangle, qrModuleRuns } from './pipeline/videoOverlay';
16
+ import { mediaFragment, videoElementAttributes, videoEmbedAllow } from './video/url';
15
17
  /**
16
18
  * Declarations of every box of CJK text measured with no punctuation
17
19
  * trimming: the browser adds and removes nothing. Chrome's
@@ -433,6 +435,38 @@ function linkRuns() {
433
435
  end,
434
436
  };
435
437
  }
438
+ /**
439
+ * The `<ruby>` elements of a line (#428, see {@link RUBY_OPEN}): `open`
440
+ * returns the markup before a ruby base (the `<ruby>`, unless the base
441
+ * goes on in the one already open), `after` the markup after its reading
442
+ * (`</ruby>`, unless the base names its annotation: the next base may go
443
+ * on in it), `before` the markup to emit before any segment (closing a
444
+ * `<ruby>` the segment does not go on in), `end` the markup that closes
445
+ * the line. The bases of one annotation (`rubyGroupOf`) share a `<ruby>`
446
+ * while they follow each other with the same link, so the element never
447
+ * straddles an `<a>` of {@link linkRuns}.
448
+ */
449
+ function rubyRuns() {
450
+ let open;
451
+ const end = () => {
452
+ const close = open !== undefined ? '</ruby>' : '';
453
+ open = undefined;
454
+ return close;
455
+ };
456
+ const continues = (seg) => open?.group !== undefined && seg.kind === 'text' && seg.ruby !== undefined && !seg.warichu && !seg.chip
457
+ && seg.refResourceId === undefined && rubyGroupOf(seg.ruby) === open.group && segmentHref(seg) === open.href;
458
+ return {
459
+ before: (seg) => (continues(seg) ? '' : end()),
460
+ open(seg) {
461
+ if (open !== undefined)
462
+ return '';
463
+ open = { group: seg.ruby ? rubyGroupOf(seg.ruby) : undefined, href: segmentHref(seg) };
464
+ return RUBY_OPEN;
465
+ },
466
+ after: (seg) => (open?.group === undefined || seg.refResourceId !== undefined ? end() : ''),
467
+ end,
468
+ };
469
+ }
436
470
  /** A segment's link, unless it is a `:ref` (which links to its resource):
437
471
  * a Markdown link's URL, a footnote marker's note, an index page number's
438
472
  * page (#264). */
@@ -609,6 +643,12 @@ end = '') {
609
643
  x += seg.width;
610
644
  continue;
611
645
  }
646
+ if (seg.sideMarker) {
647
+ // A footnote marker in the line gap (JLReq §4.2.3).
648
+ parts.push(sideMarkerHtml(seg.sideMarker, x, pickSegmentColor(seg, block), quoteFontString));
649
+ x += seg.width;
650
+ continue;
651
+ }
612
652
  if (seg.refResourceId !== undefined && segs[i + 1]?.refContinues) {
613
653
  const group = renderRefRuns(segs, i, x, pickSegmentColor(seg, block), (run, at) => paintText(run, at, true), refLinks(refKey(seg), targets));
614
654
  parts.push(group.html);
@@ -704,8 +744,11 @@ function renderComposedSegments(line, block, targets, rootDir = 'ltr', end = '')
704
744
  const dir = dirAttr(seg.rtl ? 'rtl' : 'ltr', rootDir);
705
745
  return renderTextSegment(inLink ? { ...seg, refResourceId: undefined } : seg, at, top, fontDecl, colorDecl, color, lineTracking, segmentCjk(seg, lineDecl), dir ? { attrs: dir, decl: '' } : PLAIN_BOX);
706
746
  };
747
+ // The `<ruby>` open across the bases of one annotation (#428).
748
+ const ruby = rubyRuns();
707
749
  for (let i = 0; i < segs.length; i++) {
708
750
  const seg = segs[i];
751
+ parts.push(ruby.before(seg));
709
752
  if (seg.kind === 'space') {
710
753
  // The space as text, for copying (#403): a Han–Latin gap only where
711
754
  // the author typed one (its `text`).
@@ -737,6 +780,12 @@ function renderComposedSegments(line, block, targets, rootDir = 'ltr', end = '')
737
780
  x += seg.width;
738
781
  continue;
739
782
  }
783
+ if (seg.sideMarker) {
784
+ // A footnote marker in the line gap (JLReq §4.2.3).
785
+ parts.push(sideMarkerHtml(seg.sideMarker, x, pickSegmentColor(seg, block), quoteFontString));
786
+ x += seg.width;
787
+ continue;
788
+ }
740
789
  if (seg.refResourceId !== undefined && segs[i + 1]?.refContinues) {
741
790
  const group = renderRefRuns(segs, i, x, pickSegmentColor(seg, block), (run, at) => paintText(run, at, true), refLinks(refKey(seg), targets));
742
791
  parts.push(group.html);
@@ -744,13 +793,22 @@ function renderComposedSegments(line, block, targets, rootDir = 'ltr', end = '')
744
793
  i = group.end - 1;
745
794
  continue;
746
795
  }
796
+ // A ruby base and its reading (#194), in a `<ruby>` (#428).
797
+ if (seg.ruby)
798
+ parts.push(ruby.open(seg));
747
799
  parts.push(paintText(seg, x, seg.refResourceId !== undefined && !refLinks(refKey(seg), targets)));
748
- // A ruby base's reading (#194).
749
800
  if (seg.ruby)
750
- parts.push(rubyHtml(seg.ruby, x, pickSegmentColor(seg, block), quoteFontString));
801
+ parts.push(rubyHtml(seg.ruby, x, pickSegmentColor(seg, block), quoteFontString), ruby.after(seg));
802
+ if (seg.kunten) {
803
+ // Kanbun marks (#430), after the character's `<ruby>`; the 送り仮名
804
+ // read and copy after their character, as transparent text.
805
+ parts.push(ruby.end(), kuntenHtml(seg.kunten, x, pickSegmentColor(seg, block), quoteFontString));
806
+ if (seg.kunten.okuri)
807
+ parts.push(lineEndHtml(seg.kunten.okuri, x + seg.width));
808
+ }
751
809
  x += seg.width;
752
810
  }
753
- parts.push(links.end());
811
+ parts.push(ruby.end(), links.end());
754
812
  parts.push(lineEndHtml(end, x));
755
813
  // Emphasis dots, proper-name and book-title lines (#193).
756
814
  if (line.marks)
@@ -899,11 +957,18 @@ next) {
899
957
  function centralOf(v, fontString) {
900
958
  return v.axes?.[fontFamilyOf(fontString)] ?? DEFAULT_CENTRAL_BASELINE;
901
959
  }
960
+ /** Characters of Japanese vertical text the HTML sets otherwise than the
961
+ * browser would: “ ” (set as 〝 〟) and the marks of a pair set in one
962
+ * cell (`isUprightMarkPair`). */
963
+ const JAPANESE_VERTICAL_RE = /[“”!?!?]/;
902
964
  /** Escaped text of a vertical run, with its tate-chu-yoko cells, the
903
965
  * orientation its author forced, and each turned mark in a box of its
904
966
  * cell ({@link turnedCellHtml}). `font` is the run's font string (whose
905
967
  * family's `dashes` stretch a dash) and `tracking` the letter spacing it
906
- * is set with, px, which follows each cell. */
968
+ * is set with, px, which follows each cell. A Japanese “ ” is written as
969
+ * the 〝 〟 the canvas and the PDF paint (`VerticalGlyph.paintAs`), whose
970
+ * vertical form the browser takes; a pair of !? in one cell is combined
971
+ * as written, the browser fitting it to the cell. */
907
972
  function verticalTextHtml(text, v, orient, font, tracking = 0) {
908
973
  if (orient === 'tcy')
909
974
  return `<span style="text-combine-upright:all;">${esc(text)}</span>`;
@@ -912,16 +977,17 @@ function verticalTextHtml(text, v, orient, font, tracking = 0) {
912
977
  if (orient === 'sideways')
913
978
  return `<span style="text-orientation:sideways;">${esc(text)}</span>`;
914
979
  const digits = v.uprightDigits > 0 && /[0-9]/.test(text);
915
- if (!digits && !holdsTurnedMark(text))
980
+ const japanese = v.region === 'japan' && JAPANESE_VERTICAL_RE.test(text);
981
+ if (!digits && !japanese && !holdsTurnedMark(text))
916
982
  return esc(text);
917
983
  const runs = verticalRuns(graphemesOf(text), v.region, v.uprightDigits);
918
- if (!runs.some((r) => r.glyph.orient === 'tcy' || r.glyph.orient === 'rotate'))
984
+ if (!runs.some((r) => r.glyph.orient === 'tcy' || r.glyph.orient === 'rotate' || r.glyph.paintAs !== undefined))
919
985
  return esc(text);
920
986
  const advances = font !== undefined ? v.dashes?.[fontFamilyOf(font)] : undefined;
921
987
  // A number in one cell combined upright; a turned mark in its cell.
922
988
  return runs.map((r) => (r.glyph.orient === 'tcy'
923
989
  ? `<span style="text-combine-upright:all;">${esc(r.text)}</span>`
924
- : r.glyph.orient === 'rotate' ? turnedCellHtml(r, advances?.[r.text], tracking) : esc(r.text))).join('');
990
+ : r.glyph.orient === 'rotate' ? turnedCellHtml(r, advances?.[r.text], tracking) : esc(r.glyph.paintAs ?? r.text))).join('');
925
991
  }
926
992
  /**
927
993
  * A mark a vertical line turns in a cell of its own (`rotate`: a dash, an
@@ -973,19 +1039,22 @@ function verticalSpan(at, axis, inner, decl = '') {
973
1039
  }
974
1040
  /** A run of vertical text whose em boxes are centred `axis` px from the
975
1041
  * box's flow top, on either side of it (a ruby reading or a warichu row
976
- * sits outside the line's own box). */
977
- function verticalSpanAt(at, axis, size, inner, decl = '') {
1042
+ * sits outside the line's own box); `hidden` from assistive technology
1043
+ * (a warichu row, which its note box reads). */
1044
+ function verticalSpanAt(at, axis, size, inner, decl = '', hidden = true) {
978
1045
  const lh = Math.max(1, 2 * size);
979
- return `<span aria-hidden="true" style="position:absolute;top:${at.toFixed(3)}px;right:${(axis - lh / 2).toFixed(3)}px;white-space:pre;${decl}line-height:${lh.toFixed(3)}px;">${inner}</span>`;
1046
+ return `<span${hidden ? ' aria-hidden="true"' : ''} style="position:absolute;top:${at.toFixed(3)}px;right:${(axis - lh / 2).toFixed(3)}px;white-space:pre;${decl}line-height:${lh.toFixed(3)}px;">${inner}</span>`;
980
1047
  }
981
1048
  /** Annotation runs of a vertical line (a ruby reading, a warichu note's
982
1049
  * rows, #194, #195) from `x` along it: set down the column in their own
983
1050
  * face, centred across it on their baseline (`dy`) less their face's
984
- * axis, a zhuyin tone mark standing upright (`VDTAnnotationRun.upright`). */
985
- function verticalAnnotationRuns(runs, x, color, v, axisOf) {
1051
+ * axis, a zhuyin tone mark standing upright (`VDTAnnotationRun.upright`).
1052
+ * `hidden` from assistive technology unless they are a ruby reading's,
1053
+ * which its `<rt>` holds (#428). */
1054
+ function verticalAnnotationRuns(runs, x, color, v, axisOf, hidden = true) {
986
1055
  return runs.map((run) => {
987
1056
  const decl = `font:${quoteFontString(run.fontString)};color:${run.color ?? color};letter-spacing:0;`;
988
- return verticalSpanAt(x + run.dx, axisOf(run.fontString, run.dy), extractFontSizePx(run.fontString), verticalTextHtml(run.text, v, run.upright ? 'upright' : undefined, run.fontString), decl);
1057
+ return verticalSpanAt(x + run.dx, axisOf(run.fontString, run.dy), extractFontSizePx(run.fontString), verticalTextHtml(run.text, v, run.upright ? 'upright' : undefined, run.fontString), decl, hidden);
989
1058
  }).join('');
990
1059
  }
991
1060
  /** A body line of a vertical page: its text segments down an upright box,
@@ -1021,7 +1090,10 @@ function renderVerticalLine(line, block, v, targets, next) {
1021
1090
  const slack = Math.max(0, effectiveWidth - (contentWidth - trailing));
1022
1091
  let x = block.textAlign === 'center' ? slack / 2 : block.textAlign === 'right' ? slack : 0;
1023
1092
  const spaceAxis = axisOf(block.fontString);
1093
+ // The `<ruby>` open across the bases of one annotation (#428).
1094
+ const ruby = rubyRuns();
1024
1095
  for (const seg of segs) {
1096
+ inner.push(ruby.before(seg));
1025
1097
  if (seg.kind === 'space') {
1026
1098
  // The space as text, for copying (#403).
1027
1099
  if (seg.text)
@@ -1052,6 +1124,15 @@ function renderVerticalLine(line, block, v, targets, next) {
1052
1124
  x += seg.width;
1053
1125
  continue;
1054
1126
  }
1127
+ if (seg.sideMarker) {
1128
+ // A footnote marker in the line gap, right of the column (JLReq
1129
+ // §4.2.3), read as the marker and linked to its note.
1130
+ const runs = verticalAnnotationRuns(seg.sideMarker.runs, x, pickSegmentColor(seg, block), v, axisOf, false);
1131
+ const href = segmentHref(seg);
1132
+ inner.push(href !== undefined ? `<a href="${esc(href)}" style="color:inherit;text-decoration:none;">${runs}</a>` : runs);
1133
+ x += seg.width;
1134
+ continue;
1135
+ }
1055
1136
  const fontString = pickSegmentFont(seg, block);
1056
1137
  const font = quoteFontString(fontString);
1057
1138
  const color = pickSegmentColor(seg, block);
@@ -1074,12 +1155,24 @@ function renderVerticalLine(line, block, v, targets, next) {
1074
1155
  : segmentHref(seg);
1075
1156
  if (href !== undefined)
1076
1157
  text = `<a href="${esc(href)}" style="color:inherit;text-decoration:none;"${seg.href !== undefined && seg.refResourceId === undefined ? ' rel="noopener noreferrer"' : ''}>${text}</a>`;
1158
+ // A ruby base and its reading beside it (#194), in a `<ruby>` (#428).
1159
+ if (seg.ruby)
1160
+ inner.push(ruby.open(seg));
1077
1161
  inner.push(verticalSpan(x + (seg.inkOffset ?? 0), axisOf(fontString, seg.baselineShift ?? 0), text, decl));
1078
- // A ruby base's reading, beside the base (#194).
1079
1162
  if (seg.ruby)
1080
- inner.push(verticalAnnotationRuns(seg.ruby.runs, x, seg.ruby.color ?? color, v, axisOf));
1163
+ inner.push(RT_OPEN, verticalAnnotationRuns(seg.ruby.runs, x, seg.ruby.color ?? color, v, axisOf, false), '</rt>', ruby.after(seg));
1164
+ if (seg.kunten) {
1165
+ // Kanbun marks beside the character (#430), after its `<ruby>`; its
1166
+ // 送り仮名 read and copy after it, as transparent text.
1167
+ inner.push(ruby.end(), verticalAnnotationRuns(seg.kunten.runs, x, seg.kunten.color ?? color, v, axisOf));
1168
+ if (seg.kunten.tate)
1169
+ sideways.push(verticalKuntenTateHtml(seg.kunten, x, line, color));
1170
+ if (seg.kunten.okuri)
1171
+ inner.push(verticalSpan(x + seg.width, spaceAxis, esc(seg.kunten.okuri), LINE_END_DECL));
1172
+ }
1081
1173
  x += seg.width;
1082
1174
  }
1175
+ inner.push(ruby.end());
1083
1176
  // Emphasis dots, proper-name and book-title lines (#193), in the turned
1084
1177
  // flow with the line's box.
1085
1178
  if (line.marks)
@@ -1170,7 +1263,8 @@ function pickResourceFont(seg, fonts) {
1170
1263
  /** Render one already-positioned rich-text line (caption or table cell).
1171
1264
  * Alignment and justification are baked into the measured geometry, so
1172
1265
  * segments paint sequentially from the line origin — `:ref` segments in the
1173
- * link colour, `captionLabel` segments in the label colour. */
1266
+ * link colour, `captionLabel` segments in the label colour — with ruby
1267
+ * readings, warichu rows and the line's marks as on a body line (#429). */
1174
1268
  function renderResourceLine(line, fonts, color, linkColor, labelColor = color, targets,
1175
1269
  /** The direction the document's root declares (see {@link dirAttr}). */
1176
1270
  rootDir = 'ltr',
@@ -1232,6 +1326,12 @@ end = '') {
1232
1326
  x += seg.width;
1233
1327
  continue;
1234
1328
  }
1329
+ if (composed && seg.warichu) {
1330
+ // A warichu note's part: its two rows (#195, #429).
1331
+ parts.push(warichuHtml(seg.warichu, x, color, quoteFontString));
1332
+ x += seg.width;
1333
+ continue;
1334
+ }
1235
1335
  if (seg.refResourceId !== undefined && segs[i + 1]?.refContinues) {
1236
1336
  const group = renderRefRuns(segs, i, x, linkColor, (run, at) => paintText(run, at, true), refLinks(refKey(seg), targets));
1237
1337
  parts.push(group.html);
@@ -1240,10 +1340,23 @@ end = '') {
1240
1340
  continue;
1241
1341
  }
1242
1342
  parts.push(paintText(seg, x, seg.refResourceId !== undefined && !refLinks(refKey(seg), targets)));
1343
+ // A ruby base's reading (#194, #429).
1344
+ if (seg.ruby)
1345
+ parts.push(rubyHtml(seg.ruby, x, segColorOf(seg), quoteFontString));
1346
+ // Kanbun marks (#430), the 送り仮名 read after their character.
1347
+ if (seg.kunten) {
1348
+ parts.push(kuntenHtml(seg.kunten, x, segColorOf(seg), quoteFontString));
1349
+ if (seg.kunten.okuri)
1350
+ parts.push(lineEndHtml(seg.kunten.okuri, x + seg.width));
1351
+ }
1243
1352
  x += seg.width;
1244
1353
  }
1245
1354
  parts.push(links.end());
1246
1355
  parts.push(lineEndHtml(end, x));
1356
+ // Emphasis marks, side lines, the proper-name and book-title lines
1357
+ // (#193, #421, #429).
1358
+ if (line.marks)
1359
+ parts.push(lineMarksHtml(line, color));
1247
1360
  }
1248
1361
  else {
1249
1362
  parts.push(`<span style="position:absolute;left:0;top:0;white-space:pre;">${esc(line.text)}</span>`);
@@ -1264,11 +1377,11 @@ end = '') {
1264
1377
  }
1265
1378
  /** An image fitted to a box: `<img>` from `resourceImageUrl`, or the neutral
1266
1379
  * placeholder the canvas backend paints when nothing is registered. */
1267
- function renderFittedImage(url, alt, label, x, y, w, h, paint, svg) {
1380
+ function renderFittedImage(url, alt, label, x, y, w, h, paint, svg, source) {
1268
1381
  if (url) {
1269
1382
  const filter = paint ? inkFilterDecl(paint, svg, url) : '';
1270
1383
  return (`<img src="${esc(url)}" alt="${esc(alt)}" style="position:absolute;` +
1271
- `left:${x}px;top:${y}px;width:${w}px;height:${h}px;${filter}" />`);
1384
+ `left:${x}px;top:${y}px;width:${w}px;height:${h}px;${source ? croppedFitDecl(source) : ''}${filter}" />`);
1272
1385
  }
1273
1386
  const labelSize = Math.max(10, Math.min(16, h * 0.1));
1274
1387
  return (`<div aria-hidden="true" style="position:absolute;` +
@@ -1278,6 +1391,90 @@ function renderFittedImage(url, alt, label, x, y, w, h, paint, svg) {
1278
1391
  `font:${labelSize}px sans-serif;color:rgba(120,120,120,0.8);` +
1279
1392
  `">${label}</div>`);
1280
1393
  }
1394
+ /** An attribute list as HTML: a boolean attribute written `name="name"`,
1395
+ * valid in HTML and XHTML alike (the fixed-layout EPUB converts the
1396
+ * markup). */
1397
+ function htmlAttrs(attrs) {
1398
+ return attrs.map(([name, value]) => ` ${name}="${esc(value === true ? name : value)}"`).join('');
1399
+ }
1400
+ /** A video resource (#454): its player — an HTML5 `<video>` for a
1401
+ * self-hosted file, the YouTube or Vimeo `<iframe>` — or its poster with
1402
+ * the play mark and the QR code, linked to the video. */
1403
+ function renderVideoHtml(video, posterFileId, alt, x, y, w, h, paint, source) {
1404
+ const box = `position:absolute;left:${x}px;top:${y}px;width:${w}px;height:${h}px;`;
1405
+ const label = alt || 'Video';
1406
+ if (video) {
1407
+ const stream = video.source !== 'file';
1408
+ const mode = (stream ? paint.videos?.streams : paint.videos?.files) ?? video.html;
1409
+ if (mode === 'player') {
1410
+ if (stream && video.embedUrl) {
1411
+ return (`<iframe class="pt-video" src="${esc(video.embedUrl)}" title="${esc(label)}"` +
1412
+ ` allow="${esc(videoEmbedAllow(video.player))}"${video.player.fullscreen ? ' allowfullscreen="allowfullscreen"' : ''}` +
1413
+ ` loading="lazy" referrerpolicy="strict-origin-when-cross-origin"` +
1414
+ ` style="${box}border:0;background:#000;"></iframe>`);
1415
+ }
1416
+ const src = !stream ? (video.fileId ? paint.resourceVideoUrl?.(video.fileId) : undefined) ?? video.link : undefined;
1417
+ if (src) {
1418
+ const poster = posterFileId ? paint.resourceImageUrl?.(posterFileId) : undefined;
1419
+ return (`<video class="pt-video" src="${esc(src + mediaFragment(video))}"${poster ? ` poster="${esc(poster)}"` : ''}` +
1420
+ `${htmlAttrs(videoElementAttributes(video.player))} aria-label="${esc(label)}"` +
1421
+ ` style="${box}object-fit:cover;background:#000;"></video>`);
1422
+ }
1423
+ }
1424
+ }
1425
+ // The poster, as printed.
1426
+ const url = posterFileId ? imageUrl(paint, posterFileId) : undefined;
1427
+ const picture = url
1428
+ ? `<img src="${esc(url)}" alt="${esc(label)}" style="position:absolute;left:0;top:0;width:${w}px;height:${h}px;${source ? croppedFitDecl(source) : ''}" />`
1429
+ : `<div role="img" aria-label="${esc(label)}" style="position:absolute;left:0;top:0;width:${w}px;height:${h}px;background:#1f1f1f;"></div>`;
1430
+ const overlay = video ? videoOverlaySvg(video, w, h) : '';
1431
+ const inner = picture + overlay;
1432
+ return video?.linkPoster && video.link
1433
+ ? `<a class="pt-video-link" href="${esc(video.link)}" rel="noopener noreferrer" style="${box}display:block;">${inner}</a>`
1434
+ : `<div style="${box}">${inner}</div>`;
1435
+ }
1436
+ /** The play mark and QR code of a video's poster as one SVG over the body
1437
+ * (`w` × `h`). In a mirrored flow the SVG turns back about its own box
1438
+ * like a picture, so the overlays land where they are printed and the code
1439
+ * reads. */
1440
+ function videoOverlaySvg(video, w, h) {
1441
+ const n = (v) => String(Math.round(v * 1000) / 1000);
1442
+ const parts = [];
1443
+ const mark = video.playMark;
1444
+ if (mark) {
1445
+ const { x, y, width: mw, height: mh } = mark.rect;
1446
+ const tri = playMarkTriangle(mark).map(([px, py]) => `${n(x + px)},${n(y + py)}`).join(' ');
1447
+ if (mark.shape === 'triangle') {
1448
+ parts.push(`<polygon points="${tri}" fill="${mark.color}" stroke="${mark.background}" stroke-opacity="${mark.backgroundOpacity}" stroke-width="${n(mh * 0.08)}" stroke-linejoin="round"/>`);
1449
+ }
1450
+ else {
1451
+ parts.push(mark.shape === 'circle'
1452
+ ? `<ellipse cx="${n(x + mw / 2)}" cy="${n(y + mh / 2)}" rx="${n(mw / 2)}" ry="${n(mh / 2)}" fill="${mark.background}" fill-opacity="${mark.backgroundOpacity}"/>`
1453
+ : `<rect x="${n(x)}" y="${n(y)}" width="${n(mw)}" height="${n(mh)}" rx="${n(mh * 0.24)}" fill="${mark.background}" fill-opacity="${mark.backgroundOpacity}"/>`);
1454
+ parts.push(`<polygon points="${tri}" fill="${mark.color}"/>`);
1455
+ }
1456
+ }
1457
+ const qr = video.qr;
1458
+ if (qr) {
1459
+ const { x, y, width: qw, height: qh } = qr.rect;
1460
+ parts.push(`<rect x="${n(x)}" y="${n(y)}" width="${n(qw)}" height="${n(qh)}" rx="${n(qr.radius)}" fill="${qr.background}"/>`);
1461
+ const d = qrModuleRuns(qr).map((r) => `M${n(x + r.x)} ${n(y + r.y)}h${n(r.w)}v${n(r.h)}h${n(-r.w)}z`).join('');
1462
+ parts.push(`<path d="${d}" fill="${qr.color}" shape-rendering="crispEdges"/>`);
1463
+ }
1464
+ if (parts.length === 0)
1465
+ return '';
1466
+ return (`<svg aria-hidden="true" focusable="false" width="${n(w)}" height="${n(h)}" viewBox="0 0 ${n(w)} ${n(h)}"` +
1467
+ ` style="position:absolute;left:0;top:0;overflow:visible;">${parts.join('')}</svg>`);
1468
+ }
1469
+ /** The `object-fit` of a picture cropped within its safe area (#442): the
1470
+ * shown part spans the picture's whole width or whole height and has the
1471
+ * box's ratio, so `cover` scales the picture as the crop does, and the
1472
+ * position puts the shown part in the box. */
1473
+ function croppedFitDecl(source) {
1474
+ const px = source.width < 1 ? (source.x / (1 - source.width)) * 100 : 0;
1475
+ const py = source.height < 1 ? (source.y / (1 - source.height)) * 100 : 0;
1476
+ return `object-fit:cover;object-position:${+px.toFixed(3)}% ${+py.toFixed(3)}%;`;
1477
+ }
1281
1478
  /** Wrap absolutely positioned page markup in a box clipped to a rounded
1282
1479
  * outline: the box sits on the outline and rounds its corners, and an inner
1283
1480
  * layer shifted back by the box's offset keeps the children's page
@@ -1400,10 +1597,18 @@ function renderResourceBlockHtml(block, paint) {
1400
1597
  ? `<span id="${esc(resourceAnchorId(rb.resource.id))}" style="position:absolute;` +
1401
1598
  `left:${block.bbox.x}px;top:${block.bbox.y}px;width:0;height:0;"></span>`
1402
1599
  : '';
1403
- if (rb.kind === 'bitmap' || rb.kind === 'svg') {
1600
+ if (rb.kind === 'video') {
1601
+ // Named like the PDF's figure: its alt text, else its caption, else
1602
+ // its label (`Video 1.2`).
1603
+ const name = rb.resource.altText?.trim()
1604
+ || rb.captionLines.map((l) => l.text).join(' ').replace(/\s+/g, ' ').trim()
1605
+ || `${rb.captionPrefix} ${rb.number}`.trim();
1606
+ parts.push(renderVideoHtml(rb.video, rb.fileId, name, bx, by, bw, bh, options, rb.bodySource));
1607
+ }
1608
+ else if (rb.kind === 'bitmap' || rb.kind === 'svg') {
1404
1609
  const url = rb.fileId ? imageUrl(options, rb.fileId, rb.resource.id) : undefined;
1405
1610
  // `<img>`, or a neutral placeholder matching the canvas backend's colours.
1406
- parts.push(renderFittedImage(url, rb.resource.altText ?? '', rb.kind === 'svg' ? 'SVG' : 'Image', bx, by, bw, bh, options, rb.kind === 'svg'));
1611
+ parts.push(renderFittedImage(url, rb.resource.altText ?? '', rb.kind === 'svg' ? 'SVG' : 'Image', bx, by, bw, bh, options, rb.kind === 'svg', rb.bodySource));
1407
1612
  }
1408
1613
  else if (rb.kind === 'table') {
1409
1614
  parts.push(renderResourceTable(rb, bx, by, options));
@@ -1744,8 +1949,10 @@ verticalRegion, verticalDigits) {
1744
1949
  ? `<div class="pt-flow pt-flow-mirrored" style="position:absolute;left:0;top:0;width:${page.width}px;height:${page.height}px;transform:scaleX(-1);transform-origin:${page.flow.mirror.originX / 2}px 0;">${MIRRORED_FLOW_STYLE}${flowHtml}</div>`
1745
1950
  : flowHtml) + slotParts.join('');
1746
1951
  // A right-to-left document's pages say so, with its language, for a host
1747
- // that mounts them apart from the document's root (#379).
1748
- const pageAttrs = options.dir === 'rtl' ? ` dir="rtl"${options.lang ? ` lang="${options.lang}"` : ''}` : '';
1952
+ // that mounts them apart from the document's root (#379); so do a
1953
+ // Japanese document's, whose glyph forms (a pan-CJK face's `locl`) and
1954
+ // vertical forms the browser picks by language (#428).
1955
+ const pageAttrs = (options.dir === 'rtl' ? ' dir="rtl"' : '') + (options.lang ? ` lang="${options.lang}"` : '');
1749
1956
  const outerHtml = `<div class="pt-page" id="${pageElementId((options.pageIndexOffset ?? 0) + page.index)}" data-page="${page.index}"${pageAttrs} style="` +
1750
1957
  `position:relative;` +
1751
1958
  `width:${page.width}px;` +
@@ -1764,7 +1971,7 @@ verticalRegion, verticalDigits) {
1764
1971
  * mirrored layout put it. A box that sets a transform of its own (a
1765
1972
  * stretched dash, a turned design picture) keeps it and stays mirrored. */
1766
1973
  const MIRRORED_FLOW_STYLE = '<style>.pt-flow-mirrored [style*="white-space:pre"],.pt-flow-mirrored img,' +
1767
- '.pt-flow-mirrored svg:not(.pt-char-grid){transform:scaleX(-1);}</style>';
1974
+ '.pt-flow-mirrored svg:not(.pt-char-grid),.pt-flow-mirrored .pt-video{transform:scaleX(-1);}</style>';
1768
1975
  /** The character grid (稿纸) as one SVG path over the page, under the
1769
1976
  * text (see `cjkGridCells`). */
1770
1977
  function renderCharacterGridSvg(cells, width, height) {
@@ -1843,7 +2050,7 @@ export function renderToHtmlIndexed(doc, options = {}) {
1843
2050
  ...(doc.anchors ? { anchors: doc.anchors } : {}),
1844
2051
  pageIndexOffset: doc.pageIndexOffset ?? 0,
1845
2052
  ...(docLang ? { rootLang: docLang } : {}),
1846
- ...(rtl ? { dir: 'rtl', ...(docLang ? { lang: docLang } : {}) } : {}),
2053
+ ...(rtl ? { dir: 'rtl', ...(docLang ? { lang: docLang } : {}) } : isJapaneseLanguage(docLang) ? { lang: docLang } : {}),
1847
2054
  };
1848
2055
  const bleedInset = doc.trimOffset > 0
1849
2056
  ? Math.max(0, doc.trimOffset - dimensionToPx(doc.config.page.cutLines.bleed, doc.config.page.dpi))