@heroiclands/package-build 25.0.0 → 25.1.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.
- package/CHANGELOG.md +14 -0
- package/README.md +1 -0
- package/bin/content-commands.mjs +30 -96
- package/bin/encoding-commands.mjs +146 -0
- package/bin/package-build.mjs +35 -24
- package/config.mjs +25 -0
- package/convert.mjs +182 -0
- package/docs/api.md +137 -6
- package/docs/authoring/links-and-markup.md +260 -481
- package/docs/commands.md +110 -119
- package/docs/configuration.md +31 -13
- package/docs/content-format.md +11 -4
- package/docs/diagnostics.md +43 -16
- package/docs/encoding-core.md +135 -0
- package/docs/guides/book.md +2 -2
- package/docs/guides/module-project.md +23 -1
- package/docs/guides/site.md +2 -2
- package/docs/guides/writing-in-invented-scripts.md +450 -574
- package/docs/reference/format-details.md +289 -404
- package/docs/reference/note-types.md +80 -63
- package/docs/source-preview.md +8 -0
- package/e2e.mjs +1 -1
- package/engine/base-compiler.mjs +27 -9
- package/engine/content-charset.mjs +13 -1
- package/engine/content-format.yaml +6 -2
- package/engine/content-index.mjs +6 -2
- package/engine/content-links.mjs +1 -0
- package/engine/content-scripts.mjs +614 -459
- package/engine/content-scroll.mjs +4 -4
- package/engine/content-spans.mjs +40 -9
- package/engine/content-verse.mjs +1 -1
- package/engine/converter-data.mjs +70 -0
- package/engine/dictionary-rows.mjs +2 -34
- package/engine/encoding-integrity.mjs +94 -0
- package/engine/encoding-language.mjs +506 -0
- package/engine/encoding-lexicon.mjs +699 -0
- package/engine/encoding-notes.mjs +186 -0
- package/engine/encoding-standard.mjs +42 -0
- package/engine/encoding-template.mjs +313 -0
- package/engine/encoding-terms.mjs +141 -0
- package/engine/encoding.mjs +946 -0
- package/engine/extension-attributes.mjs +2 -0
- package/engine/helpers.mjs +1 -1
- package/engine/index.mjs +7 -0
- package/engine/language-terms.mjs +17 -16
- package/engine/{logographic.mjs → language-writings.mjs} +29 -38
- package/engine/markup-validation.mjs +1 -1
- package/engine/note-vocabulary.mjs +4 -158
- package/engine/pdf-render.mjs +31 -3
- package/engine/roman-characters.mjs +135 -16
- package/engine/roman-run.mjs +149 -0
- package/engine/roman-verse.mjs +95 -0
- package/engine/run-rows.mjs +29 -31
- package/engine/run-words.mjs +2 -2
- package/engine/script-emphasis-terms.mjs +3 -0
- package/engine/script-emphasis.mjs +3 -10
- package/engine/script-font-delivery.mjs +9 -12
- package/engine/script-fonts.mjs +2 -1
- package/engine/site-build.mjs +14 -5
- package/engine/site-preview.mjs +12 -2
- package/engine/sql-tables.mjs +36 -31
- package/engine/verse-metre.mjs +1 -1
- package/engine/word-forms.mjs +1 -1
- package/engine/word-inflections.mjs +48 -0
- package/engine/word-rows.mjs +1 -1
- package/engine/word-terms.mjs +16 -17
- package/package.json +11 -5
- package/types/config.d.mts +5 -0
- package/types/convert.d.mts +44 -0
- package/types/e2e.d.mts +1 -1
- package/types/engine/base-compiler.d.mts +4 -2
- package/types/engine/content-index.d.mts +4 -1
- package/types/engine/content-scripts.d.mts +103 -42
- package/types/engine/converter-data.d.mts +11 -0
- package/types/engine/dictionary-rows.d.mts +1 -25
- package/types/engine/encoding-integrity.d.mts +14 -0
- package/types/engine/encoding-language.d.mts +36 -0
- package/types/engine/encoding-lexicon.d.mts +259 -0
- package/types/engine/encoding-notes.d.mts +39 -0
- package/types/engine/encoding-standard.d.mts +11 -0
- package/types/engine/encoding-template.d.mts +43 -0
- package/types/engine/encoding-terms.d.mts +105 -0
- package/types/engine/encoding.d.mts +155 -0
- package/types/engine/helpers.d.mts +1 -1
- package/types/engine/index.d.mts +4 -0
- package/types/engine/language-terms.d.mts +1 -1
- package/types/engine/{logographic.d.mts → language-writings.d.mts} +6 -6
- package/types/engine/markup-validation.d.mts +1 -1
- package/types/engine/pdf-render.d.mts +1 -1
- package/types/engine/roman-characters.d.mts +2 -2
- package/types/engine/roman-run.d.mts +101 -0
- package/types/engine/roman-verse.d.mts +23 -0
- package/types/engine/run-rows.d.mts +13 -20
- package/types/engine/script-emphasis-terms.d.mts +2 -0
- package/types/engine/script-emphasis.d.mts +1 -1
- package/types/engine/script-font-delivery.d.mts +2 -3
- package/types/engine/script-fonts.d.mts +5 -0
- package/types/engine/site-preview.d.mts +1 -1
- package/types/engine/word-inflections.d.mts +25 -0
- package/engine/map-lexicon.mjs +0 -1045
- package/engine/text-maps.mjs +0 -654
- package/engine/written-in.mjs +0 -204
- package/types/engine/map-lexicon.d.mts +0 -330
- package/types/engine/text-maps.d.mts +0 -189
- package/types/engine/written-in.d.mts +0 -76
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Validate note data and resolve its code references without reading files.
|
|
3
|
+
* @param {any} data - Encoding-note data, excluding ordinary document metadata.
|
|
4
|
+
* @param {{codes?: Record<string,string>, name?: string}} options - Selected font codes and document identity.
|
|
5
|
+
* @param {(key:string,message:string)=>never} fault - Schema-error constructor supplied by the engine.
|
|
6
|
+
*/
|
|
7
|
+
export function templateProgram(data: any, options: {
|
|
8
|
+
codes?: Record<string, string>;
|
|
9
|
+
name?: string;
|
|
10
|
+
}, fault: (key: string, message: string) => never): {
|
|
11
|
+
definition: {
|
|
12
|
+
groupCase?: string | undefined;
|
|
13
|
+
name: string;
|
|
14
|
+
fonts: any[];
|
|
15
|
+
accepts: any[];
|
|
16
|
+
separator: string;
|
|
17
|
+
vowels: any;
|
|
18
|
+
rows: Readonly<unknown>[];
|
|
19
|
+
codes: [string, string][];
|
|
20
|
+
controls: Readonly<{
|
|
21
|
+
verseStanza: "󠄍";
|
|
22
|
+
verseCanto: "󠄎";
|
|
23
|
+
wordSeparator: " ";
|
|
24
|
+
literalOpen: "󠄒";
|
|
25
|
+
literalClose: "󠄓";
|
|
26
|
+
literalEscape: "󠄕";
|
|
27
|
+
}>;
|
|
28
|
+
};
|
|
29
|
+
rowKeys: string[];
|
|
30
|
+
metadata: {
|
|
31
|
+
name: string;
|
|
32
|
+
language: any;
|
|
33
|
+
font: any;
|
|
34
|
+
template: Readonly<{
|
|
35
|
+
normalization: "NFC";
|
|
36
|
+
vowelGroups: any;
|
|
37
|
+
maxVowelGroup: number;
|
|
38
|
+
stress: "󠄔" | undefined;
|
|
39
|
+
diaeresis: boolean;
|
|
40
|
+
grave: boolean;
|
|
41
|
+
}>;
|
|
42
|
+
};
|
|
43
|
+
};
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
/** Closed nested keys, also documented by the generated note reference. */
|
|
2
|
+
export const ENCODING_RULE_FIELDS: readonly ({
|
|
3
|
+
allowed?: string[] | undefined;
|
|
4
|
+
kind: string;
|
|
5
|
+
shape: string;
|
|
6
|
+
name: any;
|
|
7
|
+
describe: any;
|
|
8
|
+
required: boolean;
|
|
9
|
+
} | {
|
|
10
|
+
name: any;
|
|
11
|
+
kind: string;
|
|
12
|
+
shape: string;
|
|
13
|
+
describe: any;
|
|
14
|
+
fields: any;
|
|
15
|
+
} | {
|
|
16
|
+
name: string;
|
|
17
|
+
kind: string;
|
|
18
|
+
shape: string;
|
|
19
|
+
describe: string;
|
|
20
|
+
entries: {
|
|
21
|
+
kind: string;
|
|
22
|
+
shape: string;
|
|
23
|
+
fields: {
|
|
24
|
+
name: any;
|
|
25
|
+
kind: string;
|
|
26
|
+
shape: string;
|
|
27
|
+
describe: any;
|
|
28
|
+
required: boolean;
|
|
29
|
+
}[];
|
|
30
|
+
};
|
|
31
|
+
})[];
|
|
32
|
+
/** The additional data keys a document may use to define its encoding. */
|
|
33
|
+
export const ENCODING_NOTE_FIELDS: readonly ({
|
|
34
|
+
name: any;
|
|
35
|
+
kind: string;
|
|
36
|
+
shape: string;
|
|
37
|
+
describe: any;
|
|
38
|
+
required: boolean;
|
|
39
|
+
} | {
|
|
40
|
+
name: string;
|
|
41
|
+
kind: string;
|
|
42
|
+
shape: string;
|
|
43
|
+
entries: {
|
|
44
|
+
kind: string;
|
|
45
|
+
shape: string;
|
|
46
|
+
describe: string;
|
|
47
|
+
};
|
|
48
|
+
describe: string;
|
|
49
|
+
values?: undefined;
|
|
50
|
+
fields?: undefined;
|
|
51
|
+
} | {
|
|
52
|
+
name: string;
|
|
53
|
+
kind: string;
|
|
54
|
+
shape: string;
|
|
55
|
+
values: {
|
|
56
|
+
describe: string;
|
|
57
|
+
kind: string;
|
|
58
|
+
shape: string;
|
|
59
|
+
entries: {
|
|
60
|
+
kind: string;
|
|
61
|
+
shape: string;
|
|
62
|
+
describe: string;
|
|
63
|
+
};
|
|
64
|
+
};
|
|
65
|
+
describe: string;
|
|
66
|
+
entries?: undefined;
|
|
67
|
+
fields?: undefined;
|
|
68
|
+
} | {
|
|
69
|
+
name: string;
|
|
70
|
+
kind: string;
|
|
71
|
+
shape: string;
|
|
72
|
+
fields: readonly ({
|
|
73
|
+
allowed?: string[] | undefined;
|
|
74
|
+
kind: string;
|
|
75
|
+
shape: string;
|
|
76
|
+
name: any;
|
|
77
|
+
describe: any;
|
|
78
|
+
required: boolean;
|
|
79
|
+
} | {
|
|
80
|
+
name: any;
|
|
81
|
+
kind: string;
|
|
82
|
+
shape: string;
|
|
83
|
+
describe: any;
|
|
84
|
+
fields: any;
|
|
85
|
+
} | {
|
|
86
|
+
name: string;
|
|
87
|
+
kind: string;
|
|
88
|
+
shape: string;
|
|
89
|
+
describe: string;
|
|
90
|
+
entries: {
|
|
91
|
+
kind: string;
|
|
92
|
+
shape: string;
|
|
93
|
+
fields: {
|
|
94
|
+
name: any;
|
|
95
|
+
kind: string;
|
|
96
|
+
shape: string;
|
|
97
|
+
describe: any;
|
|
98
|
+
required: boolean;
|
|
99
|
+
}[];
|
|
100
|
+
};
|
|
101
|
+
})[];
|
|
102
|
+
describe: string;
|
|
103
|
+
entries?: undefined;
|
|
104
|
+
values?: undefined;
|
|
105
|
+
})[];
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Validate and compile an encoding note with a separately resolved font code table.
|
|
3
|
+
* @param {any} data Encoding-note data with mappings and executable rules.
|
|
4
|
+
* @param {{codes?: Record<string,string>, name?: string}} [options] Font glyph codes and canonical note identity.
|
|
5
|
+
*/
|
|
6
|
+
export function compileEncoding(data: any, options?: {
|
|
7
|
+
codes?: Record<string, string>;
|
|
8
|
+
name?: string;
|
|
9
|
+
}): Readonly<{
|
|
10
|
+
name: any;
|
|
11
|
+
language?: any;
|
|
12
|
+
font?: any;
|
|
13
|
+
template?: Readonly<{
|
|
14
|
+
normalization: "NFC";
|
|
15
|
+
vowelGroups: any;
|
|
16
|
+
maxVowelGroup: number;
|
|
17
|
+
stress: "󠄔" | undefined;
|
|
18
|
+
diaeresis: boolean;
|
|
19
|
+
grave: boolean;
|
|
20
|
+
}> | undefined;
|
|
21
|
+
fonts: readonly any[];
|
|
22
|
+
separator: any;
|
|
23
|
+
separatorRow: {
|
|
24
|
+
from: string;
|
|
25
|
+
to: any;
|
|
26
|
+
key: string;
|
|
27
|
+
};
|
|
28
|
+
vowels: Set<any>;
|
|
29
|
+
accepted: Set<any>;
|
|
30
|
+
controls: any;
|
|
31
|
+
groupCase: any;
|
|
32
|
+
roundTrip: any;
|
|
33
|
+
shared: {
|
|
34
|
+
rows: any;
|
|
35
|
+
index: Map<any, any>;
|
|
36
|
+
readings: Map<any, any>;
|
|
37
|
+
};
|
|
38
|
+
faces: Map<any, any>;
|
|
39
|
+
codes: {
|
|
40
|
+
rows: any;
|
|
41
|
+
index: Map<any, any>;
|
|
42
|
+
readings: Map<any, any>;
|
|
43
|
+
};
|
|
44
|
+
}>;
|
|
45
|
+
/**
|
|
46
|
+
* Compile the internal row program, including isolated execution conformance fixtures.
|
|
47
|
+
* Application inputs go through compileEncoding's closed note schema.
|
|
48
|
+
* @internal
|
|
49
|
+
* @param {any} definition Fully resolved internal rows.
|
|
50
|
+
* @param {Partial<ReturnType<typeof templateProgram>["metadata"]>} [metadata] Validated note metadata, supplied by the template compiler.
|
|
51
|
+
*/
|
|
52
|
+
export function compileRows(definition: any, metadata?: Partial<ReturnType<typeof templateProgram>["metadata"]>): Readonly<{
|
|
53
|
+
name: any;
|
|
54
|
+
language?: any;
|
|
55
|
+
font?: any;
|
|
56
|
+
template?: Readonly<{
|
|
57
|
+
normalization: "NFC";
|
|
58
|
+
vowelGroups: any;
|
|
59
|
+
maxVowelGroup: number;
|
|
60
|
+
stress: "󠄔" | undefined;
|
|
61
|
+
diaeresis: boolean;
|
|
62
|
+
grave: boolean;
|
|
63
|
+
}> | undefined;
|
|
64
|
+
fonts: readonly any[];
|
|
65
|
+
separator: any;
|
|
66
|
+
separatorRow: {
|
|
67
|
+
from: string;
|
|
68
|
+
to: any;
|
|
69
|
+
key: string;
|
|
70
|
+
};
|
|
71
|
+
vowels: Set<any>;
|
|
72
|
+
accepted: Set<any>;
|
|
73
|
+
controls: any;
|
|
74
|
+
groupCase: any;
|
|
75
|
+
roundTrip: any;
|
|
76
|
+
shared: {
|
|
77
|
+
rows: any;
|
|
78
|
+
index: Map<any, any>;
|
|
79
|
+
readings: Map<any, any>;
|
|
80
|
+
};
|
|
81
|
+
faces: Map<any, any>;
|
|
82
|
+
codes: {
|
|
83
|
+
rows: any;
|
|
84
|
+
index: Map<any, any>;
|
|
85
|
+
readings: Map<any, any>;
|
|
86
|
+
};
|
|
87
|
+
}>;
|
|
88
|
+
/**
|
|
89
|
+
* Validate Roman spelling and literal syntax without requiring ordinary mapping coverage.
|
|
90
|
+
* Accepted words may instead have authoritative native writings in the language note.
|
|
91
|
+
* @param {ReturnType<typeof compileEncoding>} enc - Compiled encoding and its font codes.
|
|
92
|
+
* @param {string} text - Authored Roman source, normalized to NFC for template rules.
|
|
93
|
+
* @param {{font?:string,start?:number,end?:number}} [options] - Face and authored UTF-16 bounds.
|
|
94
|
+
* @returns {void} Throws EncodingError at the authored UTF-16 offset and code-point column.
|
|
95
|
+
*/
|
|
96
|
+
export function validateSource(enc: ReturnType<typeof compileEncoding>, text: string, options?: {
|
|
97
|
+
font?: string;
|
|
98
|
+
start?: number;
|
|
99
|
+
end?: number;
|
|
100
|
+
}): void;
|
|
101
|
+
/**
|
|
102
|
+
* Encode matched pieces while preserving offsets into the original source.
|
|
103
|
+
* @param {ReturnType<typeof compileEncoding>} enc - Compiled encoding note.
|
|
104
|
+
* @param {string} text - Authored Roman source.
|
|
105
|
+
* @param {{font?: string, verse?: boolean, start?: number, end?: number}} [options] - Source bounds and presentation.
|
|
106
|
+
*/
|
|
107
|
+
export function encodePieces(enc: ReturnType<typeof compileEncoding>, text: string, options?: {
|
|
108
|
+
font?: string;
|
|
109
|
+
verse?: boolean;
|
|
110
|
+
start?: number;
|
|
111
|
+
end?: number;
|
|
112
|
+
}): {
|
|
113
|
+
from: any;
|
|
114
|
+
to: any;
|
|
115
|
+
start: any;
|
|
116
|
+
end: any;
|
|
117
|
+
row: any;
|
|
118
|
+
}[];
|
|
119
|
+
/**
|
|
120
|
+
* Encode text using exactly the rows of its compiled encoding. Unknown input is refused.
|
|
121
|
+
* @param {ReturnType<typeof compileEncoding>} enc
|
|
122
|
+
* @param {string} text
|
|
123
|
+
* @param {{font?: string, verse?: boolean}} [options]
|
|
124
|
+
* @returns {string}
|
|
125
|
+
*/
|
|
126
|
+
export function encodeText(enc: ReturnType<typeof compileEncoding>, text: string, options?: {
|
|
127
|
+
font?: string;
|
|
128
|
+
verse?: boolean;
|
|
129
|
+
}): string;
|
|
130
|
+
/**
|
|
131
|
+
* Decode a note's uniquely decodable output, including nonprefix glyph sequences.
|
|
132
|
+
* @param {ReturnType<typeof compileEncoding>} enc - Compiled encoding note.
|
|
133
|
+
* @param {string} text - Native text with optional literal spans.
|
|
134
|
+
* @param {{font?: string}} [options] - Selected encoding face.
|
|
135
|
+
* @returns {string} Roman source, with literals kept between their visible markers.
|
|
136
|
+
*/
|
|
137
|
+
export function decodeText(enc: ReturnType<typeof compileEncoding>, text: string, options?: {
|
|
138
|
+
font?: string;
|
|
139
|
+
}): string;
|
|
140
|
+
/**
|
|
141
|
+
* A schema fault or text refusal. Text offsets are UTF-16; columns count code points.
|
|
142
|
+
*/
|
|
143
|
+
export class EncodingError extends Error {
|
|
144
|
+
/** @param {string} message @param {{text?: string, offset?: number, key?: string}} [details] */
|
|
145
|
+
constructor(message: string, { text, offset, key }?: {
|
|
146
|
+
text?: string;
|
|
147
|
+
offset?: number;
|
|
148
|
+
key?: string;
|
|
149
|
+
});
|
|
150
|
+
key: string | undefined;
|
|
151
|
+
offset: number | undefined;
|
|
152
|
+
line: number | undefined;
|
|
153
|
+
column: number | undefined;
|
|
154
|
+
}
|
|
155
|
+
import { templateProgram } from "./encoding-template.mjs";
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
* {@link module:engine/content-figures.scanFigures}.
|
|
13
13
|
* @param {import("./content-scripts.mjs").RunContext} [runs] - The package's
|
|
14
14
|
* languages, faces and maps. Given, text marked with `lang=`, `font=` and
|
|
15
|
-
* `
|
|
15
|
+
* `enc=` is rewritten first, so it is tagged for its language, mapped and
|
|
16
16
|
* set in its font.
|
|
17
17
|
* @returns {string} The rendered HTML.
|
|
18
18
|
*/
|
package/types/engine/index.d.mts
CHANGED
|
@@ -97,4 +97,8 @@ export * as sceneLevels from "./scene-levels.mjs";
|
|
|
97
97
|
export * as generate from "./generate.mjs";
|
|
98
98
|
export * as compendiums from "./compendiums.mjs";
|
|
99
99
|
export * as regionEvents from "./region-events.mjs";
|
|
100
|
+
export * as encoding from "./encoding.mjs";
|
|
101
|
+
export * as encodingLanguage from "./encoding-language.mjs";
|
|
102
|
+
export * as encodingNotes from "./encoding-notes.mjs";
|
|
103
|
+
export * as encodingLexicon from "./encoding-lexicon.mjs";
|
|
100
104
|
export { CURATED_REGION_EVENTS, EXCLUDED_REGION_EVENTS, REGION_EVENT_TO_TRIGGER } from "./region-events.mjs";
|
|
@@ -352,7 +352,7 @@ export const NAMING_FIELDS: readonly import("./data-keys.mjs").InnerKeySpec[];
|
|
|
352
352
|
*/
|
|
353
353
|
export const VERB_PERSON_FIELDS: readonly import("./data-keys.mjs").InnerKeySpec[];
|
|
354
354
|
/**
|
|
355
|
-
* The endings `data.grammar.native` writes under a
|
|
355
|
+
* The endings `data.grammar.native` writes under a encoding: the noun
|
|
356
356
|
* plural, then the six persons of the verb pattern.
|
|
357
357
|
*/
|
|
358
358
|
export const WRITTEN_ENDINGS: readonly string[];
|
|
@@ -6,25 +6,25 @@
|
|
|
6
6
|
* | {ambiguous: {form: string, glosses: string[]}}} Writing
|
|
7
7
|
*/
|
|
8
8
|
/**
|
|
9
|
-
* The text a list of native entries states for a
|
|
9
|
+
* The text a list of native entries states for a enc in a face: the entry for
|
|
10
10
|
* the face, else the entry for no face.
|
|
11
11
|
*
|
|
12
12
|
* @param {unknown} natives - A `native` list as authored.
|
|
13
|
-
* @param {string}
|
|
13
|
+
* @param {string} enc - The encoding's name.
|
|
14
14
|
* @param {string|undefined} font - The face.
|
|
15
15
|
* @returns {string|undefined} The text.
|
|
16
16
|
*/
|
|
17
|
-
export function nativeText(natives: unknown,
|
|
17
|
+
export function nativeText(natives: unknown, enc: string, font: string | undefined): string | undefined;
|
|
18
18
|
/**
|
|
19
|
-
* The writings of a language's words under one
|
|
19
|
+
* The writings of a language's words under one encoding in one face.
|
|
20
20
|
*
|
|
21
21
|
* @param {Record<string, any>|undefined} data - The language note's `data`.
|
|
22
|
-
* @param {string}
|
|
22
|
+
* @param {string} enc - The encoding's name.
|
|
23
23
|
* @param {string|undefined} font - The face.
|
|
24
24
|
* @returns {{word: (word: string) => Writing, entry: (index: number) => Writing}}
|
|
25
25
|
* The writing of a run's word, and of the `data.words` entry at an index.
|
|
26
26
|
*/
|
|
27
|
-
export function writingsOf(data: Record<string, any> | undefined,
|
|
27
|
+
export function writingsOf(data: Record<string, any> | undefined, enc: string, font: string | undefined): {
|
|
28
28
|
word: (word: string) => Writing;
|
|
29
29
|
entry: (index: number) => Writing;
|
|
30
30
|
};
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* @param {import("./content-session.mjs").ContentSyntax} [syntax] - Exact-text scanner projections.
|
|
7
7
|
* @param {import("./content-scripts.mjs").RunContext} [runs] - The package's
|
|
8
8
|
* languages, faces and maps. Given, text marked with `lang=`, `font=` and
|
|
9
|
-
* `
|
|
9
|
+
* `enc=` is checked against them; a caller with no package configuration
|
|
10
10
|
* leaves it out.
|
|
11
11
|
* @returns {Array<{file: string, line: number, column: number, severity: string, message: string}>} Syntax errors,
|
|
12
12
|
* then warnings.
|
|
@@ -91,7 +91,7 @@ export function stripHtmlComments(markdown: string): string;
|
|
|
91
91
|
* finding.
|
|
92
92
|
* @param {import("./content-scripts.mjs").RunContext} [opts.runs] - The
|
|
93
93
|
* package's languages, faces and maps, which text marked with `lang=`,
|
|
94
|
-
* `font=` and `
|
|
94
|
+
* `font=` and `enc=` is checked against and set by.
|
|
95
95
|
* @param {number} [opts.bodyLine] - The 1-based file line the body starts on, so
|
|
96
96
|
* a finding's line is the file's rather than the body's.
|
|
97
97
|
* @param {number} [opts.bodyColumn] - The 1-based column the body starts at.
|
|
@@ -26,13 +26,13 @@ export function romanInventoriesOf(records: ReadonlyMap<string, Record<string, a
|
|
|
26
26
|
* No punctuation, case or normalization repair is performed.
|
|
27
27
|
* @param {string} text - Visible Roman source.
|
|
28
28
|
* @param {RomanInventory} inventory - Its language's declared characters.
|
|
29
|
-
* @param {(char: string) => boolean} [native] - Whether a directly typed native sign is drawn in the selected native face.
|
|
30
29
|
* @returns {Array<{offset: number, message: string}>}
|
|
31
30
|
*/
|
|
32
|
-
export function romanTextProblems(text: string, inventory: RomanInventory
|
|
31
|
+
export function romanTextProblems(text: string, inventory: RomanInventory): Array<{
|
|
33
32
|
offset: number;
|
|
34
33
|
message: string;
|
|
35
34
|
}>;
|
|
35
|
+
export function isRomanWhitespace(char: any): boolean;
|
|
36
36
|
export type RomanInventory = {
|
|
37
37
|
/**
|
|
38
38
|
* - The configured language name.
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Project an authored run to logical Roman text while retaining source offsets.
|
|
3
|
+
* Presentation-only children contribute their text; names contribute standard
|
|
4
|
+
* braces. The caller decides which children are independent runs and which
|
|
5
|
+
* ranges are layout or emphasis delimiters.
|
|
6
|
+
* @module
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* @typedef {object} RomanSpan
|
|
10
|
+
* @property {number} start - Opening bracket offset.
|
|
11
|
+
* @property {number} end - Offset past the attribute block.
|
|
12
|
+
* @property {number} contentEnd - Closing bracket offset.
|
|
13
|
+
* @property {Array<[string, string]>} [attrs] - Authored attributes.
|
|
14
|
+
*/
|
|
15
|
+
/**
|
|
16
|
+
* @typedef {object} ProjectedSpan
|
|
17
|
+
* @property {RomanSpan} source - The authored child.
|
|
18
|
+
* @property {number} from - Its first logical UTF-16 offset, including name braces.
|
|
19
|
+
* @property {number} to - Offset past its logical text and braces.
|
|
20
|
+
* @property {number} contentFrom - Logical text after its opening name brace.
|
|
21
|
+
* @property {number} contentTo - Offset past the logical text, before its closing name brace.
|
|
22
|
+
* @property {boolean} name - Whether this child marks a name.
|
|
23
|
+
* @property {boolean} included - Whether this child contributes its own text.
|
|
24
|
+
*/
|
|
25
|
+
/**
|
|
26
|
+
* Remove Markdown escapes, inline presentation syntax and excluded layout.
|
|
27
|
+
* The returned offsets refer to the original source, in UTF-16 units, matching
|
|
28
|
+
* the source scanner. A supplementary character has two entries, both pointing
|
|
29
|
+
* at its original first unit. Synthetic braces point at the name's brackets.
|
|
30
|
+
* @param {string} source - Complete authored source.
|
|
31
|
+
* @param {object} [options] - Bounds and projections chosen by the run scanner.
|
|
32
|
+
* @param {number} [options.from] - First included source offset.
|
|
33
|
+
* @param {number} [options.to] - Offset past the included source.
|
|
34
|
+
* @param {readonly RomanSpan[]} [options.spans] - Scanned spans, with absolute offsets.
|
|
35
|
+
* @param {(span: RomanSpan) => boolean} [options.includeSpan] - Whether a child inherits this run.
|
|
36
|
+
* @param {(span: RomanSpan) => string} [options.opaqueSpan] - Placeholder for an independent child. The default empty name keeps sentence state without introducing that child's letters.
|
|
37
|
+
* @param {ReadonlyArray<readonly [number, number]>} [options.exclude] - Absolute source ranges that carry layout or presentation syntax.
|
|
38
|
+
* @param {boolean} [options.markNames] - Whether name children contribute braces.
|
|
39
|
+
* @returns {{text: string, offsets: number[], spans: ProjectedSpan[]}} Logical text and source locations, with child ranges for presentation.
|
|
40
|
+
*/
|
|
41
|
+
export function plainRomanRun(source: string, { from, to, spans, includeSpan, opaqueSpan, exclude, markNames, }?: {
|
|
42
|
+
from?: number | undefined;
|
|
43
|
+
to?: number | undefined;
|
|
44
|
+
spans?: readonly RomanSpan[] | undefined;
|
|
45
|
+
includeSpan?: ((span: RomanSpan) => boolean) | undefined;
|
|
46
|
+
opaqueSpan?: ((span: RomanSpan) => string) | undefined;
|
|
47
|
+
exclude?: readonly (readonly [number, number])[] | undefined;
|
|
48
|
+
markNames?: boolean | undefined;
|
|
49
|
+
}): {
|
|
50
|
+
text: string;
|
|
51
|
+
offsets: number[];
|
|
52
|
+
spans: ProjectedSpan[];
|
|
53
|
+
};
|
|
54
|
+
export type RomanSpan = {
|
|
55
|
+
/**
|
|
56
|
+
* - Opening bracket offset.
|
|
57
|
+
*/
|
|
58
|
+
start: number;
|
|
59
|
+
/**
|
|
60
|
+
* - Offset past the attribute block.
|
|
61
|
+
*/
|
|
62
|
+
end: number;
|
|
63
|
+
/**
|
|
64
|
+
* - Closing bracket offset.
|
|
65
|
+
*/
|
|
66
|
+
contentEnd: number;
|
|
67
|
+
/**
|
|
68
|
+
* - Authored attributes.
|
|
69
|
+
*/
|
|
70
|
+
attrs?: [string, string][] | undefined;
|
|
71
|
+
};
|
|
72
|
+
export type ProjectedSpan = {
|
|
73
|
+
/**
|
|
74
|
+
* - The authored child.
|
|
75
|
+
*/
|
|
76
|
+
source: RomanSpan;
|
|
77
|
+
/**
|
|
78
|
+
* - Its first logical UTF-16 offset, including name braces.
|
|
79
|
+
*/
|
|
80
|
+
from: number;
|
|
81
|
+
/**
|
|
82
|
+
* - Offset past its logical text and braces.
|
|
83
|
+
*/
|
|
84
|
+
to: number;
|
|
85
|
+
/**
|
|
86
|
+
* - Logical text after its opening name brace.
|
|
87
|
+
*/
|
|
88
|
+
contentFrom: number;
|
|
89
|
+
/**
|
|
90
|
+
* - Offset past the logical text, before its closing name brace.
|
|
91
|
+
*/
|
|
92
|
+
contentTo: number;
|
|
93
|
+
/**
|
|
94
|
+
* - Whether this child marks a name.
|
|
95
|
+
*/
|
|
96
|
+
name: boolean;
|
|
97
|
+
/**
|
|
98
|
+
* - Whether this child contributes its own text.
|
|
99
|
+
*/
|
|
100
|
+
included: boolean;
|
|
101
|
+
};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Remove visual indentation before checking or encoding Roman verse. Each
|
|
3
|
+
* content line keeps its own boundary, including the last line before a stanza
|
|
4
|
+
* or canto; those extra structural controls do not consume its line boundary.
|
|
5
|
+
* The caller writes the boundaries through its selected encoding.
|
|
6
|
+
* @param {string} source - Complete authored source.
|
|
7
|
+
* @param {Parameters<typeof plainRomanRun>[1] & {isCantoLine?: (line: string) => boolean}} [options] - Run bounds, spans and layout projection.
|
|
8
|
+
* @returns {ReturnType<typeof plainRomanRun> & {boundaries: Array<{kind: "line"|"stanza"|"canto", at: number, sourceOffset: number}>, errors: Array<{offset: number, message: string}>}} Visible text, positions and structural events.
|
|
9
|
+
*/
|
|
10
|
+
export function plainRomanVerse(source: string, options?: Parameters<typeof plainRomanRun>[1] & {
|
|
11
|
+
isCantoLine?: (line: string) => boolean;
|
|
12
|
+
}): ReturnType<typeof plainRomanRun> & {
|
|
13
|
+
boundaries: Array<{
|
|
14
|
+
kind: "line" | "stanza" | "canto";
|
|
15
|
+
at: number;
|
|
16
|
+
sourceOffset: number;
|
|
17
|
+
}>;
|
|
18
|
+
errors: Array<{
|
|
19
|
+
offset: number;
|
|
20
|
+
message: string;
|
|
21
|
+
}>;
|
|
22
|
+
};
|
|
23
|
+
import { plainRomanRun } from "./roman-run.mjs";
|
|
@@ -7,11 +7,8 @@
|
|
|
7
7
|
* own `lang=`, else the one the div or fence around it states.
|
|
8
8
|
* @property {string|null} tag - The BCP 47 tag it resolves to, or null.
|
|
9
9
|
* @property {string|null} font - Its explicit font, an inherited ordinary
|
|
10
|
-
* prose family, or the
|
|
11
|
-
* @property {string|null}
|
|
12
|
-
* opted-in native run; null for Roman language-only text.
|
|
13
|
-
* @property {boolean} [nativefont] - Explicit native opt-in on this construct;
|
|
14
|
-
* absent on Roman runs. This internal flag is not a SQL column.
|
|
10
|
+
* prose family, or the font of the selected encoding document.
|
|
11
|
+
* @property {string|null} enc - Its resolved encoding document, or default for Roman text.
|
|
15
12
|
* @property {number} line - 1-based file line of its opening.
|
|
16
13
|
* @property {number} column - 1-based UTF-16 file column of its opening.
|
|
17
14
|
*/
|
|
@@ -38,22 +35,24 @@ export function recordRuns(body: string, { context, bodyLine, bodyColumn, syntax
|
|
|
38
35
|
syntax?: import("./content-session.mjs").ContentSyntax | undefined;
|
|
39
36
|
}): RecordRun[];
|
|
40
37
|
/**
|
|
41
|
-
*
|
|
42
|
-
*
|
|
43
|
-
* once every record exists, since a run's language note may be recorded after
|
|
44
|
-
* the note that marks it.
|
|
38
|
+
* Resolve recorded encoding Addresses and fill the language and font supplied
|
|
39
|
+
* by each selected document, once every index record exists.
|
|
45
40
|
*
|
|
46
41
|
* @param {Record<string, any>[]} records - The package's index records; each
|
|
47
42
|
* note record's `runs` is updated in place.
|
|
48
|
-
* @param {{languages?: Readonly<Record<string, {tag: string, note?: string}>>, contentPackage?: string}} config -
|
|
43
|
+
* @param {{languages?: Readonly<Record<string, {tag: string, note?: string}>>, contentPackage?: string, rootDir?:string, paths?:{content?:string}}} config -
|
|
49
44
|
* The configured languages, whose `note` names each language note.
|
|
50
45
|
*/
|
|
51
|
-
export function
|
|
46
|
+
export function fillEncodingRuns(records: Record<string, any>[], config: {
|
|
52
47
|
languages?: Readonly<Record<string, {
|
|
53
48
|
tag: string;
|
|
54
49
|
note?: string;
|
|
55
50
|
}>>;
|
|
56
51
|
contentPackage?: string;
|
|
52
|
+
rootDir?: string;
|
|
53
|
+
paths?: {
|
|
54
|
+
content?: string;
|
|
55
|
+
};
|
|
57
56
|
}): void;
|
|
58
57
|
/**
|
|
59
58
|
* The containing page's NOTE identity.
|
|
@@ -91,19 +90,13 @@ export type RecordRun = {
|
|
|
91
90
|
tag: string | null;
|
|
92
91
|
/**
|
|
93
92
|
* - Its explicit font, an inherited ordinary
|
|
94
|
-
* prose family, or the
|
|
93
|
+
* prose family, or the font of the selected encoding document.
|
|
95
94
|
*/
|
|
96
95
|
font: string | null;
|
|
97
96
|
/**
|
|
98
|
-
* - Its
|
|
99
|
-
* opted-in native run; null for Roman language-only text.
|
|
97
|
+
* - Its resolved encoding document, or default for Roman text.
|
|
100
98
|
*/
|
|
101
|
-
|
|
102
|
-
/**
|
|
103
|
-
* - Explicit native opt-in on this construct;
|
|
104
|
-
* absent on Roman runs. This internal flag is not a SQL column.
|
|
105
|
-
*/
|
|
106
|
-
nativefont?: boolean | undefined;
|
|
99
|
+
enc: string | null;
|
|
107
100
|
/**
|
|
108
101
|
* - 1-based file line of its opening.
|
|
109
102
|
*/
|
|
@@ -26,3 +26,5 @@ export const LANGUAGE_EMPHASES: readonly string[];
|
|
|
26
26
|
export const SCRIPT_DIRECTIONS: readonly string[];
|
|
27
27
|
/** The `subType` of a script note. */
|
|
28
28
|
export const SCRIPT_SUBTYPE: "script";
|
|
29
|
+
/** The ordinary prose families accepted by font=. */
|
|
30
|
+
export const GENERIC_FAMILIES: readonly string[];
|
|
@@ -12,7 +12,7 @@ export function emphasesFromRecords(records: Iterable<Record<string, any>> | und
|
|
|
12
12
|
*
|
|
13
13
|
* @param {ReadonlyMap<string, Record<string, any>>} byName - Each configured
|
|
14
14
|
* language's note record, by language name, from
|
|
15
|
-
* {@link module:engine/
|
|
15
|
+
* {@link module:engine/encoding-lexicon.languageRecordsByName}.
|
|
16
16
|
* @returns {Map<string, LanguageEmphasis>} The conventions, by language name;
|
|
17
17
|
* a language whose note states none, or one the build does not know, is
|
|
18
18
|
* absent.
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* The faces the package's notes set text in, read from the notes
|
|
3
3
|
* themselves: every Markdown file under the content tree that writes `font=`
|
|
4
|
-
* is scanned for its runs, and
|
|
5
|
-
*
|
|
6
|
-
* in it.
|
|
4
|
+
* is scanned for its runs, and encoding documents supply the fonts their
|
|
5
|
+
* encoded runs infer.
|
|
7
6
|
*
|
|
8
7
|
* @param {DeliveryConfig} config - The resolved configuration.
|
|
9
8
|
* @param {import("./script-fonts.mjs").ScriptFonts} installed - The fonts package.
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
* @typedef {object} FaceCodepoint
|
|
5
5
|
* @property {string} codepoint - `U+` and the hexadecimal code point.
|
|
6
6
|
* @property {string} glyph - The glyph's name in the face.
|
|
7
|
+
* @property {string} [code] - The font's case-sensitive glyph code.
|
|
7
8
|
* @property {string} kind - What it is: `letter`, `numeral`, `mark` and so on.
|
|
8
9
|
*/
|
|
9
10
|
/**
|
|
@@ -77,6 +78,10 @@ export type FaceCodepoint = {
|
|
|
77
78
|
* - The glyph's name in the face.
|
|
78
79
|
*/
|
|
79
80
|
glyph: string;
|
|
81
|
+
/**
|
|
82
|
+
* - The font's case-sensitive glyph code.
|
|
83
|
+
*/
|
|
84
|
+
code?: string | undefined;
|
|
80
85
|
/**
|
|
81
86
|
* - What it is: `letter`, `numeral`, `mark` and so on.
|
|
82
87
|
*/
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
* @param {string} text - Markdown, optionally beginning with YAML frontmatter.
|
|
12
12
|
* @param {{dark?: boolean, infobox?: boolean, file?: string, currentDate?: string,
|
|
13
13
|
* index?: import("./preview-index.mjs").PreviewIndex}} [options] - Explicit palette, profile visibility, diagnostic filename, neutral current date (default "720.1") and the content index, from {@link module:engine/preview-index.previewIndex}.
|
|
14
|
-
* @returns {{ok: boolean, html: string, frontmatter: object, findings: object[]}} HTML and metadata with locally calculable ages; unavailable ages remain absent or null.
|
|
14
|
+
* @returns {{ok: boolean, html: string, frontmatter: object, findings: object[]}} HTML and metadata with locally calculable ages; unavailable ages remain absent or null. Error findings set `ok` to false while retaining the HTML.
|
|
15
15
|
*/
|
|
16
16
|
export function renderPreview(text: string, { dark, infobox, file, currentDate, index }?: {
|
|
17
17
|
dark?: boolean;
|