postext 1.28.6 → 1.29.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/__tests__/arabicLocale.test.js +10 -2
- package/dist/__tests__/arabicLocale.test.js.map +1 -1
- package/dist/__tests__/bundle/balloonPlacementPin.test.js +5 -1
- package/dist/__tests__/bundle/balloonPlacementPin.test.js.map +1 -1
- package/dist/__tests__/bundle/cjkRulesPin.test.js +15 -9
- package/dist/__tests__/bundle/cjkRulesPin.test.js.map +1 -1
- package/dist/__tests__/bundle/designOverflowPin.test.js +3 -3
- package/dist/__tests__/bundle/designOverflowPin.test.js.map +1 -1
- package/dist/__tests__/bundle/flowColumnsPin.test.js +4 -1
- package/dist/__tests__/bundle/flowColumnsPin.test.js.map +1 -1
- package/dist/__tests__/bundle/gridBalancingPin.test.js +6 -2
- package/dist/__tests__/bundle/gridBalancingPin.test.js.map +1 -1
- package/dist/__tests__/bundle/gridBreakRulesPin.test.js +23 -17
- package/dist/__tests__/bundle/gridBreakRulesPin.test.js.map +1 -1
- package/dist/__tests__/bundle/indexGroupSplitPin.test.js +5 -2
- package/dist/__tests__/bundle/indexGroupSplitPin.test.js.map +1 -1
- package/dist/__tests__/bundle/looseOrderPin.test.js +5 -1
- package/dist/__tests__/bundle/looseOrderPin.test.js.map +1 -1
- package/dist/__tests__/bundle/refLabelBreaksPin.test.js +5 -1
- package/dist/__tests__/bundle/refLabelBreaksPin.test.js.map +1 -1
- package/dist/__tests__/bundle/scriptContextPin.test.js +7 -2
- package/dist/__tests__/bundle/scriptContextPin.test.js.map +1 -1
- package/dist/__tests__/bundle/shapingLanguagePin.test.d.ts +2 -0
- package/dist/__tests__/bundle/shapingLanguagePin.test.d.ts.map +1 -0
- package/dist/__tests__/bundle/shapingLanguagePin.test.js +96 -0
- package/dist/__tests__/bundle/shapingLanguagePin.test.js.map +1 -0
- package/dist/__tests__/bundle/taskBoxPin.test.d.ts +2 -0
- package/dist/__tests__/bundle/taskBoxPin.test.d.ts.map +1 -0
- package/dist/__tests__/bundle/taskBoxPin.test.js +94 -0
- package/dist/__tests__/bundle/taskBoxPin.test.js.map +1 -0
- package/dist/__tests__/bundle/trailingStepPin.test.js +5 -2
- package/dist/__tests__/bundle/trailingStepPin.test.js.map +1 -1
- package/dist/__tests__/bundle/wideFloatStretchPin.test.js +5 -2
- package/dist/__tests__/bundle/wideFloatStretchPin.test.js.map +1 -1
- package/dist/__tests__/bundle.test.js +5 -5
- package/dist/__tests__/bundle.test.js.map +1 -1
- package/dist/__tests__/chineseLocale.test.js +7 -1
- package/dist/__tests__/chineseLocale.test.js.map +1 -1
- package/dist/__tests__/cjk/japaneseHtml.test.js +19 -3
- package/dist/__tests__/cjk/japaneseHtml.test.js.map +1 -1
- package/dist/__tests__/cjk/japaneseSegmentLanguage.test.js +24 -4
- package/dist/__tests__/cjk/japaneseSegmentLanguage.test.js.map +1 -1
- package/dist/__tests__/codeBlocks.test.js +1 -1
- package/dist/__tests__/exports.test.js +14 -0
- package/dist/__tests__/exports.test.js.map +1 -1
- package/dist/__tests__/hardBreaks.test.js +1 -1
- package/dist/__tests__/headingInlineMarks.test.js +1 -1
- package/dist/__tests__/mathSizeMigration.test.js +4 -4
- package/dist/__tests__/mathSizeMigration.test.js.map +1 -1
- package/dist/__tests__/pipeline/calloutInlineResourceGap.test.js +1 -1
- package/dist/__tests__/pipeline/calloutSplitMinLinesChild.test.js +3 -3
- package/dist/__tests__/pipeline/calloutSplitMinLinesChild.test.js.map +1 -1
- package/dist/__tests__/pipeline/colonListRoom.test.js +3 -3
- package/dist/__tests__/pipeline/colonListRoom.test.js.map +1 -1
- package/dist/__tests__/pipeline/compoundBreaks.test.js +6 -6
- package/dist/__tests__/pipeline/compoundBreaks.test.js.map +1 -1
- package/dist/__tests__/pipeline/dashBreaks.test.js +5 -5
- package/dist/__tests__/pipeline/dashBreaks.test.js.map +1 -1
- package/dist/__tests__/pipeline/headingSplitOrphans.test.js +3 -3
- package/dist/__tests__/pipeline/headingSplitOrphans.test.js.map +1 -1
- package/dist/__tests__/pipeline/inlineFigureSpace.test.js +5 -5
- package/dist/__tests__/pipeline/inlineFigureSpace.test.js.map +1 -1
- package/dist/__tests__/pipeline/paragraphContainerTail.test.js +7 -7
- package/dist/__tests__/pipeline/paragraphContainerTail.test.js.map +1 -1
- package/dist/__tests__/pipeline/raggedOptimal.test.js +6 -6
- package/dist/__tests__/pipeline/raggedOptimal.test.js.map +1 -1
- package/dist/__tests__/rtl/htmlRtl.test.js +15 -2
- package/dist/__tests__/rtl/htmlRtl.test.js.map +1 -1
- package/dist/__tests__/shapingLanguage.test.d.ts +2 -0
- package/dist/__tests__/shapingLanguage.test.d.ts.map +1 -0
- package/dist/__tests__/shapingLanguage.test.js +352 -0
- package/dist/__tests__/shapingLanguage.test.js.map +1 -0
- package/dist/__tests__/taskBox.test.d.ts +2 -0
- package/dist/__tests__/taskBox.test.d.ts.map +1 -0
- package/dist/__tests__/taskBox.test.js +291 -0
- package/dist/__tests__/taskBox.test.js.map +1 -0
- package/dist/__tests__/verseLines.test.js +7 -7
- package/dist/__tests__/verseLines.test.js.map +1 -1
- package/dist/bundle/configVersion.d.ts +53 -7
- package/dist/bundle/configVersion.d.ts.map +1 -1
- package/dist/bundle/configVersion.js +84 -6
- package/dist/bundle/configVersion.js.map +1 -1
- package/dist/bundle/index.d.ts +2 -1
- package/dist/bundle/index.d.ts.map +1 -1
- package/dist/bundle/index.js +2 -1
- package/dist/bundle/index.js.map +1 -1
- package/dist/canvas-backend/blockRender.d.ts.map +1 -1
- package/dist/canvas-backend/blockRender.js +41 -2
- package/dist/canvas-backend/blockRender.js.map +1 -1
- package/dist/canvas-backend/index.d.ts.map +1 -1
- package/dist/canvas-backend/index.js +10 -5
- package/dist/canvas-backend/index.js.map +1 -1
- package/dist/canvas-backend/trackedText.d.ts.map +1 -1
- package/dist/canvas-backend/trackedText.js +9 -5
- package/dist/canvas-backend/trackedText.js.map +1 -1
- package/dist/canvas-backend/wordRuns.d.ts +6 -0
- package/dist/canvas-backend/wordRuns.d.ts.map +1 -1
- package/dist/canvas-backend/wordRuns.js +31 -0
- package/dist/canvas-backend/wordRuns.js.map +1 -1
- package/dist/comics/lettering/letter.d.ts.map +1 -1
- package/dist/comics/lettering/letter.js +2 -1
- package/dist/comics/lettering/letter.js.map +1 -1
- package/dist/contrast.d.ts.map +1 -1
- package/dist/contrast.js +5 -0
- package/dist/contrast.js.map +1 -1
- package/dist/defaults/bodyText.d.ts.map +1 -1
- package/dist/defaults/bodyText.js +10 -0
- package/dist/defaults/bodyText.js.map +1 -1
- package/dist/defaults/unorderedLists.d.ts.map +1 -1
- package/dist/defaults/unorderedLists.js +7 -0
- package/dist/defaults/unorderedLists.js.map +1 -1
- package/dist/html-backend.d.ts.map +1 -1
- package/dist/html-backend.js +45 -5
- package/dist/html-backend.js.map +1 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -1
- package/dist/index.js.map +1 -1
- package/dist/locale.d.ts +37 -14
- package/dist/locale.d.ts.map +1 -1
- package/dist/locale.js +40 -12
- package/dist/locale.js.map +1 -1
- package/dist/measure/cache.js +2 -2
- package/dist/measure/cache.js.map +1 -1
- package/dist/measure/canvas.d.ts +20 -0
- package/dist/measure/canvas.d.ts.map +1 -1
- package/dist/measure/canvas.js +131 -50
- package/dist/measure/canvas.js.map +1 -1
- package/dist/measure/cjkAnnotate.js +2 -2
- package/dist/measure/cjkAnnotate.js.map +1 -1
- package/dist/measure/cjkCompose.d.ts.map +1 -1
- package/dist/measure/cjkCompose.js +225 -209
- package/dist/measure/cjkCompose.js.map +1 -1
- package/dist/measure/plain.d.ts.map +1 -1
- package/dist/measure/plain.js +4 -2
- package/dist/measure/plain.js.map +1 -1
- package/dist/measure/pretextLanguage.d.ts +12 -0
- package/dist/measure/pretextLanguage.d.ts.map +1 -0
- package/dist/measure/pretextLanguage.js +117 -0
- package/dist/measure/pretextLanguage.js.map +1 -0
- package/dist/measure/rich.d.ts +4 -0
- package/dist/measure/rich.d.ts.map +1 -1
- package/dist/measure/rich.js +164 -137
- package/dist/measure/rich.js.map +1 -1
- package/dist/measure/rubyLift.d.ts.map +1 -1
- package/dist/measure/rubyLift.js +4 -3
- package/dist/measure/rubyLift.js.map +1 -1
- package/dist/measure/spanLanguage.d.ts +11 -0
- package/dist/measure/spanLanguage.d.ts.map +1 -0
- package/dist/measure/spanLanguage.js +19 -0
- package/dist/measure/spanLanguage.js.map +1 -0
- package/dist/measure/vertical.d.ts.map +1 -1
- package/dist/measure/vertical.js +4 -3
- package/dist/measure/vertical.js.map +1 -1
- package/dist/pipeline/build.d.ts.map +1 -1
- package/dist/pipeline/build.js +15 -2
- package/dist/pipeline/build.js.map +1 -1
- package/dist/pipeline/calloutLayout.d.ts.map +1 -1
- package/dist/pipeline/calloutLayout.js +10 -4
- package/dist/pipeline/calloutLayout.js.map +1 -1
- package/dist/pipeline/dropCap.js +2 -2
- package/dist/pipeline/dropCap.js.map +1 -1
- package/dist/pipeline/lists.d.ts +8 -0
- package/dist/pipeline/lists.d.ts.map +1 -1
- package/dist/pipeline/lists.js +16 -1
- package/dist/pipeline/lists.js.map +1 -1
- package/dist/pipeline/toc.d.ts.map +1 -1
- package/dist/pipeline/toc.js +5 -3
- package/dist/pipeline/toc.js.map +1 -1
- package/dist/taskBox.d.ts +55 -0
- package/dist/taskBox.d.ts.map +1 -0
- package/dist/taskBox.js +79 -0
- package/dist/taskBox.js.map +1 -0
- package/dist/types.d.ts +54 -1
- package/dist/types.d.ts.map +1 -1
- package/dist/vdt.d.ts +14 -0
- package/dist/vdt.d.ts.map +1 -1
- package/dist/vdt.js.map +1 -1
- package/package.json +1 -1
package/dist/html-backend.js
CHANGED
|
@@ -7,7 +7,7 @@ import { registeredFontSyncProvider } from './svg/fontRegistry';
|
|
|
7
7
|
import { svgPictureFontWarning } from './svg/image';
|
|
8
8
|
import { lineInkExtent, lineTrailingTracking } from './lineInk';
|
|
9
9
|
import { CHARACTER_GRID_COLOR, cjkGridCells } from './pipeline/cjkGrid';
|
|
10
|
-
import { isJapaneseLanguage, renderLangOf } from './locale';
|
|
10
|
+
import { isJapaneseLanguage, renderLangOf, shapingLanguageOf } from './locale';
|
|
11
11
|
import { hasCJK } from './measure/cjk';
|
|
12
12
|
import { markerRuns } from './bidi';
|
|
13
13
|
import { joiningScriptIn } from './measure/joining';
|
|
@@ -21,6 +21,7 @@ import { playMarkTriangle, qrModuleRuns } from './pipeline/videoOverlay';
|
|
|
21
21
|
import { isHlsMimeType, mediaFragment, videoElementAttributes, videoEmbedAllow } from './video/url';
|
|
22
22
|
import { renderComicHtml } from './htmlComic';
|
|
23
23
|
import { comicBlockOnSheet, pageComics } from './comics/transform';
|
|
24
|
+
import { taskBoxSvgBody, taskBoxText } from './taskBox';
|
|
24
25
|
/**
|
|
25
26
|
* Declarations of every box of CJK text measured with no punctuation
|
|
26
27
|
* trimming: the browser adds and removes nothing. Chrome's
|
|
@@ -1073,7 +1074,34 @@ function arabicMarkNeeded(text) {
|
|
|
1073
1074
|
const arabic = markerRuns(text, 'rtl-arabic');
|
|
1074
1075
|
return plain.length !== arabic.length || plain.some((r, i) => r.text !== arabic[i].text);
|
|
1075
1076
|
}
|
|
1077
|
+
/**
|
|
1078
|
+
* The box of a task item (`VDTBlock.bulletBox`, #765): an inline SVG the
|
|
1079
|
+
* size of the box, from `bulletOffsetX` and centred on `bulletY`, in the
|
|
1080
|
+
* marker's colour. Its holder is an image named ☐ or ☑, which is what
|
|
1081
|
+
* assistive technology reads, and holds that character as text of no
|
|
1082
|
+
* size, so a selection copies it as it copied the character the box
|
|
1083
|
+
* stands for. On a vertical page the tick is drawn turned back
|
|
1084
|
+
* (`vertical`); on a right-to-left one the flow's own rule turns every
|
|
1085
|
+
* `svg` back.
|
|
1086
|
+
*/
|
|
1087
|
+
function renderTaskBox(block, vertical = false) {
|
|
1088
|
+
const box = block.bulletBox;
|
|
1089
|
+
const firstLine = block.lines[0];
|
|
1090
|
+
if (!box || block.bulletOffsetX === undefined || !firstLine)
|
|
1091
|
+
return '';
|
|
1092
|
+
const { side, stroke, checked } = box;
|
|
1093
|
+
const top = (block.bulletY ?? firstLine.baseline) - side / 2;
|
|
1094
|
+
const mark = esc(taskBoxText(checked));
|
|
1095
|
+
return (`<div class="pt-bullet pt-task-box" role="img" aria-label="${mark}" style="position:absolute;` +
|
|
1096
|
+
`left:${block.bulletOffsetX}px;top:${top}px;width:${side}px;height:${side}px;` +
|
|
1097
|
+
`color:${block.bulletColor ?? block.color};font-size:0;">` +
|
|
1098
|
+
`<svg aria-hidden="true" focusable="false" viewBox="0 0 100 100" width="${side}" height="${side}" style="position:absolute;left:0;top:0;">` +
|
|
1099
|
+
taskBoxSvgBody(stroke / side, checked, vertical ? 'vertical' : undefined) +
|
|
1100
|
+
`</svg>${mark}</div>`);
|
|
1101
|
+
}
|
|
1076
1102
|
function renderBullet(block, rootDir = 'ltr') {
|
|
1103
|
+
if (block.type === 'listItem' && block.bulletBox)
|
|
1104
|
+
return renderTaskBox(block);
|
|
1077
1105
|
if (block.type !== 'listItem' ||
|
|
1078
1106
|
!block.bulletText ||
|
|
1079
1107
|
block.bulletOffsetX === undefined) {
|
|
@@ -1448,6 +1476,8 @@ function renderVerticalMarker(cls, x, block, v, fontString, color, text) {
|
|
|
1448
1476
|
return uprightBox(x, lineTop, width, h, decl, verticalSpan(0, axis, verticalTextHtml(text, v, undefined, fontString)), `class="${cls}" aria-hidden="true"`);
|
|
1449
1477
|
}
|
|
1450
1478
|
function renderVerticalBullet(block, v) {
|
|
1479
|
+
if (block.type === 'listItem' && block.bulletBox)
|
|
1480
|
+
return renderTaskBox(block, true);
|
|
1451
1481
|
if (block.type !== 'listItem' || !block.bulletText || block.bulletOffsetX === undefined || !block.lines[0])
|
|
1452
1482
|
return '';
|
|
1453
1483
|
const bulletFont = block.bulletFontString ?? block.fontString;
|
|
@@ -2307,7 +2337,7 @@ verticalRegion, verticalDigits) {
|
|
|
2307
2337
|
// that mounts them apart from the document's root (#379); so do a
|
|
2308
2338
|
// Japanese document's, whose glyph forms (a pan-CJK face's `locl`) and
|
|
2309
2339
|
// vertical forms the browser picks by language (#428).
|
|
2310
|
-
const pageAttrs = (options.dir === 'rtl' ? ' dir="rtl"' : '') + (options.lang ? ` lang="${options.lang}"` : '');
|
|
2340
|
+
const pageAttrs = (options.dir === 'rtl' ? ' dir="rtl"' : '') + (options.lang !== undefined ? ` lang="${options.lang}"` : '');
|
|
2311
2341
|
const outerHtml = `<div class="pt-page" id="${pageElementId((options.pageIndexOffset ?? 0) + page.index)}" data-page="${page.index}"${pageAttrs} style="` +
|
|
2312
2342
|
`position:relative;` +
|
|
2313
2343
|
`width:${page.width}px;` +
|
|
@@ -2396,7 +2426,13 @@ export function renderToHtmlIndexed(doc, options = {}) {
|
|
|
2396
2426
|
// browser resolves the text of every box in that direction unless the
|
|
2397
2427
|
// box declares its own (see `dirAttr`).
|
|
2398
2428
|
const rtl = doc.config.direction === 'rtl';
|
|
2399
|
-
|
|
2429
|
+
// The language the document was measured in is the one its HTML
|
|
2430
|
+
// declares (#764): the browser shapes the text in it, on a page in any
|
|
2431
|
+
// other. A document with no language to name (`shapingLanguageOf` gives
|
|
2432
|
+
// the empty tag) says `lang=""`, no language, as it was measured; one
|
|
2433
|
+
// shaped in the host's declares what it did up to postext 1.28.
|
|
2434
|
+
const shapedIn = shapingLanguageOf(doc.config);
|
|
2435
|
+
const docLang = shapedIn ?? renderLangOf(doc.config);
|
|
2400
2436
|
// A right-bound book lays its pages out right to left in a row: a row
|
|
2401
2437
|
// already runs that way in a right-to-left root.
|
|
2402
2438
|
const reversed = (doc.binding === 'right') !== rtl;
|
|
@@ -2421,7 +2457,11 @@ export function renderToHtmlIndexed(doc, options = {}) {
|
|
|
2421
2457
|
...(doc.anchors ? { anchors: doc.anchors } : {}),
|
|
2422
2458
|
pageIndexOffset: doc.pageIndexOffset ?? 0,
|
|
2423
2459
|
...(docLang ? { rootLang: docLang } : {}),
|
|
2424
|
-
|
|
2460
|
+
// Every page says its language, for a host that mounts it apart from
|
|
2461
|
+
// the document's root; up to postext 1.28 only a right-to-left and a
|
|
2462
|
+
// Japanese one did.
|
|
2463
|
+
...(rtl ? { dir: 'rtl' } : {}),
|
|
2464
|
+
...(docLang !== undefined && (shapedIn !== undefined || rtl || isJapaneseLanguage(docLang)) ? { lang: docLang } : {}),
|
|
2425
2465
|
};
|
|
2426
2466
|
const bleedInset = doc.trimOffset > 0
|
|
2427
2467
|
? Math.max(0, doc.trimOffset - dimensionToPx(doc.config.page.cutLines.bleed, doc.config.page.dpi))
|
|
@@ -2460,7 +2500,7 @@ export function renderToHtmlIndexed(doc, options = {}) {
|
|
|
2460
2500
|
// browser picks the region's glyph forms, and so does a right-to-left one,
|
|
2461
2501
|
// with its direction (see `renderLangOf`).
|
|
2462
2502
|
const reset = rtl ? HTML_TEXT_RESET.replace('direction:ltr;', 'direction:rtl;') : HTML_TEXT_RESET;
|
|
2463
|
-
const html = `<div class="pt-doc"${docLang ? ` lang="${docLang}"` : ''}${rtl ? ' dir="rtl"' : ''} data-mode="${mode}" style="${reset}${docStyle}">` +
|
|
2503
|
+
const html = `<div class="pt-doc"${docLang !== undefined ? ` lang="${docLang}"` : ''}${rtl ? ' dir="rtl"' : ''} data-mode="${mode}" style="${reset}${docStyle}">` +
|
|
2464
2504
|
pageHtmlParts.join('') +
|
|
2465
2505
|
`</div>`;
|
|
2466
2506
|
return { html, mode, pages: indexedPages };
|