@heroiclands/package-build 23.12.6 → 23.12.8

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 (94) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/assets/styles/content-base.css +25 -0
  3. package/bin/content-commands.mjs +264 -3
  4. package/bin/package-build.mjs +25 -0
  5. package/content-config.mjs +72 -0
  6. package/docs/api.md +10 -9
  7. package/docs/authoring/assets.md +1 -1
  8. package/docs/authoring/links-and-markup.md +439 -47
  9. package/docs/commands.md +137 -3
  10. package/docs/configuration.md +73 -3
  11. package/docs/content-format.md +3 -1
  12. package/docs/guides/book.md +11 -0
  13. package/docs/guides/module-project.md +16 -0
  14. package/docs/guides/site.md +19 -0
  15. package/docs/reference/format-details.md +378 -6
  16. package/docs/reference/note-types.md +36 -11
  17. package/e2e.mjs +1 -1
  18. package/engine/asset-shipping.mjs +22 -8
  19. package/engine/base-compiler.mjs +2 -0
  20. package/engine/bundles.mjs +7 -2
  21. package/engine/compile-corpus.mjs +3 -1
  22. package/engine/content-charset.mjs +21 -2
  23. package/engine/content-format.yaml +1 -0
  24. package/engine/content-index.mjs +12 -0
  25. package/engine/content-poetry.mjs +22 -4
  26. package/engine/content-scripts.mjs +1219 -0
  27. package/engine/content-session.mjs +2 -0
  28. package/engine/data-keys.mjs +5 -1
  29. package/engine/dictionary-layout.mjs +18 -12
  30. package/engine/dictionary-rows.mjs +11 -2
  31. package/engine/helpers.mjs +8 -2
  32. package/engine/index-records.mjs +1 -0
  33. package/engine/journals.mjs +14 -3
  34. package/engine/language-data.mjs +137 -1
  35. package/engine/language-tag.mjs +103 -0
  36. package/engine/language-terms.mjs +16 -4
  37. package/engine/map-lexicon.mjs +762 -0
  38. package/engine/markup-validation.mjs +17 -3
  39. package/engine/names.mjs +1 -1
  40. package/engine/note-vocabulary.mjs +113 -0
  41. package/engine/pdf-build.mjs +28 -10
  42. package/engine/pdf-render.mjs +116 -11
  43. package/engine/run-rows.mjs +119 -0
  44. package/engine/run-words.mjs +266 -0
  45. package/engine/scenes.mjs +1 -0
  46. package/engine/script-font-delivery.mjs +321 -0
  47. package/engine/script-fonts.mjs +172 -0
  48. package/engine/site-build.mjs +10 -3
  49. package/engine/site-config.mjs +5 -0
  50. package/engine/site-root.mjs +19 -5
  51. package/engine/sql-tables.mjs +111 -1
  52. package/engine/text-maps.mjs +607 -0
  53. package/engine/verb-pattern.mjs +99 -0
  54. package/engine/word-pattern.mjs +27 -0
  55. package/engine/word-rows.mjs +8 -2
  56. package/engine/word-terms.mjs +44 -0
  57. package/hugo-theme/layouts/_default/baseof.html +3 -0
  58. package/hugo-theme/static/css/style.css +10 -0
  59. package/manifest.mjs +9 -1
  60. package/package.json +2 -2
  61. package/types/content-config.d.mts +26 -0
  62. package/types/e2e.d.mts +2 -2
  63. package/types/engine/address-fields.d.mts +1 -1
  64. package/types/engine/address-values.d.mts +1 -1
  65. package/types/engine/asset-shipping.d.mts +5 -0
  66. package/types/engine/compile-corpus.d.mts +2 -1
  67. package/types/engine/content-format-check.d.mts +1 -1
  68. package/types/engine/content-index.d.mts +11 -3
  69. package/types/engine/content-poetry.d.mts +7 -0
  70. package/types/engine/content-scripts.d.mts +226 -0
  71. package/types/engine/data-keys.d.mts +2 -2
  72. package/types/engine/dictionary-rows.d.mts +15 -0
  73. package/types/engine/helpers.d.mts +5 -1
  74. package/types/engine/journals.d.mts +7 -2
  75. package/types/engine/language-data.d.mts +2 -0
  76. package/types/engine/language-tag.d.mts +8 -0
  77. package/types/engine/language-terms.d.mts +2 -1
  78. package/types/engine/map-lexicon.d.mts +274 -0
  79. package/types/engine/markup-validation.d.mts +7 -2
  80. package/types/engine/note-vocabulary.d.mts +1 -1
  81. package/types/engine/pdf-build.d.mts +26 -3
  82. package/types/engine/pdf-coverage.d.mts +1 -1
  83. package/types/engine/pdf-render.d.mts +17 -2
  84. package/types/engine/run-rows.d.mts +89 -0
  85. package/types/engine/run-words.d.mts +86 -0
  86. package/types/engine/script-font-delivery.d.mts +134 -0
  87. package/types/engine/script-fonts.d.mts +168 -0
  88. package/types/engine/site-build.d.mts +2 -1
  89. package/types/engine/site-root.d.mts +11 -3
  90. package/types/engine/text-maps.d.mts +175 -0
  91. package/types/engine/verb-pattern.d.mts +65 -0
  92. package/types/engine/word-pattern.d.mts +13 -0
  93. package/types/engine/word-terms.d.mts +6 -0
  94. package/types/release.d.mts +1 -1
@@ -0,0 +1,226 @@
1
+ /**
2
+ * The context a resolved configuration gives, and the maps an index holds.
3
+ *
4
+ * @param {{languages?: object, rootDir?: string}|undefined} config - The
5
+ * resolved configuration.
6
+ * @param {Iterable<Record<string, any>>} [records] - The content index's
7
+ * records, whose mapping notes give the maps. Without them no map is known.
8
+ * @returns {RunContext} Its languages, the faces installed where it sits, and
9
+ * the maps. A fonts package that cannot be read gives no faces; a run naming
10
+ * one is reported.
11
+ */
12
+ export function runContext(config: {
13
+ languages?: object;
14
+ rootDir?: string;
15
+ } | undefined, records?: Iterable<Record<string, any>>): RunContext;
16
+ /**
17
+ * Find the spans, divs and poetry fences marked with `lang=`, `font=` or
18
+ * `map=`, and every fault in their markup and their text.
19
+ *
20
+ * @param {string} source - Authored Markdown: a note body, or a whole file
21
+ * whose frontmatter is blanked.
22
+ * @param {RunContext} [ctx] - The configured languages, the installed faces
23
+ * and the maps. Without them every `lang=` must be a tag, every face and
24
+ * map is unknown, and only `mono`, `serif` and `sans` are fonts.
25
+ * @param {import("./content-session.mjs").ContentSyntax} [syntax] - Session
26
+ * scanner projections, so the source's spans and blocks are scanned once.
27
+ * @returns {{runs: Run[], errors: Array<{line: number, column: number, message: string}>, warnings: Array<{line: number, column: number, message: string}>}}
28
+ * The runs in source order, and each finding at its 1-based position. A
29
+ * warning is a `lang=` read as a tag that sits within one edit of a
30
+ * declared name.
31
+ */
32
+ export function scanRuns(source: string, ctx?: RunContext, syntax?: import("./content-session.mjs").ContentSyntax): {
33
+ runs: Run[];
34
+ errors: Array<{
35
+ line: number;
36
+ column: number;
37
+ message: string;
38
+ }>;
39
+ warnings: Array<{
40
+ line: number;
41
+ column: number;
42
+ message: string;
43
+ }>;
44
+ };
45
+ /**
46
+ * Rewrite text marked with `lang=`, `font=` and `map=` into the plain span,
47
+ * div and poetry grammar the rest of each chain renders, one line for one line.
48
+ *
49
+ * - **The map, if any, is applied first.** Characters Markdown would read are
50
+ * then backslash-escaped, so they reach every later pass as characters.
51
+ * - **The construct carries** the language's tag as `lang`, the face's class
52
+ * (with `script`, and `script-block` on a div) or the generic family's
53
+ * class. On the site, a face's construct also carries
54
+ * `data-pagefind-ignore`, since site search cannot read its code points;
55
+ * Foundry and the book receive no search marker.
56
+ * - **A div or fence in a right-to-left face** carries `dir=rtl`. No direction
57
+ * mark, `<bdo>` or `<bdi>` is ever written: the code points carry their own
58
+ * direction.
59
+ *
60
+ * A run with a finding is left as written; {@link scanRuns} reports it.
61
+ *
62
+ * @param {string} source - Authored Markdown: a note body.
63
+ * @param {RunContext} [ctx] - The configured languages, faces and maps.
64
+ * @param {import("./content-session.mjs").ContentSyntax} [syntax] - Session
65
+ * scanner projections.
66
+ * @param {{target?: "site"|"foundry"|"book"}} [options] - The target the
67
+ * Markdown is rendered for; only `site` writes the search marker.
68
+ * @returns {{markdown: string, errors: Array<{line: number, column: number, message: string}>}}
69
+ * The rewritten Markdown, and the findings of {@link scanRuns}.
70
+ */
71
+ export function renderRuns(source: string, ctx?: RunContext, syntax?: import("./content-session.mjs").ContentSyntax, options?: {
72
+ target?: "site" | "foundry" | "book";
73
+ }): {
74
+ markdown: string;
75
+ errors: Array<{
76
+ line: number;
77
+ column: number;
78
+ message: string;
79
+ }>;
80
+ };
81
+ /** The keys this module reads, which no construct passes through as written. */
82
+ export const RUN_KEYS: readonly string[];
83
+ /** The generic families `font=` may name, each with the class that sets it. */
84
+ export const GENERIC_FONTS: Readonly<{
85
+ mono: "font-mono";
86
+ serif: "font-serif";
87
+ sans: "font-sans";
88
+ }>;
89
+ /**
90
+ * One marked construct, with what rendering it needs beside its {@link Run}.
91
+ */
92
+ export type RunDetail = {
93
+ /**
94
+ * - The run.
95
+ */
96
+ run: Run;
97
+ /**
98
+ * -
99
+ * What the construct carries besides the run keys.
100
+ */
101
+ own: {
102
+ id: string;
103
+ classes: string[];
104
+ values: Array<[string, string]>;
105
+ };
106
+ /**
107
+ * - The run keys it states itself.
108
+ */
109
+ keys: Record<string, string>;
110
+ /**
111
+ * - Whether its text is set.
112
+ */
113
+ plain: boolean;
114
+ /**
115
+ * - Its face.
116
+ */
117
+ face: import("./script-fonts.mjs").Face | undefined;
118
+ /**
119
+ * - Its generic family's class.
120
+ */
121
+ generic: string | undefined;
122
+ /**
123
+ * - Its map.
124
+ */
125
+ textMap: import("./text-maps.mjs").TextMap | undefined;
126
+ /**
127
+ * - Its map,
128
+ * face and lexicon, which its text is set by.
129
+ */
130
+ mapping: import("./map-lexicon.mjs").Mapping | undefined;
131
+ /**
132
+ * - The marked spans inside it.
133
+ */
134
+ holes: Map<number, number>;
135
+ /**
136
+ * - A div's or fence's body, as
137
+ * offsets: the first body line's start to the end of the last.
138
+ */
139
+ body: [number, number] | undefined;
140
+ /**
141
+ * - A span's offset of its closing `]`.
142
+ */
143
+ contentEnd: number | undefined;
144
+ };
145
+ /**
146
+ * What a run is checked against.
147
+ */
148
+ export type RunContext = {
149
+ /**
150
+ * - The
151
+ * configured languages.
152
+ */
153
+ languages?: Readonly<Record<string, {
154
+ tag: string;
155
+ }>> | undefined;
156
+ /**
157
+ * -
158
+ * The installed faces by slug, from
159
+ * {@link module :engine/script-fonts.resolveScriptFonts}.
160
+ */
161
+ faces?: ReadonlyMap<string, import("./script-fonts.mjs").Face> | undefined;
162
+ /**
163
+ * -
164
+ * The mapping notes' maps by name, from
165
+ * {@link module :engine/text-maps.mapsFromRecords}.
166
+ */
167
+ maps?: ReadonlyMap<string, import("./text-maps.mjs").TextMap> | undefined;
168
+ /**
169
+ * -
170
+ * Each configured language's lexicon by name, from
171
+ * {@link module :engine/map-lexicon.lexiconsFromRecords}.
172
+ */
173
+ lexicons?: ReadonlyMap<string, import("./map-lexicon.mjs").Lexicon> | undefined;
174
+ /**
175
+ * -
176
+ * What each configured language's mapped runs are checked against, from
177
+ * {@link module :engine/run-words.wordBooksFromRecords}.
178
+ */
179
+ wordBooks?: ReadonlyMap<string, import("./run-words.mjs").WordBook> | undefined;
180
+ };
181
+ /**
182
+ * One span, div or poetry fence carrying `lang=`, `font=` or `map=`. Its
183
+ * `lang`, `font` and `map` are the ones it is set with: its own, else the
184
+ * innermost div or fence around it that states one.
185
+ */
186
+ export type Run = {
187
+ /**
188
+ * - Which construct.
189
+ */
190
+ kind: "span" | "block" | "poetry";
191
+ /**
192
+ * - The language as written.
193
+ */
194
+ lang: string | undefined;
195
+ /**
196
+ * - The BCP 47 tag it resolves to; `undefined`
197
+ * when it resolves to none.
198
+ */
199
+ tag: string | undefined;
200
+ /**
201
+ * - The font as written.
202
+ */
203
+ font: string | undefined;
204
+ /**
205
+ * - The map as written.
206
+ */
207
+ map: string | undefined;
208
+ /**
209
+ * - 1-based line of the construct's opening.
210
+ */
211
+ line: number;
212
+ /**
213
+ * - 1-based UTF-16 column of its opening.
214
+ */
215
+ column: number;
216
+ /**
217
+ * - A span's offset of `[`; a div's or fence's
218
+ * 0-based opening line.
219
+ */
220
+ start: number;
221
+ /**
222
+ * - A span's offset past its attributes; a div's or
223
+ * fence's 0-based closing line.
224
+ */
225
+ end: number;
226
+ };
@@ -5,7 +5,7 @@
5
5
  * @property {string} name - The key as an author writes it.
6
6
  * @property {string} [kind] - Its value's shape: `string`, `date`, `number`,
7
7
  * `integer`, `boolean`, `address`, `list`, `map`, `scalar-or-map`,
8
- * `string-or-list`, or `string-list-or-map` — see {@link fitsKind}. Absent, the check
8
+ * `string-or-list`, `string-list-or-map` or `list-or-map` — see {@link fitsKind}. Absent, the check
9
9
  * makes no claim about the value.
10
10
  * @property {readonly string[]} [allowed] - The closed set a present value is
11
11
  * one of, where the key takes a fixed word.
@@ -97,7 +97,7 @@ export type InnerKeySpec = {
97
97
  /**
98
98
  * - Its value's shape: `string`, `date`, `number`,
99
99
  * `integer`, `boolean`, `address`, `list`, `map`, `scalar-or-map`,
100
- * `string-or-list`, or `string-list-or-map` — see {@link fitsKind}. Absent, the check
100
+ * `string-or-list`, `string-list-or-map` or `list-or-map` — see {@link fitsKind}. Absent, the check
101
101
  * makes no claim about the value.
102
102
  */
103
103
  kind?: string | undefined;
@@ -1,3 +1,18 @@
1
+ /**
2
+ * A noun's stated plural, or the first literal ending replacement that fits.
3
+ *
4
+ * @param {{form: string, class?: unknown, plural?: unknown}} word - A word of
5
+ * `data.words`.
6
+ * @param {Record<string, any>|undefined} grammar - Its language's
7
+ * `data.grammar`.
8
+ * @returns {string|null} The plural, or `null` for a word that is no noun or
9
+ * that no rule fits.
10
+ */
11
+ export function pluralOf(word: {
12
+ form: string;
13
+ class?: unknown;
14
+ plural?: unknown;
15
+ }, grammar: Record<string, any> | undefined): string | null;
1
16
  /**
2
17
  * The stable prose anchor of a word in one language's dictionary. The exact
3
18
  * language and NFC form identify it, including case and accents.
@@ -10,12 +10,16 @@
10
10
  * @param {(address: string) => string|undefined} [resolveRole] - From a
11
11
  * picture's address to the role its asset declares — see
12
12
  * {@link module:engine/content-figures.scanFigures}.
13
+ * @param {import("./content-scripts.mjs").RunContext} [runs] - The package's
14
+ * languages, faces and maps. Given, text marked with `lang=`, `font=` and
15
+ * `map=` is rewritten first, so it is tagged for its language, mapped and
16
+ * set in its font.
13
17
  * @returns {string} The rendered HTML.
14
18
  */
15
19
  export function renderFoundryMarkdown(body: string, figures?: Array<{
16
20
  id: string;
17
21
  label: string;
18
- }>, footnoteNumbers?: Map<string, number>, docId?: string, resolveRole?: (address: string) => string | undefined): string;
22
+ }>, footnoteNumbers?: Map<string, number>, docId?: string, resolveRole?: (address: string) => string | undefined, runs?: import("./content-scripts.mjs").RunContext): string;
19
23
  /**
20
24
  * Parses a markdown file with LF or CRLF YAML frontmatter delimiters.
21
25
  *
@@ -134,13 +134,15 @@ export function journalPageId(entryId: string, page: {
134
134
  * carries its own figure already, from {@link splitPages}.
135
135
  * @param {(address: string) => string|undefined} [resolveRole] - See
136
136
  * {@link splitPages}.
137
+ * @param {import("./content-scripts.mjs").RunContext} [runs] - The package's
138
+ * languages, faces and maps — see {@link module:engine/helpers.renderFoundryMarkdown}.
137
139
  * @returns {Array<{_id: string, name: string, type: string,
138
140
  * title: {show: boolean, level: number},
139
141
  * text: {format: number, content: string}, _key: string,
140
142
  * ownership?: {default: number}}>} The page documents, in order.
141
143
  * @throws {Error} When the note has no content at all, or repeats an anchor.
142
144
  */
143
- export function buildPages(rawPages: Array<object>, entryId: string, noteName: string, figures: Array<object>, resolveRole?: (address: string) => string | undefined): Array<{
145
+ export function buildPages(rawPages: Array<object>, entryId: string, noteName: string, figures: Array<object>, resolveRole?: (address: string) => string | undefined, runs?: import("./content-scripts.mjs").RunContext): Array<{
144
146
  _id: string;
145
147
  name: string;
146
148
  type: string;
@@ -192,9 +194,11 @@ export function buildPages(rawPages: Array<object>, entryId: string, noteName: s
192
194
  * name reads `Map 1` rather than `Figure 1` where it is due — see
193
195
  * {@link module:engine/content-figures.scanFigures}.
194
196
  * @param {import("./content-session.mjs").ContentSyntax} [params.syntax] - Session scanner projections.
197
+ * @param {import("./content-scripts.mjs").RunContext} [params.runs] - The package's
198
+ * languages, faces and maps — see {@link module:engine/helpers.renderFoundryMarkdown}.
195
199
  * @returns {object} The JournalEntry document, keyed for the pack.
196
200
  */
197
- export function buildJournalEntry({ id, name, markdown, leadName, folder, stats, infoboxes, notice, resolveRole, syntax, }: {
201
+ export function buildJournalEntry({ id, name, markdown, leadName, folder, stats, infoboxes, notice, resolveRole, syntax, runs, }: {
198
202
  id: string;
199
203
  name: string;
200
204
  markdown: string;
@@ -209,6 +213,7 @@ export function buildJournalEntry({ id, name, markdown, leadName, folder, stats,
209
213
  notice?: string | undefined;
210
214
  resolveRole?: ((address: string) => string | undefined) | undefined;
211
215
  syntax?: import("./content-session.mjs").ContentSyntax | undefined;
216
+ runs?: import("./content-scripts.mjs").RunContext | undefined;
212
217
  }): object;
213
218
  /**
214
219
  * Journals pack compiler.
@@ -20,3 +20,5 @@ export function checkLanguageData(note: object, { index, types }?: {
20
20
  index?: object | undefined;
21
21
  types?: readonly string[] | undefined;
22
22
  }): object[];
23
+ /** How a foreign row that its tongue's register does not bear out is reported. */
24
+ export const FOREIGN_ROW_SEVERITY: "warning";
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Whether a value is a BCP 47 language tag.
3
+ *
4
+ * @param {unknown} value - The value to test.
5
+ * @returns {boolean} Whether it is a well-formed tag with no repeated variant
6
+ * or extension singleton.
7
+ */
8
+ export function isLanguageTag(value: unknown): boolean;
@@ -321,7 +321,8 @@ export const NEAR_NAME_FIELDS: readonly import("./data-keys.mjs").InnerKeySpec[]
321
321
  export const NAMING_FIELDS: readonly import("./data-keys.mjs").InnerKeySpec[];
322
322
  /**
323
323
  * The six present persons of the one optional regular verb pattern, in
324
- * presentation order. Empty endings leave the citation form unchanged.
324
+ * presentation order. Each ending is added to the citation form, or takes the
325
+ * place of its closing `replaces`; an empty ending adds nothing.
325
326
  *
326
327
  * @type {readonly import("./data-keys.mjs").InnerKeySpec[]}
327
328
  */
@@ -0,0 +1,274 @@
1
+ /**
2
+ * Each configured language's lexicon, read from the language note its `note`
3
+ * names. A language with no `note`, or one naming no language note, has none.
4
+ *
5
+ * @param {Iterable<Record<string, any>>|undefined} records - Index records.
6
+ * @param {{languages?: Readonly<Record<string, {tag: string, note?: string}>>, contentPackage?: string}} config -
7
+ * The resolved configuration.
8
+ * @returns {Map<string, Lexicon>} The lexicons by language name.
9
+ */
10
+ export function lexiconsFromRecords(records: Iterable<Record<string, any>> | undefined, config?: {
11
+ languages?: Readonly<Record<string, {
12
+ tag: string;
13
+ note?: string;
14
+ }>>;
15
+ contentPackage?: string;
16
+ }): Map<string, Lexicon>;
17
+ /**
18
+ * The language note each configured language's `note` names, by language
19
+ * name. A language with no `note`, or one naming no language note, is absent.
20
+ *
21
+ * @param {Iterable<Record<string, any>>|undefined} records - Index records.
22
+ * @param {{languages?: Readonly<Record<string, {tag: string, note?: string}>>, contentPackage?: string}} config -
23
+ * The resolved configuration.
24
+ * @returns {Map<string, Record<string, any>>} The records.
25
+ */
26
+ export function languageRecordsByName(records: Iterable<Record<string, any>> | undefined, { languages, contentPackage }?: {
27
+ languages?: Readonly<Record<string, {
28
+ tag: string;
29
+ note?: string;
30
+ }>>;
31
+ contentPackage?: string;
32
+ }): Map<string, Record<string, any>>;
33
+ /**
34
+ * Each `languages.<name>.note` that names no language note, at its key.
35
+ *
36
+ * @param {{languages?: Readonly<Record<string, {tag: string, note?: string}>>, contentPackage?: string, configFile?: string, configText?: string}} config -
37
+ * The resolved configuration, and where it was read from.
38
+ * @param {Iterable<Record<string, any>>} records - Index records.
39
+ * @returns {object[]} The findings.
40
+ */
41
+ export function languageNoteFindings(config: {
42
+ languages?: Readonly<Record<string, {
43
+ tag: string;
44
+ note?: string;
45
+ }>>;
46
+ contentPackage?: string;
47
+ configFile?: string;
48
+ configText?: string;
49
+ }, records: Iterable<Record<string, any>>): object[];
50
+ /**
51
+ * A lookup of a word's native form under one map in one face: the form stated
52
+ * for the face, else the one stated for no face.
53
+ *
54
+ * @param {Lexicon|undefined} lexicon - The lexicon.
55
+ * @param {string} map - The map's name.
56
+ * @param {string|undefined} font - The face.
57
+ * @returns {((word: string) => string|undefined)|undefined} The lookup, or
58
+ * `undefined` with no lexicon.
59
+ */
60
+ export function nativeLookup(lexicon: Lexicon | undefined, map: string, font: string | undefined): ((word: string) => string | undefined) | undefined;
61
+ /**
62
+ * What a run, a passage or a listing is mapped by.
63
+ *
64
+ * @typedef {object} Mapping
65
+ * @property {import("./text-maps.mjs").TextMap} map - The map.
66
+ * @property {string|undefined} font - The face, whose own rows come first.
67
+ * @property {((word: string) => string|undefined)|undefined} native - The
68
+ * language's native forms under the map in the face.
69
+ */
70
+ /**
71
+ * The one path from a map, a face and a language to what rewrites the text.
72
+ *
73
+ * @param {{maps?: ReadonlyMap<string, import("./text-maps.mjs").TextMap>, lexicons?: ReadonlyMap<string, Lexicon>}} ctx -
74
+ * The run context.
75
+ * @param {{map: string, font?: string, lang?: string}} keys - The map, the face
76
+ * and the language.
77
+ * @returns {Mapping|undefined} The mapping, or `undefined` for an unknown map.
78
+ */
79
+ export function mappingFor(ctx: {
80
+ maps?: ReadonlyMap<string, import("./text-maps.mjs").TextMap>;
81
+ lexicons?: ReadonlyMap<string, Lexicon>;
82
+ }, { map, font, lang }: {
83
+ map: string;
84
+ font?: string;
85
+ lang?: string;
86
+ }): Mapping | undefined;
87
+ /**
88
+ * Why a face is not one a map is for, or `undefined` where it is.
89
+ *
90
+ * @param {import("./text-maps.mjs").TextMap} map - The map.
91
+ * @param {string} font - The face's slug.
92
+ * @returns {string|undefined} The problem.
93
+ */
94
+ export function fontProblem(map: import("./text-maps.mjs").TextMap, font: string): string | undefined;
95
+ /**
96
+ * What is wrong with a capitalised word whose native form the rows cannot
97
+ * capitalise.
98
+ *
99
+ * @param {string} word - The word as written.
100
+ * @param {string} lower - The lowercase form the lexicon states.
101
+ * @param {string|undefined} lang - The language.
102
+ * @param {string} map - The map's name.
103
+ * @returns {string} The message.
104
+ */
105
+ export function uncapitalisedMessage(word: string, lower: string, lang: string | undefined, map: string): string;
106
+ /**
107
+ * Map a passage exactly as the build maps a run with the same keys.
108
+ *
109
+ * @param {object} ctx - The run context.
110
+ * @param {{map: string, font?: string, lang?: string}} keys - The map, the face
111
+ * and the language.
112
+ * @param {string} text - The passage, with no escapes.
113
+ * @returns {{text: string}|{problem: string, about: string}} The mapped text, or the problem.
114
+ */
115
+ export function transliterate(ctx: object, keys: {
116
+ map: string;
117
+ font?: string;
118
+ lang?: string;
119
+ }, text: string): {
120
+ text: string;
121
+ } | {
122
+ problem: string;
123
+ about: string;
124
+ };
125
+ /**
126
+ * Every word of a language's lexicon with its native form under a map: the
127
+ * stated exception, else the rows' spelling, each exactly as the build gives
128
+ * it.
129
+ *
130
+ * @param {object} ctx - The run context.
131
+ * @param {{lang: string, map: string, font?: string}} keys - The language, the
132
+ * map and the face.
133
+ * @returns {{entries: Array<{form: string, native: string, exception: boolean, class: string|null, gloss: string|null}>}|{problem: string, about: string}}
134
+ * The words in `data.words` order, or the problem.
135
+ */
136
+ export function lexiconEntries(ctx: object, { lang, map, font }: {
137
+ lang: string;
138
+ map: string;
139
+ font?: string;
140
+ }): {
141
+ entries: Array<{
142
+ form: string;
143
+ native: string;
144
+ exception: boolean;
145
+ class: string | null;
146
+ gloss: string | null;
147
+ }>;
148
+ } | {
149
+ problem: string;
150
+ about: string;
151
+ };
152
+ /**
153
+ * Check a mapping note's `fonts` against the installed faces: an unknown face
154
+ * and a face listed twice, at the entry, and each code point a listed face
155
+ * lacks, at the row that writes it.
156
+ *
157
+ * @param {{file: string, raw?: string, fm?: Record<string, any>}} note - The note.
158
+ * @param {{faces?: ReadonlyMap<string, import("./script-fonts.mjs").Face>, maps?: ReadonlyMap<string, import("./text-maps.mjs").TextMap>}} ctx -
159
+ * The run context.
160
+ * @returns {object[]} The findings.
161
+ */
162
+ export function checkMapFonts(note: {
163
+ file: string;
164
+ raw?: string;
165
+ fm?: Record<string, any>;
166
+ }, ctx: {
167
+ faces?: ReadonlyMap<string, import("./script-fonts.mjs").Face>;
168
+ maps?: ReadonlyMap<string, import("./text-maps.mjs").TextMap>;
169
+ }): object[];
170
+ /**
171
+ * Check a language note's native forms against the maps and faces: an unknown
172
+ * map, a face the map is not for, a second form for one map and face, a form
173
+ * that states what the rows already give, and a code point a face it applies
174
+ * in does not draw. The shape of each entry is the data-key check's.
175
+ *
176
+ * @param {{file: string, raw?: string, fm?: Record<string, any>}} note - The note.
177
+ * @param {{faces?: ReadonlyMap<string, import("./script-fonts.mjs").Face>, maps?: ReadonlyMap<string, import("./text-maps.mjs").TextMap>}} ctx -
178
+ * The run context.
179
+ * @returns {object[]} The findings.
180
+ */
181
+ export function checkLexiconNatives(note: {
182
+ file: string;
183
+ raw?: string;
184
+ fm?: Record<string, any>;
185
+ }, ctx: {
186
+ faces?: ReadonlyMap<string, import("./script-fonts.mjs").Face>;
187
+ maps?: ReadonlyMap<string, import("./text-maps.mjs").TextMap>;
188
+ }): object[];
189
+ /**
190
+ * One row per native form of a language note's word, for the `natives`
191
+ * relation: a text is a value of a row, never a struct key, so forms that
192
+ * differ only in case stay apart.
193
+ *
194
+ * @param {Iterable<Record<string, any>>} records - Index records.
195
+ * @returns {Array<Record<string, string|number|null>>} The rows; `word` is the
196
+ * word's 0-based place in `data.words`, `native` the form's in its `native`.
197
+ */
198
+ export function nativeRows(records: Iterable<Record<string, any>>): Array<Record<string, string | number | null>>;
199
+ /** Every column of the `natives` relation, in order. */
200
+ export const NATIVE_COLUMNS: readonly string[];
201
+ /**
202
+ * One native form, read.
203
+ */
204
+ export type NativeForm = {
205
+ /**
206
+ * - The map it is written for.
207
+ */
208
+ map: string;
209
+ /**
210
+ * - The one face it is for.
211
+ */
212
+ font: string | undefined;
213
+ /**
214
+ * - The word in the script.
215
+ */
216
+ text: string;
217
+ };
218
+ /**
219
+ * One word of a lexicon.
220
+ */
221
+ export type LexiconWord = {
222
+ /**
223
+ * - The word as cited.
224
+ */
225
+ form: string;
226
+ /**
227
+ * - Its class.
228
+ */
229
+ class: string | null;
230
+ /**
231
+ * - Its senses, joined by `; `.
232
+ */
233
+ gloss: string | null;
234
+ /**
235
+ * - Its native forms.
236
+ */
237
+ natives: readonly NativeForm[];
238
+ };
239
+ /**
240
+ * A language's lexicon.
241
+ */
242
+ export type Lexicon = {
243
+ /**
244
+ * - The language's configured name.
245
+ */
246
+ language: string;
247
+ /**
248
+ * - Its words, in `data.words` order.
249
+ */
250
+ words: readonly LexiconWord[];
251
+ /**
252
+ * - The native
253
+ * forms by the word's form, NFC; the first word of a form keeps it.
254
+ */
255
+ byForm: ReadonlyMap<string, readonly NativeForm[]>;
256
+ };
257
+ /**
258
+ * What a run, a passage or a listing is mapped by.
259
+ */
260
+ export type Mapping = {
261
+ /**
262
+ * - The map.
263
+ */
264
+ map: import("./text-maps.mjs").TextMap;
265
+ /**
266
+ * - The face, whose own rows come first.
267
+ */
268
+ font: string | undefined;
269
+ /**
270
+ * - The
271
+ * language's native forms under the map in the face.
272
+ */
273
+ native: ((word: string) => string | undefined) | undefined;
274
+ };
@@ -4,9 +4,14 @@
4
4
  * @param {string} source - Complete Markdown source, optionally with frontmatter.
5
5
  * @param {string} file - Diagnostic filename.
6
6
  * @param {import("./content-session.mjs").ContentSyntax} [syntax] - Exact-text scanner projections.
7
- * @returns {Array<{file: string, line: number, column: number, severity: string, message: string}>} Syntax errors.
7
+ * @param {import("./content-scripts.mjs").RunContext} [runs] - The package's
8
+ * languages, faces and maps. Given, text marked with `lang=`, `font=` and
9
+ * `map=` is checked against them; a caller with no package configuration
10
+ * leaves it out.
11
+ * @returns {Array<{file: string, line: number, column: number, severity: string, message: string}>} Syntax errors,
12
+ * then warnings.
8
13
  */
9
- export function markupFindings(source: string, file: string, syntax?: import("./content-session.mjs").ContentSyntax): Array<{
14
+ export function markupFindings(source: string, file: string, syntax?: import("./content-session.mjs").ContentSyntax, runs?: import("./content-scripts.mjs").RunContext): Array<{
10
15
  file: string;
11
16
  line: number;
12
17
  column: number;
@@ -423,7 +423,7 @@ export type DataFieldSpec = {
423
423
  * - The anchor kinds an
424
424
  * Address here may name with `#<anchor>`. Absent, an anchor is refused.
425
425
  */
426
- anchors?: readonly ("event" | "prose")[] | undefined;
426
+ anchors?: readonly ("prose" | "event")[] | undefined;
427
427
  /**
428
428
  * - The Address names exactly one event: an
429
429
  * anchor of kind `event`, or a note holding one event and no more.