@heroiclands/package-build 23.12.6 → 23.12.7

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 (83) hide show
  1. package/CHANGELOG.md +12 -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/links-and-markup.md +439 -47
  8. package/docs/commands.md +127 -0
  9. package/docs/configuration.md +66 -3
  10. package/docs/content-format.md +3 -1
  11. package/docs/guides/book.md +11 -0
  12. package/docs/guides/module-project.md +16 -0
  13. package/docs/guides/site.md +19 -0
  14. package/docs/reference/format-details.md +372 -6
  15. package/docs/reference/note-types.md +36 -11
  16. package/engine/base-compiler.mjs +2 -0
  17. package/engine/bundles.mjs +7 -2
  18. package/engine/compile-corpus.mjs +3 -1
  19. package/engine/content-charset.mjs +21 -2
  20. package/engine/content-format.yaml +1 -0
  21. package/engine/content-index.mjs +12 -0
  22. package/engine/content-poetry.mjs +22 -4
  23. package/engine/content-scripts.mjs +1219 -0
  24. package/engine/content-session.mjs +2 -0
  25. package/engine/data-keys.mjs +5 -1
  26. package/engine/dictionary-layout.mjs +18 -12
  27. package/engine/dictionary-rows.mjs +11 -2
  28. package/engine/helpers.mjs +8 -2
  29. package/engine/index-records.mjs +1 -0
  30. package/engine/journals.mjs +14 -3
  31. package/engine/language-data.mjs +137 -1
  32. package/engine/language-tag.mjs +103 -0
  33. package/engine/language-terms.mjs +16 -4
  34. package/engine/map-lexicon.mjs +762 -0
  35. package/engine/markup-validation.mjs +17 -3
  36. package/engine/names.mjs +1 -1
  37. package/engine/note-vocabulary.mjs +113 -0
  38. package/engine/pdf-build.mjs +28 -10
  39. package/engine/pdf-render.mjs +116 -11
  40. package/engine/run-rows.mjs +119 -0
  41. package/engine/run-words.mjs +266 -0
  42. package/engine/scenes.mjs +1 -0
  43. package/engine/script-font-delivery.mjs +321 -0
  44. package/engine/script-fonts.mjs +172 -0
  45. package/engine/site-build.mjs +10 -3
  46. package/engine/site-config.mjs +5 -0
  47. package/engine/site-root.mjs +19 -5
  48. package/engine/sql-tables.mjs +111 -1
  49. package/engine/text-maps.mjs +607 -0
  50. package/engine/verb-pattern.mjs +99 -0
  51. package/engine/word-pattern.mjs +27 -0
  52. package/engine/word-rows.mjs +8 -2
  53. package/engine/word-terms.mjs +44 -0
  54. package/hugo-theme/layouts/_default/baseof.html +3 -0
  55. package/hugo-theme/static/css/style.css +10 -0
  56. package/manifest.mjs +9 -1
  57. package/package.json +1 -1
  58. package/types/content-config.d.mts +26 -0
  59. package/types/engine/compile-corpus.d.mts +2 -1
  60. package/types/engine/content-index.d.mts +11 -3
  61. package/types/engine/content-poetry.d.mts +7 -0
  62. package/types/engine/content-scripts.d.mts +226 -0
  63. package/types/engine/data-keys.d.mts +2 -2
  64. package/types/engine/dictionary-rows.d.mts +15 -0
  65. package/types/engine/helpers.d.mts +5 -1
  66. package/types/engine/journals.d.mts +7 -2
  67. package/types/engine/language-data.d.mts +2 -0
  68. package/types/engine/language-tag.d.mts +8 -0
  69. package/types/engine/language-terms.d.mts +2 -1
  70. package/types/engine/map-lexicon.d.mts +274 -0
  71. package/types/engine/markup-validation.d.mts +7 -2
  72. package/types/engine/pdf-build.d.mts +26 -3
  73. package/types/engine/pdf-render.d.mts +17 -2
  74. package/types/engine/run-rows.d.mts +89 -0
  75. package/types/engine/run-words.d.mts +86 -0
  76. package/types/engine/script-font-delivery.d.mts +134 -0
  77. package/types/engine/script-fonts.d.mts +168 -0
  78. package/types/engine/site-build.d.mts +2 -1
  79. package/types/engine/site-root.d.mts +11 -3
  80. package/types/engine/text-maps.d.mts +175 -0
  81. package/types/engine/verb-pattern.d.mts +65 -0
  82. package/types/engine/word-pattern.d.mts +13 -0
  83. package/types/engine/word-terms.d.mts +6 -0
@@ -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;
@@ -184,17 +184,33 @@ export function buildPdf({ config, configPath, book, out, version, compile, read
184
184
  * @param {string} typPath - The `.typ` file.
185
185
  * @param {string} pdfPath - Where the PDF goes.
186
186
  * @param {object} [pdf] - The resolved `pdf:` block.
187
+ * @param {{rootDir?: string, paths?: {content?: string}}} [config] - The
188
+ * resolved configuration; the installed faces are searched when a note sets
189
+ * text in one.
187
190
  * @returns {string[]} The arguments, in order.
188
191
  */
189
- export function typstArgs(typPath: string, pdfPath: string, pdf?: object): string[];
192
+ export function typstArgs(typPath: string, pdfPath: string, pdf?: object, config?: {
193
+ rootDir?: string;
194
+ paths?: {
195
+ content?: string;
196
+ };
197
+ }): string[];
190
198
  /**
191
199
  * The flags that decide which faces a layout uses, shared by the compile and by
192
200
  * the page measurement so both lay the book out in the same metrics.
193
201
  *
194
202
  * @param {object} [pdf] - The resolved `pdf:` block.
203
+ * @param {{rootDir?: string, paths?: {content?: string}}} [config] - The
204
+ * resolved configuration; the installed faces are searched when a note sets
205
+ * text in one.
195
206
  * @returns {string[]} The arguments, in order.
196
207
  */
197
- export function typstFontArgs(pdf?: object): string[];
208
+ export function typstFontArgs(pdf?: object, config?: {
209
+ rootDir?: string;
210
+ paths?: {
211
+ content?: string;
212
+ };
213
+ }): string[];
198
214
  /**
199
215
  * The compiler's own warnings, as findings.
200
216
  *
@@ -224,10 +240,17 @@ export function typstWarnings(output: string): Array<{
224
240
  * @param {string} typPath - The `.typ` file.
225
241
  * @param {string} pdfPath - Where the PDF goes.
226
242
  * @param {object} pdf - The resolved `pdf:` block.
243
+ * @param {{rootDir?: string, paths?: {content?: string}}} [config] - The
244
+ * resolved configuration, for the installed faces.
227
245
  * @returns {{ok: boolean, message: string, findings: object[]}} What happened,
228
246
  * and what the compiler warned about on the way.
229
247
  */
230
- export function compileTypst(typPath: string, pdfPath: string, pdf?: object): {
248
+ export function compileTypst(typPath: string, pdfPath: string, pdf?: object, config?: {
249
+ rootDir?: string;
250
+ paths?: {
251
+ content?: string;
252
+ };
253
+ }): {
231
254
  ok: boolean;
232
255
  message: string;
233
256
  findings: object[];
@@ -85,6 +85,9 @@ export function stripHtmlComments(markdown: string): string;
85
85
  * Typst and is told nothing.
86
86
  * @param {string} [opts.file] - The file the markdown came from, named in every
87
87
  * finding.
88
+ * @param {import("./content-scripts.mjs").RunContext} [opts.runs] - The
89
+ * package's languages, faces and maps, which text marked with `lang=`,
90
+ * `font=` and `map=` is checked against and set by.
88
91
  * @param {number} [opts.bodyLine] - The 1-based file line the body starts on, so
89
92
  * a finding's line is the file's rather than the body's.
90
93
  * @param {number} [opts.bodyColumn] - The 1-based column the body starts at.
@@ -124,6 +127,7 @@ export function markdownToTypst(markdown: string, opts?: {
124
127
  anchorPrefix?: string | undefined;
125
128
  findings?: object[] | undefined;
126
129
  file?: string | undefined;
130
+ runs?: import("./content-scripts.mjs").RunContext | undefined;
127
131
  bodyLine?: number | undefined;
128
132
  bodyColumn?: number | undefined;
129
133
  lineMap?: {
@@ -228,9 +232,17 @@ export function crossBookReference(inner: string, away: {
228
232
  * carries are not the same set, and a missing glyph on 2,000 feet is a
229
233
  * tofu box on every page of the book.
230
234
  *
235
+ * @param {import("./content-scripts.mjs").RunContext} [runs] - The installed
236
+ * faces, each of whose classes sets its family.
237
+ * @param {{serif?: string, sans?: string, mono?: string}} [families] - The
238
+ * book's own serif, sans and mono, which `font=serif`, `sans` and `mono` set.
231
239
  * @returns {string} Typst markup.
232
240
  */
233
- export function bookTypstPreamble(): string;
241
+ export function bookTypstPreamble(runs?: import("./content-scripts.mjs").RunContext, families?: {
242
+ serif?: string;
243
+ sans?: string;
244
+ mono?: string;
245
+ }): string;
234
246
  /**
235
247
  * The whole book, as one Typst document.
236
248
  *
@@ -345,9 +357,11 @@ export function bookTypstPreamble(): string;
345
357
  * @param {object} [opts.index] - As {@link module:engine/pdf-index.indexTerms}:
346
358
  * `owns` limits the index to the notes this book is home to, and `foreign`
347
359
  * (present only under `pdf.indexSeeAlso`) lists notes another book prints.
360
+ * @param {import("./content-scripts.mjs").RunContext} [opts.runs] - The
361
+ * installed faces, which the preamble maps to font families.
348
362
  * @returns {string} A complete `.typ` document.
349
363
  */
350
- export function renderBook({ plan, bodies, title, subtitle, front, fonts, version, preamble, banners, maps, coverImage, authors, copyright, license, index, }?: {
364
+ export function renderBook({ plan, bodies, title, subtitle, front, fonts, version, preamble, banners, maps, coverImage, authors, copyright, license, index, runs, }?: {
351
365
  plan: object;
352
366
  bodies: Map<string, string>;
353
367
  title: string;
@@ -369,6 +383,7 @@ export function renderBook({ plan, bodies, title, subtitle, front, fonts, versio
369
383
  copyright?: string | undefined;
370
384
  license?: string | undefined;
371
385
  index?: object | undefined;
386
+ runs?: import("./content-scripts.mjs").RunContext | undefined;
372
387
  }): string;
373
388
  /**
374
389
  * Point every internal link at a label the document actually declares.
@@ -0,0 +1,89 @@
1
+ /**
2
+ * One run as an index record carries it.
3
+ *
4
+ * @typedef {object} RecordRun
5
+ * @property {"span"|"block"|"poetry"} kind - The construct.
6
+ * @property {string|null} lang - The language it is set in, as written: its
7
+ * own `lang=`, else the one the div or fence around it states.
8
+ * @property {string|null} tag - The BCP 47 tag it resolves to, or null.
9
+ * @property {string|null} font - Its font, as written and inherited the same way.
10
+ * @property {string|null} map - Its map, as written and inherited the same way.
11
+ * @property {number} line - 1-based file line of its opening.
12
+ * @property {number} column - 1-based UTF-16 file column of its opening.
13
+ */
14
+ /**
15
+ * @typedef {RecordRun & {owner: string|null}} RunRow
16
+ */
17
+ /**
18
+ * A note body's runs, at file positions, as an index record carries them.
19
+ *
20
+ * @param {string} body - The note's body.
21
+ * @param {object} options - Options.
22
+ * @param {import("./content-scripts.mjs").RunContext} [options.context] - The
23
+ * configured languages, which give a declared name its tag.
24
+ * @param {number} [options.bodyLine] - The 1-based file line the body starts on.
25
+ * @param {number} [options.bodyColumn] - The 1-based column of its first character.
26
+ * @param {import("./content-session.mjs").ContentSyntax} [options.syntax] -
27
+ * Session scanner projections.
28
+ * @returns {RecordRun[]} One entry per run, in source order.
29
+ */
30
+ export function recordRuns(body: string, { context, bodyLine, bodyColumn, syntax }?: {
31
+ context?: import("./content-scripts.mjs").RunContext | undefined;
32
+ bodyLine?: number | undefined;
33
+ bodyColumn?: number | undefined;
34
+ syntax?: import("./content-session.mjs").ContentSyntax | undefined;
35
+ }): RecordRun[];
36
+ /**
37
+ * The containing page's NOTE identity.
38
+ *
39
+ * @param {Record<string, any>} record - An own-note index record.
40
+ * @returns {string|null} The page Address, or null for an unaddressable record.
41
+ */
42
+ export function ownerOf(record: Record<string, any>): string | null;
43
+ /**
44
+ * Project recorded runs without reading sources or changing records.
45
+ *
46
+ * @param {Iterable<Record<string, any>>} records - Index records, already
47
+ * narrowed to the audience.
48
+ * @returns {RunRow[]} One row per run, in record then source order.
49
+ */
50
+ export function runsRows(records: Iterable<Record<string, any>>): RunRow[];
51
+ /** Every column of the `runs` relation, in order. */
52
+ export const RUN_COLUMNS: readonly string[];
53
+ /**
54
+ * One run as an index record carries it.
55
+ */
56
+ export type RecordRun = {
57
+ /**
58
+ * - The construct.
59
+ */
60
+ kind: "span" | "block" | "poetry";
61
+ /**
62
+ * - The language it is set in, as written: its
63
+ * own `lang=`, else the one the div or fence around it states.
64
+ */
65
+ lang: string | null;
66
+ /**
67
+ * - The BCP 47 tag it resolves to, or null.
68
+ */
69
+ tag: string | null;
70
+ /**
71
+ * - Its font, as written and inherited the same way.
72
+ */
73
+ font: string | null;
74
+ /**
75
+ * - Its map, as written and inherited the same way.
76
+ */
77
+ map: string | null;
78
+ /**
79
+ * - 1-based file line of its opening.
80
+ */
81
+ line: number;
82
+ /**
83
+ * - 1-based UTF-16 file column of its opening.
84
+ */
85
+ column: number;
86
+ };
87
+ export type RunRow = RecordRun & {
88
+ owner: string | null;
89
+ };