postext 1.36.0 → 1.37.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 (178) hide show
  1. package/dist/__tests__/composed/continuation.test.d.ts +2 -0
  2. package/dist/__tests__/composed/continuation.test.d.ts.map +1 -0
  3. package/dist/__tests__/composed/continuation.test.js +352 -0
  4. package/dist/__tests__/composed/continuation.test.js.map +1 -0
  5. package/dist/__tests__/composed/contrast.test.d.ts +2 -0
  6. package/dist/__tests__/composed/contrast.test.d.ts.map +1 -0
  7. package/dist/__tests__/composed/contrast.test.js +124 -0
  8. package/dist/__tests__/composed/contrast.test.js.map +1 -0
  9. package/dist/__tests__/composed/corpus.test.js +7 -1
  10. package/dist/__tests__/composed/corpus.test.js.map +1 -1
  11. package/dist/__tests__/composed/fit.test.js +9 -6
  12. package/dist/__tests__/composed/fit.test.js.map +1 -1
  13. package/dist/__tests__/composed/groups.test.js +14 -0
  14. package/dist/__tests__/composed/groups.test.js.map +1 -1
  15. package/dist/__tests__/composed/headingDesigns.test.d.ts +2 -0
  16. package/dist/__tests__/composed/headingDesigns.test.d.ts.map +1 -0
  17. package/dist/__tests__/composed/headingDesigns.test.js +262 -0
  18. package/dist/__tests__/composed/headingDesigns.test.js.map +1 -0
  19. package/dist/__tests__/composed/labels.test.d.ts +2 -0
  20. package/dist/__tests__/composed/labels.test.d.ts.map +1 -0
  21. package/dist/__tests__/composed/labels.test.js +326 -0
  22. package/dist/__tests__/composed/labels.test.js.map +1 -0
  23. package/dist/__tests__/composed/outsidePrint.test.js +5 -2
  24. package/dist/__tests__/composed/outsidePrint.test.js.map +1 -1
  25. package/dist/__tests__/composed/sourceMap.test.js +26 -0
  26. package/dist/__tests__/composed/sourceMap.test.js.map +1 -1
  27. package/dist/__tests__/composed/spreadLabels.test.d.ts +2 -0
  28. package/dist/__tests__/composed/spreadLabels.test.d.ts.map +1 -0
  29. package/dist/__tests__/composed/spreadLabels.test.js +131 -0
  30. package/dist/__tests__/composed/spreadLabels.test.js.map +1 -0
  31. package/dist/__tests__/exports.test.js +11 -0
  32. package/dist/__tests__/exports.test.js.map +1 -1
  33. package/dist/__tests__/migrate/fixtures/textbookPort.d.ts +14 -0
  34. package/dist/__tests__/migrate/fixtures/textbookPort.d.ts.map +1 -0
  35. package/dist/__tests__/migrate/fixtures/textbookPort.js +116 -0
  36. package/dist/__tests__/migrate/fixtures/textbookPort.js.map +1 -0
  37. package/dist/__tests__/migrate/textToMarkdown.test.d.ts +2 -0
  38. package/dist/__tests__/migrate/textToMarkdown.test.d.ts.map +1 -0
  39. package/dist/__tests__/migrate/textToMarkdown.test.js +268 -0
  40. package/dist/__tests__/migrate/textToMarkdown.test.js.map +1 -0
  41. package/dist/__tests__/paragraphStyleLetterSpacing.test.d.ts +2 -0
  42. package/dist/__tests__/paragraphStyleLetterSpacing.test.d.ts.map +1 -0
  43. package/dist/__tests__/paragraphStyleLetterSpacing.test.js +89 -0
  44. package/dist/__tests__/paragraphStyleLetterSpacing.test.js.map +1 -0
  45. package/dist/__tests__/pictureBelowPrintSize.test.d.ts +2 -0
  46. package/dist/__tests__/pictureBelowPrintSize.test.d.ts.map +1 -0
  47. package/dist/__tests__/pictureBelowPrintSize.test.js +82 -0
  48. package/dist/__tests__/pictureBelowPrintSize.test.js.map +1 -0
  49. package/dist/__tests__/pipeline/paragraphStyleFaces.test.js +1 -1
  50. package/dist/__tests__/pipeline/paragraphStyleFaces.test.js.map +1 -1
  51. package/dist/canvas-backend/composed.d.ts +5 -2
  52. package/dist/canvas-backend/composed.d.ts.map +1 -1
  53. package/dist/canvas-backend/composed.js +5 -3
  54. package/dist/canvas-backend/composed.js.map +1 -1
  55. package/dist/canvas-backend/index.d.ts.map +1 -1
  56. package/dist/canvas-backend/index.js +37 -19
  57. package/dist/canvas-backend/index.js.map +1 -1
  58. package/dist/canvas-backend/renderResourceBlock.d.ts +5 -1
  59. package/dist/canvas-backend/renderResourceBlock.d.ts.map +1 -1
  60. package/dist/canvas-backend/renderResourceBlock.js +60 -1
  61. package/dist/canvas-backend/renderResourceBlock.js.map +1 -1
  62. package/dist/composed/continuation.d.ts +102 -0
  63. package/dist/composed/continuation.d.ts.map +1 -0
  64. package/dist/composed/continuation.js +87 -0
  65. package/dist/composed/continuation.js.map +1 -0
  66. package/dist/composed/labels.d.ts +154 -0
  67. package/dist/composed/labels.d.ts.map +1 -0
  68. package/dist/composed/labels.js +524 -0
  69. package/dist/composed/labels.js.map +1 -0
  70. package/dist/composed/pageMemo.d.ts +3 -2
  71. package/dist/composed/pageMemo.d.ts.map +1 -1
  72. package/dist/composed/pageMemo.js +3 -1
  73. package/dist/composed/pageMemo.js.map +1 -1
  74. package/dist/composed/paint.d.ts +8 -2
  75. package/dist/composed/paint.d.ts.map +1 -1
  76. package/dist/composed/paint.js +8 -2
  77. package/dist/composed/paint.js.map +1 -1
  78. package/dist/composed/reflowLog.d.ts +3 -1
  79. package/dist/composed/reflowLog.d.ts.map +1 -1
  80. package/dist/composed/reflowLog.js +20 -6
  81. package/dist/composed/reflowLog.js.map +1 -1
  82. package/dist/composed/sourceMap.d.ts +0 -21
  83. package/dist/composed/sourceMap.d.ts.map +1 -1
  84. package/dist/composed/sourceMap.js +87 -7
  85. package/dist/composed/sourceMap.js.map +1 -1
  86. package/dist/composed/spread.d.ts +3 -0
  87. package/dist/composed/spread.d.ts.map +1 -1
  88. package/dist/composed/spread.js +1 -1
  89. package/dist/composed/spread.js.map +1 -1
  90. package/dist/configWarnings.d.ts +15 -0
  91. package/dist/configWarnings.d.ts.map +1 -1
  92. package/dist/configWarnings.js +29 -17
  93. package/dist/configWarnings.js.map +1 -1
  94. package/dist/contrast.d.ts +5 -3
  95. package/dist/contrast.d.ts.map +1 -1
  96. package/dist/contrast.js +46 -5
  97. package/dist/contrast.js.map +1 -1
  98. package/dist/defaults/paragraphStyles.d.ts +1 -1
  99. package/dist/defaults/paragraphStyles.d.ts.map +1 -1
  100. package/dist/defaults/paragraphStyles.js +5 -1
  101. package/dist/defaults/paragraphStyles.js.map +1 -1
  102. package/dist/design/slots.d.ts +12 -10
  103. package/dist/design/slots.d.ts.map +1 -1
  104. package/dist/design/slots.js +26 -2
  105. package/dist/design/slots.js.map +1 -1
  106. package/dist/fonts/faces.d.ts.map +1 -1
  107. package/dist/fonts/faces.js +6 -0
  108. package/dist/fonts/faces.js.map +1 -1
  109. package/dist/highlightMarks.d.ts.map +1 -1
  110. package/dist/highlightMarks.js +6 -0
  111. package/dist/highlightMarks.js.map +1 -1
  112. package/dist/html-backend.d.ts.map +1 -1
  113. package/dist/html-backend.js +40 -2
  114. package/dist/html-backend.js.map +1 -1
  115. package/dist/index.d.ts +7 -3
  116. package/dist/index.d.ts.map +1 -1
  117. package/dist/index.js +5 -1
  118. package/dist/index.js.map +1 -1
  119. package/dist/migrate/markdownRuns.d.ts +70 -0
  120. package/dist/migrate/markdownRuns.d.ts.map +1 -0
  121. package/dist/migrate/markdownRuns.js +215 -0
  122. package/dist/migrate/markdownRuns.js.map +1 -0
  123. package/dist/migrate/pageDesign.d.ts +119 -0
  124. package/dist/migrate/pageDesign.d.ts.map +1 -0
  125. package/dist/migrate/pageDesign.js +446 -0
  126. package/dist/migrate/pageDesign.js.map +1 -0
  127. package/dist/migrate/textToMarkdown.d.ts +124 -0
  128. package/dist/migrate/textToMarkdown.d.ts.map +1 -0
  129. package/dist/migrate/textToMarkdown.js +716 -0
  130. package/dist/migrate/textToMarkdown.js.map +1 -0
  131. package/dist/pipeline/build.d.ts.map +1 -1
  132. package/dist/pipeline/build.js +192 -24
  133. package/dist/pipeline/build.js.map +1 -1
  134. package/dist/pipeline/buildMeasurement.d.ts.map +1 -1
  135. package/dist/pipeline/buildMeasurement.js +12 -1
  136. package/dist/pipeline/buildMeasurement.js.map +1 -1
  137. package/dist/pipeline/calloutLayout.d.ts +20 -1
  138. package/dist/pipeline/calloutLayout.d.ts.map +1 -1
  139. package/dist/pipeline/calloutLayout.js +30 -2
  140. package/dist/pipeline/calloutLayout.js.map +1 -1
  141. package/dist/pipeline/composedLayout.d.ts +16 -2
  142. package/dist/pipeline/composedLayout.d.ts.map +1 -1
  143. package/dist/pipeline/composedLayout.js +107 -37
  144. package/dist/pipeline/composedLayout.js.map +1 -1
  145. package/dist/pipeline/contentWarnings.d.ts +15 -0
  146. package/dist/pipeline/contentWarnings.d.ts.map +1 -1
  147. package/dist/pipeline/contentWarnings.js +85 -0
  148. package/dist/pipeline/contentWarnings.js.map +1 -1
  149. package/dist/pipeline/frameLayout.d.ts +4 -1
  150. package/dist/pipeline/frameLayout.d.ts.map +1 -1
  151. package/dist/pipeline/frameLayout.js +5 -2
  152. package/dist/pipeline/frameLayout.js.map +1 -1
  153. package/dist/pipeline/headerFooter.d.ts +11 -1
  154. package/dist/pipeline/headerFooter.d.ts.map +1 -1
  155. package/dist/pipeline/headerFooter.js +169 -66
  156. package/dist/pipeline/headerFooter.js.map +1 -1
  157. package/dist/pipeline/mirrorFrame.d.ts.map +1 -1
  158. package/dist/pipeline/mirrorFrame.js +25 -2
  159. package/dist/pipeline/mirrorFrame.js.map +1 -1
  160. package/dist/pipeline/resourceLayout.d.ts +28 -0
  161. package/dist/pipeline/resourceLayout.d.ts.map +1 -1
  162. package/dist/pipeline/resourceLayout.js +21 -0
  163. package/dist/pipeline/resourceLayout.js.map +1 -1
  164. package/dist/pipeline/styles.d.ts +1 -1
  165. package/dist/pipeline/styles.d.ts.map +1 -1
  166. package/dist/pipeline/styles.js +4 -0
  167. package/dist/pipeline/styles.js.map +1 -1
  168. package/dist/types.d.ts +13 -0
  169. package/dist/types.d.ts.map +1 -1
  170. package/dist/vdt.d.ts +138 -7
  171. package/dist/vdt.d.ts.map +1 -1
  172. package/dist/vdt.js.map +1 -1
  173. package/dist/word/toDocx.d.ts.map +1 -1
  174. package/dist/word/toDocx.js +14 -0
  175. package/dist/word/toDocx.js.map +1 -1
  176. package/dist/word/word.test.js +11 -1
  177. package/dist/word/word.test.js.map +1 -1
  178. package/package.json +1 -1
@@ -0,0 +1,87 @@
1
+ import { nextFrameOf } from './geometry';
2
+ import { continueInTemplate } from './templates';
3
+ /** How many pages, one after another, the content of one composed page may
4
+ * go on to: the generation of added pages after which what still does not
5
+ * fit is cut (`frameContinuationLimit`). */
6
+ export const MAX_CONTINUATION_PAGES = 16;
7
+ /** `continueIn` sends content to another page. */
8
+ export function continuesOffPage(continueIn) {
9
+ return continueIn === 'next-page' || continueInTemplate(continueIn) !== undefined;
10
+ }
11
+ /** The page an added page is built from for `c`: its template id, and
12
+ * whether the template's frames that receive nothing collapse. */
13
+ export function continuationTarget(c, overflowTemplateOf) {
14
+ const named = continueInTemplate(c.rule);
15
+ if (named !== undefined)
16
+ return { template: named, collapse: false };
17
+ // 'next-page': the template's overflow template, or the template again.
18
+ const over = overflowTemplateOf(c.template);
19
+ if (over !== undefined && over !== c.template)
20
+ return { template: over, collapse: false };
21
+ return { template: c.template, collapse: over === undefined || c.collapsed };
22
+ }
23
+ /**
24
+ * The frames of `template` that take `list`, in order: each goes on in
25
+ * the frame of its name, else the flow frame, else the first frame no
26
+ * other continuation took. Those that find no free frame are `left` for
27
+ * another page.
28
+ */
29
+ export function assignReceivers(template, list) {
30
+ const receivers = new Map();
31
+ const left = [];
32
+ const names = new Set(template.frames.map((f) => f.name));
33
+ const flow = template.frames.find((f) => f.flow)?.name;
34
+ for (const c of list) {
35
+ const take = [c.frame, flow, ...template.frames.map((f) => f.name)].find((n) => n !== undefined && names.has(n) && !receivers.has(n));
36
+ if (take === undefined)
37
+ left.push(c);
38
+ else
39
+ receivers.set(take, c);
40
+ }
41
+ return { receivers, left };
42
+ }
43
+ /**
44
+ * The template an added page is laid with: the receivers (and the frames
45
+ * their chains go on in on that page) continue as the rule that brought
46
+ * the content, unless they send content off the page themselves; on the
47
+ * last page allowed nothing goes on; with `collapse`, every other frame
48
+ * takes no room and leaves its group.
49
+ */
50
+ export function continuationTemplate(template, input) {
51
+ const byName = new Map(template.frames.map((f) => [f.name, f]));
52
+ /** Frames the received content fills, with the rule it came by. */
53
+ const filled = new Map();
54
+ for (const [name, c] of input.receivers) {
55
+ const seen = new Set();
56
+ for (let n = name; n !== undefined && byName.has(n) && !seen.has(n); n = nextFrameOf(byName.get(n))) {
57
+ seen.add(n);
58
+ if (!filled.has(n))
59
+ filled.set(n, c.rule);
60
+ }
61
+ }
62
+ const frames = template.frames.map((f) => {
63
+ const rule = filled.get(f.name);
64
+ if (rule !== undefined) {
65
+ const own = f.overflow.continueIn;
66
+ if (input.last && continuesOffPage(own)) {
67
+ const overflow = { ...f.overflow };
68
+ delete overflow.continueIn;
69
+ return { ...f, overflow };
70
+ }
71
+ // The last frame of the chain goes on as the content came, unless
72
+ // it says where itself.
73
+ if (!input.last && nextFrameOf(f) === undefined && !continuesOffPage(own))
74
+ return { ...f, overflow: { ...f.overflow, continueIn: rule } };
75
+ return f;
76
+ }
77
+ if (!input.collapse)
78
+ return f;
79
+ const out = { ...f, height: 'auto', grow: 0 };
80
+ delete out.minHeight;
81
+ delete out.maxHeight;
82
+ return out;
83
+ });
84
+ const groups = input.collapse ? template.groups.map((g) => ({ ...g, frames: g.frames.filter((n) => filled.has(n)) })) : template.groups;
85
+ return { ...template, frames, groups };
86
+ }
87
+ //# sourceMappingURL=continuation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"continuation.js","sourceRoot":"","sources":["../../src/composed/continuation.ts"],"names":[],"mappings":"AAwBA,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AACzC,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAGjD;;6CAE6C;AAC7C,MAAM,CAAC,MAAM,sBAAsB,GAAG,EAAE,CAAC;AAkDzC,kDAAkD;AAClD,MAAM,UAAU,gBAAgB,CAAC,UAA8B;IAC7D,OAAO,UAAU,KAAK,WAAW,IAAI,kBAAkB,CAAC,UAAU,CAAC,KAAK,SAAS,CAAC;AACpF,CAAC;AAED;mEACmE;AACnE,MAAM,UAAU,kBAAkB,CAChC,CAAg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AAC,CAAC,EAAE,GAAG,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC;IACxI,OAAO,EAAE,GAAG,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC;AACzC,CAAC"}
@@ -0,0 +1,154 @@
1
+ /**
2
+ * Figure labels drawn on their picture (#860, DESIGN §2.6, §3.3).
3
+ *
4
+ * A `:::figure` lists `::label[TEXT]{at style}` lines; the resource holds
5
+ * the anchors (points in fractions of the whole picture, shared by every
6
+ * locale). Each label is set as a small caption (inline Markdown: bold,
7
+ * italic, chips, marks, references, formulas) in its label style, wrapped
8
+ * within its anchor's `width` and, when a word is still too wide, set
9
+ * smaller down to the style's `minScale`. Its box stands at the anchor's
10
+ * point as `align` / `verticalAlign` say (start and end follow the label's
11
+ * own direction), turned by `rotate` degrees about that point.
12
+ *
13
+ * The label's geometry is kept in its own frame (origin at the anchor
14
+ * point) and the point itself relative to the picture's body, so the
15
+ * label moves with its block wherever placement, frames, spreads or the
16
+ * memo put it, and the painters only add the body's corner:
17
+ * {@link figureLabelMatrix}. Once the pages exist the build stamps each
18
+ * label's `rect` (for `sourceAt`) and reports the anchors a figure names
19
+ * wrongly or leaves without a word ({@link figureLabelWarnings}).
20
+ */
21
+ import type { InlineSpan } from '../parse/types';
22
+ import type { FigureLabel } from '../parse/types';
23
+ import type { Resource, ResourceAnchor, ResourceType } from '../types';
24
+ import type { BoundingBox, ContentWarning, ResolvedConfig, ResolvedResourceBlock, VDTBlock, VDTDocument, VDTFigureLabel, VDTFigureLabelLayout, VDTLine } from '../vdt';
25
+ import type { MeasurementCache } from '../measure';
26
+ import type { ResourceNumberingMap } from '../pipeline/resourceNumbering';
27
+ /** `[a, b, c, d, e, f]`, canvas `transform` order (y down). */
28
+ export type LabelMatrix = [number, number, number, number, number, number];
29
+ /** A label style resolved for one label: the type and the plate. */
30
+ export interface LabelLook {
31
+ styleId?: string;
32
+ fontFamily: string;
33
+ fontPx: number;
34
+ weight: number;
35
+ boldWeight: number;
36
+ italic: boolean;
37
+ color: string;
38
+ uppercase: boolean;
39
+ /** Ems. */
40
+ letterSpacing: number;
41
+ lineHeight: number;
42
+ halo?: {
43
+ color: string;
44
+ widthPx: number;
45
+ };
46
+ background?: string;
47
+ paddingPx: number;
48
+ minScale: number;
49
+ }
50
+ /**
51
+ * The look of a label set in style `styleId` (the label's own `style`,
52
+ * else its anchor's): the body text's type, under the paragraph style the
53
+ * label style borrows (`paragraphStyle`), under the label style's own
54
+ * fields. An unknown or absent style is the body text's type.
55
+ */
56
+ export declare function resolveLabelLook(styleId: string | undefined, resolved: ResolvedConfig): LabelLook;
57
+ /** Where a label stands on the picture: its anchor (looked up on the
58
+ * resource) or its percentages, with the anchor's label fields. */
59
+ export interface LabelPlace {
60
+ /** Fractions of the whole picture. */
61
+ x: number;
62
+ y: number;
63
+ anchor?: ResourceAnchor;
64
+ }
65
+ /** The place of `label` on `resource`; undefined when it names an anchor
66
+ * the resource lacks. */
67
+ export declare function labelPlace(label: Pick<VDTFigureLabel, 'at'>, resource: Pick<Resource, 'anchors'>): LabelPlace | undefined;
68
+ /** A point of the whole picture (fractions) in px from the top-left of the
69
+ * body as drawn: through its crop (`bodySource`) and its size. */
70
+ export declare function pictureToBody(rb: Pick<ResolvedResourceBlock, 'bodyRect' | 'bodySource'>, fx: number, fy: number): {
71
+ x: number;
72
+ y: number;
73
+ };
74
+ /** What laying the labels out needs besides the block. */
75
+ export interface FigureLabelContext {
76
+ resolved: ResolvedConfig;
77
+ resourceNumbering?: ResourceNumberingMap;
78
+ resourceTypes?: ResourceType[];
79
+ resources?: Resource[];
80
+ cache?: MeasurementCache;
81
+ }
82
+ /**
83
+ * Lay out one label: its lines in its look, wrapped within `widthPx` (none:
84
+ * one line per forced break), set smaller (down to `minScale`) while a
85
+ * line is wider, then placed about the anchor point by `align` and
86
+ * `verticalAlign`.
87
+ */
88
+ export declare function layOutLabel(spans: readonly InlineSpan[], look: LabelLook, place: {
89
+ x: number;
90
+ y: number;
91
+ widthPx?: number;
92
+ align?: ResourceAnchor['align'];
93
+ verticalAlign?: ResourceAnchor['verticalAlign'];
94
+ rotate?: number;
95
+ }, ctx: FigureLabelContext): VDTFigureLabelLayout | undefined;
96
+ /**
97
+ * The labels of a figure laid out on its picture: `labels` (the VDT's,
98
+ * `figureLabels`) with the `layout` of each one that can be drawn, read
99
+ * from `parsed` (the parser's, the same order) for its inline Markdown.
100
+ * A table, a video or a picture with no body draws none; a label whose
101
+ * anchor is unknown is left without a layout.
102
+ */
103
+ export declare function layOutFigureLabels(labels: readonly VDTFigureLabel[], parsed: readonly Pick<FigureLabel, 'spans'>[] | undefined, rb: ResolvedResourceBlock, ctx: FigureLabelContext): VDTFigureLabel[];
104
+ /** The matrix that puts a label's frame on the block's frame, the body's
105
+ * top-left corner at (`bodyX`, `bodyY`): `translate(body + point) ·
106
+ * rotate(rotate)`. */
107
+ export declare function figureLabelMatrix(layout: Pick<VDTFigureLabelLayout, 'x' | 'y' | 'rotate'>, bodyX: number, bodyY: number): LabelMatrix;
108
+ /** What a label paints in its own frame: its background, else its lines'
109
+ * box. */
110
+ export declare function figureLabelExtent(layout: VDTFigureLabelLayout): BoundingBox;
111
+ /** The upright box a label covers in the block's frame. */
112
+ export declare function figureLabelBounds(layout: VDTFigureLabelLayout, bodyX: number, bodyY: number): BoundingBox;
113
+ /** The point `(x, y)` of the block's frame in a label's own frame. */
114
+ export declare function pointInLabel(layout: VDTFigureLabelLayout, bodyX: number, bodyY: number, x: number, y: number): {
115
+ x: number;
116
+ y: number;
117
+ };
118
+ /**
119
+ * Stamp `rect` on every drawn label of the document (#860): the upright
120
+ * box it covers in its block's frame, through a quarter-turned block's
121
+ * turn. A label not drawn loses any `rect` it had.
122
+ */
123
+ export declare function stampFigureLabelRects(doc: VDTDocument): void;
124
+ /**
125
+ * The glyph of a drawn label under the point `(x, y)` of its block's
126
+ * frame: the index into `label.text`'s source map, or undefined off its
127
+ * lines. Lines are read from their plain ranges; a label whose lines lack
128
+ * them spreads its text over its lines in order.
129
+ */
130
+ export declare function labelGlyphAt(label: VDTFigureLabel, block: Pick<VDTBlock, 'bbox' | 'resourceBlock'>, x: number, y: number): number | undefined;
131
+ /**
132
+ * A label layout for the flow of a mirrored page (a right-to-left book):
133
+ * its point, its turn and its lines reflected about the body's vertical
134
+ * axis, so that the page's reflection puts it back where the picture shows
135
+ * it, reading as written. `bodyWidth` is the body's width; `orient` turns
136
+ * a line's run order for the frame as the build does for captions.
137
+ */
138
+ export declare function mirrorLabelLayout(layout: VDTFigureLabelLayout, bodyWidth: number, orient: (line: VDTLine) => VDTLine): VDTFigureLabelLayout;
139
+ /** The labels of a figure that are not drawn as text: what its picture's
140
+ * alternative text still names (`altWithLabels`). */
141
+ export declare function undrawnLabels(labels: readonly VDTFigureLabel[] | undefined): VDTFigureLabel[] | undefined;
142
+ /** A drawn label's words as read, its lines joined by a space. */
143
+ export declare function figureLabelReading(label: VDTFigureLabel): string;
144
+ /**
145
+ * The anchors the figures of `doc` name wrongly (`labelAnchorUnknown`, at
146
+ * the label's text) or leave without a word (`anchorUnlabelled`, a note
147
+ * at the figure: an anchor that names a label style and that no label of
148
+ * the figure stands at), each on the page its figure landed on.
149
+ */
150
+ export declare function figureLabelWarnings(doc: VDTDocument, figureSource: (block: VDTBlock) => {
151
+ start: number;
152
+ end: number;
153
+ } | undefined): ContentWarning[];
154
+ //# sourceMappingURL=labels.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"labels.d.ts","sourceRoot":"","sources":["../../src/composed/labels.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AACjD,OAAO,KAAK,EAAE,WAA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