@helloao/tools 0.0.18 → 0.0.19
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/types/generation/api.d.ts +735 -0
- package/dist/types/generation/audio.d.ts +20 -0
- package/dist/types/generation/book-order.d.ts +19 -0
- package/dist/types/generation/common-types.d.ts +546 -0
- package/dist/types/generation/dataset.d.ts +84 -0
- package/dist/types/generation/index.d.ts +7 -0
- package/dist/types/index.d.ts +6 -0
- package/dist/types/log.d.ts +23 -0
- package/dist/types/parser/codex-parser.d.ts +158 -0
- package/dist/types/parser/commentary-csv-parser.d.ts +12 -0
- package/dist/types/parser/index.d.ts +8 -0
- package/dist/types/parser/iterators.d.ts +89 -0
- package/dist/types/parser/tyndale-xml-parser.d.ts +8 -0
- package/dist/types/parser/types.d.ts +204 -0
- package/dist/types/parser/usfm-parser.d.ts +135 -0
- package/dist/types/parser/usx-parser.d.ts +37 -0
- package/dist/types/utils.d.ts +48 -0
- package/package.json +1 -1
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { ParseTree } from './types.js';
|
|
3
|
+
export declare const chapterHeadingSchema: z.ZodObject<{
|
|
4
|
+
type: z.ZodLiteral<"chapter-heading">;
|
|
5
|
+
data: z.ZodObject<{
|
|
6
|
+
chapter: z.ZodNumber;
|
|
7
|
+
}, "strip", z.ZodTypeAny, {
|
|
8
|
+
chapter: number;
|
|
9
|
+
}, {
|
|
10
|
+
chapter: number;
|
|
11
|
+
}>;
|
|
12
|
+
}, "strip", z.ZodTypeAny, {
|
|
13
|
+
type: "chapter-heading";
|
|
14
|
+
data: {
|
|
15
|
+
chapter: number;
|
|
16
|
+
};
|
|
17
|
+
}, {
|
|
18
|
+
type: "chapter-heading";
|
|
19
|
+
data: {
|
|
20
|
+
chapter: number;
|
|
21
|
+
};
|
|
22
|
+
}>;
|
|
23
|
+
export declare const verseSchema: z.ZodObject<{
|
|
24
|
+
type: z.ZodLiteral<"text">;
|
|
25
|
+
id: z.ZodString;
|
|
26
|
+
bookCode: z.ZodOptional<z.ZodString>;
|
|
27
|
+
chapter: z.ZodOptional<z.ZodNumber>;
|
|
28
|
+
verse: z.ZodOptional<z.ZodNumber>;
|
|
29
|
+
}, "strip", z.ZodTypeAny, {
|
|
30
|
+
id: string;
|
|
31
|
+
type: "text";
|
|
32
|
+
chapter?: number | undefined;
|
|
33
|
+
verse?: number | undefined;
|
|
34
|
+
bookCode?: string | undefined;
|
|
35
|
+
}, {
|
|
36
|
+
id: string;
|
|
37
|
+
type: "text";
|
|
38
|
+
chapter?: number | undefined;
|
|
39
|
+
verse?: number | undefined;
|
|
40
|
+
bookCode?: string | undefined;
|
|
41
|
+
}>;
|
|
42
|
+
export declare const paratextSchema: z.ZodObject<{
|
|
43
|
+
type: z.ZodLiteral<"paratext">;
|
|
44
|
+
id: z.ZodString;
|
|
45
|
+
}, "strip", z.ZodTypeAny, {
|
|
46
|
+
id: string;
|
|
47
|
+
type: "paratext";
|
|
48
|
+
}, {
|
|
49
|
+
id: string;
|
|
50
|
+
type: "paratext";
|
|
51
|
+
}>;
|
|
52
|
+
export declare const metadataSchema: z.ZodDiscriminatedUnion<"type", [z.ZodObject<{
|
|
53
|
+
type: z.ZodLiteral<"chapter-heading">;
|
|
54
|
+
data: z.ZodObject<{
|
|
55
|
+
chapter: z.ZodNumber;
|
|
56
|
+
}, "strip", z.ZodTypeAny, {
|
|
57
|
+
chapter: number;
|
|
58
|
+
}, {
|
|
59
|
+
chapter: number;
|
|
60
|
+
}>;
|
|
61
|
+
}, "strip", z.ZodTypeAny, {
|
|
62
|
+
type: "chapter-heading";
|
|
63
|
+
data: {
|
|
64
|
+
chapter: number;
|
|
65
|
+
};
|
|
66
|
+
}, {
|
|
67
|
+
type: "chapter-heading";
|
|
68
|
+
data: {
|
|
69
|
+
chapter: number;
|
|
70
|
+
};
|
|
71
|
+
}>, z.ZodObject<{
|
|
72
|
+
type: z.ZodLiteral<"text">;
|
|
73
|
+
id: z.ZodString;
|
|
74
|
+
bookCode: z.ZodOptional<z.ZodString>;
|
|
75
|
+
chapter: z.ZodOptional<z.ZodNumber>;
|
|
76
|
+
verse: z.ZodOptional<z.ZodNumber>;
|
|
77
|
+
}, "strip", z.ZodTypeAny, {
|
|
78
|
+
id: string;
|
|
79
|
+
type: "text";
|
|
80
|
+
chapter?: number | undefined;
|
|
81
|
+
verse?: number | undefined;
|
|
82
|
+
bookCode?: string | undefined;
|
|
83
|
+
}, {
|
|
84
|
+
id: string;
|
|
85
|
+
type: "text";
|
|
86
|
+
chapter?: number | undefined;
|
|
87
|
+
verse?: number | undefined;
|
|
88
|
+
bookCode?: string | undefined;
|
|
89
|
+
}>, z.ZodObject<{
|
|
90
|
+
type: z.ZodLiteral<"paratext">;
|
|
91
|
+
id: z.ZodString;
|
|
92
|
+
}, "strip", z.ZodTypeAny, {
|
|
93
|
+
id: string;
|
|
94
|
+
type: "paratext";
|
|
95
|
+
}, {
|
|
96
|
+
id: string;
|
|
97
|
+
type: "paratext";
|
|
98
|
+
}>]>;
|
|
99
|
+
export declare const codexSchema: z.ZodObject<{
|
|
100
|
+
cells: z.ZodArray<z.ZodObject<{
|
|
101
|
+
kind: z.ZodNumber;
|
|
102
|
+
languageId: z.ZodString;
|
|
103
|
+
value: z.ZodString;
|
|
104
|
+
metadata: z.ZodOptional<z.ZodNullable<z.ZodObject<{
|
|
105
|
+
type: z.ZodString;
|
|
106
|
+
}, "passthrough", z.ZodTypeAny, z.objectOutputType<{
|
|
107
|
+
type: z.ZodString;
|
|
108
|
+
}, z.ZodTypeAny, "passthrough">, z.objectInputType<{
|
|
109
|
+
type: z.ZodString;
|
|
110
|
+
}, z.ZodTypeAny, "passthrough">>>>;
|
|
111
|
+
}, "strip", z.ZodTypeAny, {
|
|
112
|
+
kind: number;
|
|
113
|
+
value: string;
|
|
114
|
+
languageId: string;
|
|
115
|
+
metadata?: z.objectOutputType<{
|
|
116
|
+
type: z.ZodString;
|
|
117
|
+
}, z.ZodTypeAny, "passthrough"> | null | undefined;
|
|
118
|
+
}, {
|
|
119
|
+
kind: number;
|
|
120
|
+
value: string;
|
|
121
|
+
languageId: string;
|
|
122
|
+
metadata?: z.objectInputType<{
|
|
123
|
+
type: z.ZodString;
|
|
124
|
+
}, z.ZodTypeAny, "passthrough"> | null | undefined;
|
|
125
|
+
}>, "many">;
|
|
126
|
+
}, "strip", z.ZodTypeAny, {
|
|
127
|
+
cells: {
|
|
128
|
+
kind: number;
|
|
129
|
+
value: string;
|
|
130
|
+
languageId: string;
|
|
131
|
+
metadata?: z.objectOutputType<{
|
|
132
|
+
type: z.ZodString;
|
|
133
|
+
}, z.ZodTypeAny, "passthrough"> | null | undefined;
|
|
134
|
+
}[];
|
|
135
|
+
}, {
|
|
136
|
+
cells: {
|
|
137
|
+
kind: number;
|
|
138
|
+
value: string;
|
|
139
|
+
languageId: string;
|
|
140
|
+
metadata?: z.objectInputType<{
|
|
141
|
+
type: z.ZodString;
|
|
142
|
+
}, z.ZodTypeAny, "passthrough"> | null | undefined;
|
|
143
|
+
}[];
|
|
144
|
+
}>;
|
|
145
|
+
/**
|
|
146
|
+
* Defines a parser for codex files.
|
|
147
|
+
*/
|
|
148
|
+
export declare class CodexParser {
|
|
149
|
+
private _noteCounter;
|
|
150
|
+
/**
|
|
151
|
+
* Parses the specified codex content.
|
|
152
|
+
*
|
|
153
|
+
* @param codex The codex content to parse.
|
|
154
|
+
* @returns The parse tree that was generated.
|
|
155
|
+
*/
|
|
156
|
+
parse(codex: string): ParseTree;
|
|
157
|
+
}
|
|
158
|
+
//# sourceMappingURL=codex-parser.d.ts.map
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { CommentaryParseTree } from './types';
|
|
2
|
+
export interface CsvLine {
|
|
3
|
+
book: string;
|
|
4
|
+
chapter: string;
|
|
5
|
+
verse: string;
|
|
6
|
+
commentaries: string;
|
|
7
|
+
}
|
|
8
|
+
export declare class CommentaryCsvParser {
|
|
9
|
+
parse(data: string): CommentaryParseTree;
|
|
10
|
+
parseLines(data: CsvLine[]): CommentaryParseTree;
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=commentary-csv-parser.d.ts.map
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export * from './types.js';
|
|
2
|
+
export * from './usfm-parser.js';
|
|
3
|
+
export * from './usx-parser.js';
|
|
4
|
+
export * from './codex-parser.js';
|
|
5
|
+
export * from './commentary-csv-parser.js';
|
|
6
|
+
import * as iterators from './iterators.js';
|
|
7
|
+
export { iterators };
|
|
8
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Defines an interface that represents an iterator that can be rewound.
|
|
3
|
+
*/
|
|
4
|
+
export interface RewindableIterator<T> extends IterableIterator<T> {
|
|
5
|
+
/**
|
|
6
|
+
* Rewinds the iterator by the specified number of elements.
|
|
7
|
+
* @param number The number of elements to rewind.
|
|
8
|
+
*/
|
|
9
|
+
rewind(number: number): void;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Defines a class that implements an iterator that can be rewound.
|
|
13
|
+
*/
|
|
14
|
+
export declare class Rewindable<T> implements RewindableIterator<T> {
|
|
15
|
+
buffer: T[];
|
|
16
|
+
private _bufferSize;
|
|
17
|
+
private _position;
|
|
18
|
+
private _iterator;
|
|
19
|
+
constructor(iterator: IterableIterator<T>, bufferSize?: number);
|
|
20
|
+
rewind(number: number): void;
|
|
21
|
+
[Symbol.iterator](): IterableIterator<T>;
|
|
22
|
+
next(...args: [] | [undefined]): IteratorResult<T, any>;
|
|
23
|
+
return?(value?: any): IteratorResult<T, any>;
|
|
24
|
+
throw?(e?: any): IteratorResult<T, any>;
|
|
25
|
+
}
|
|
26
|
+
export declare function debug(label: string, iterator: IterableIterator<any>): Generator<any, void, unknown>;
|
|
27
|
+
/**
|
|
28
|
+
* Creates a new rewindable iterator from the given iterator.
|
|
29
|
+
* @param iterator The iterator.
|
|
30
|
+
* @param bufferSize The size of the buffer.
|
|
31
|
+
*/
|
|
32
|
+
export declare function rewindable<T>(iterator: IterableIterator<T>, bufferSize?: number): Rewindable<T>;
|
|
33
|
+
/**
|
|
34
|
+
* Gets the char element that is the parent of the given node.
|
|
35
|
+
* @param node The node.
|
|
36
|
+
*/
|
|
37
|
+
export declare function parentChar(node: Node): Element | null;
|
|
38
|
+
/**
|
|
39
|
+
* Gets the note element that is the parent of the given node.
|
|
40
|
+
* @param node The node.
|
|
41
|
+
*/
|
|
42
|
+
export declare function parentNote(node: Node): Element | null;
|
|
43
|
+
/**
|
|
44
|
+
* Gets the parent node that matches the given filter.
|
|
45
|
+
* @param node The node to start the search from.
|
|
46
|
+
* @param filter The filter that should be used.
|
|
47
|
+
*/
|
|
48
|
+
export declare function matchingParent(node: Node, filter: (node: Node) => boolean): Node | null;
|
|
49
|
+
/**
|
|
50
|
+
* Determines if the given node is a child of the parent node.
|
|
51
|
+
* @param node The node to test.
|
|
52
|
+
* @param parent The parent.
|
|
53
|
+
* @returns
|
|
54
|
+
*/
|
|
55
|
+
export declare function isParent(node: Node, parent: Node): boolean;
|
|
56
|
+
/**
|
|
57
|
+
* Iterates through all of the nodes in the tree in a depth-first traversal.
|
|
58
|
+
* @param node The node to start the traversal from.
|
|
59
|
+
*/
|
|
60
|
+
export declare function iterateAll(node: Node): RewindableIterator<Node>;
|
|
61
|
+
export declare function iterateUntil<T>(iterator: IterableIterator<T>, predicate: (value: T) => boolean): IterableIterator<T>;
|
|
62
|
+
/**
|
|
63
|
+
* Iterates only the elements in the iterator.
|
|
64
|
+
* @param iterator The iterator that should be used.
|
|
65
|
+
*/
|
|
66
|
+
export declare function elements(iterator: IterableIterator<Node>): IterableIterator<Element>;
|
|
67
|
+
/**
|
|
68
|
+
* Iterates only the children of the given node in the iterator.
|
|
69
|
+
* @param iterator The iterator that should be used.
|
|
70
|
+
* @param parent The parent node.
|
|
71
|
+
*/
|
|
72
|
+
export declare function children(iterator: RewindableIterator<Node>, parent: Node): IterableIterator<Node>;
|
|
73
|
+
/**
|
|
74
|
+
* Wraps the given iterable in a generator that will prevent consumers from calling return() on the iterator.
|
|
75
|
+
* @param iterable The iterable.
|
|
76
|
+
*/
|
|
77
|
+
export declare function uncompletable<T>(iterable: IterableIterator<T>): IterableIterator<T>;
|
|
78
|
+
/**
|
|
79
|
+
* Converts the given iterable into an async iterable.
|
|
80
|
+
* @param input The input iterable.
|
|
81
|
+
*/
|
|
82
|
+
export declare function toAsyncIterable<T>(input: Iterable<T>): AsyncIterable<T>;
|
|
83
|
+
/**
|
|
84
|
+
* Batches items from the given iterator.
|
|
85
|
+
* @param input The input iterator.
|
|
86
|
+
* @param batchSize The size of each batch.
|
|
87
|
+
*/
|
|
88
|
+
export declare function batch<T>(input: Iterable<T>, batchSize: number): Iterable<T[]>;
|
|
89
|
+
//# sourceMappingURL=iterators.d.ts.map
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { CommentaryParseTree } from './types';
|
|
2
|
+
export declare class TyndaleXmlParser {
|
|
3
|
+
private _domParser;
|
|
4
|
+
constructor(domParser: DOMParser);
|
|
5
|
+
parse(xml: string): CommentaryParseTree;
|
|
6
|
+
}
|
|
7
|
+
export declare function toKebabCase(camelCase: string): string;
|
|
8
|
+
//# sourceMappingURL=tyndale-xml-parser.d.ts.map
|
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
import { VerseRef } from '../utils.js';
|
|
2
|
+
/**
|
|
3
|
+
* The parse tree that is gathered.
|
|
4
|
+
*/
|
|
5
|
+
export interface ParseTree {
|
|
6
|
+
type: 'root';
|
|
7
|
+
/**
|
|
8
|
+
* The ID of the parse tree.
|
|
9
|
+
*/
|
|
10
|
+
id?: string;
|
|
11
|
+
/**
|
|
12
|
+
* The header that was associated with the tree.
|
|
13
|
+
*/
|
|
14
|
+
header?: string;
|
|
15
|
+
/**
|
|
16
|
+
* The major title that was associated with the tree.
|
|
17
|
+
*/
|
|
18
|
+
title?: string;
|
|
19
|
+
/**
|
|
20
|
+
* The list of chapters for the tree.
|
|
21
|
+
*/
|
|
22
|
+
content: (Heading | Chapter)[];
|
|
23
|
+
/**
|
|
24
|
+
* The list of messages that were generated during parsing.
|
|
25
|
+
*/
|
|
26
|
+
parseMessages?: ParseMessage[];
|
|
27
|
+
}
|
|
28
|
+
export interface ParseMessage {
|
|
29
|
+
type: 'warning' | 'error';
|
|
30
|
+
message: string;
|
|
31
|
+
}
|
|
32
|
+
export interface Heading {
|
|
33
|
+
type: 'heading';
|
|
34
|
+
content: string[];
|
|
35
|
+
}
|
|
36
|
+
export type ChapterContent = Heading | Verse | HebrewSubtitle | LineBreak;
|
|
37
|
+
export type VerseContent = string | FootnoteReference | Text;
|
|
38
|
+
/**
|
|
39
|
+
* Defines an interface that represents a chapter.
|
|
40
|
+
*/
|
|
41
|
+
export interface Chapter {
|
|
42
|
+
type: 'chapter';
|
|
43
|
+
number: number;
|
|
44
|
+
/**
|
|
45
|
+
* The contents of the chapter.
|
|
46
|
+
*/
|
|
47
|
+
content: ChapterContent[];
|
|
48
|
+
/**
|
|
49
|
+
* The list of footnotes for the chapter.
|
|
50
|
+
*/
|
|
51
|
+
footnotes: Footnote[];
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Defines an interface that represents a hebrew subtitle.
|
|
55
|
+
*/
|
|
56
|
+
export interface HebrewSubtitle {
|
|
57
|
+
type: 'hebrew_subtitle';
|
|
58
|
+
/**
|
|
59
|
+
* The contents of the subtitle.
|
|
60
|
+
*/
|
|
61
|
+
content: (string | Text | FootnoteReference)[];
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Defines an interface that represents a verse.
|
|
65
|
+
*/
|
|
66
|
+
export interface Verse {
|
|
67
|
+
type: 'verse';
|
|
68
|
+
number: number;
|
|
69
|
+
/**
|
|
70
|
+
* The contents of the verse.
|
|
71
|
+
*/
|
|
72
|
+
content: (string | Text | InlineHeading | InlineLineBreak | FootnoteReference)[];
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Defines an interface that represents text that has some markup attributes applied to it.
|
|
76
|
+
*/
|
|
77
|
+
export interface Text {
|
|
78
|
+
/**
|
|
79
|
+
* The text that is contained.
|
|
80
|
+
*/
|
|
81
|
+
text: string;
|
|
82
|
+
/**
|
|
83
|
+
* Whether the text represents a poem.
|
|
84
|
+
* The number indicates the level of indent.
|
|
85
|
+
*/
|
|
86
|
+
poem?: number;
|
|
87
|
+
/**
|
|
88
|
+
* Whether the text contains the words of Jesus.
|
|
89
|
+
*/
|
|
90
|
+
wordsOfJesus?: boolean;
|
|
91
|
+
/**
|
|
92
|
+
* Whether the text is descriptive.
|
|
93
|
+
*
|
|
94
|
+
* This is only used for "hebrew subtitles" that are included inside the verse markers.
|
|
95
|
+
*/
|
|
96
|
+
descriptive?: boolean;
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Defines an interface that represents a heading that is embedded in a verse.
|
|
100
|
+
*/
|
|
101
|
+
export interface InlineHeading {
|
|
102
|
+
/**
|
|
103
|
+
* The text of the heading.
|
|
104
|
+
*/
|
|
105
|
+
heading: string;
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Defines an interface that represents a line break that is embedded in a verse.
|
|
109
|
+
*/
|
|
110
|
+
export interface InlineLineBreak {
|
|
111
|
+
lineBreak: true;
|
|
112
|
+
}
|
|
113
|
+
export interface FootnoteReference {
|
|
114
|
+
/**
|
|
115
|
+
* The ID of the note that is referenced.
|
|
116
|
+
*/
|
|
117
|
+
noteId: number;
|
|
118
|
+
}
|
|
119
|
+
export interface Footnote {
|
|
120
|
+
noteId: number;
|
|
121
|
+
/**
|
|
122
|
+
* The text of the footnote.
|
|
123
|
+
*/
|
|
124
|
+
text: string;
|
|
125
|
+
/**
|
|
126
|
+
* The caller that should be used for the footnote.
|
|
127
|
+
* For footnotes, a "caller" is the character that is used in the text to reference to footnote.
|
|
128
|
+
*
|
|
129
|
+
* For example, in the text:
|
|
130
|
+
* Hello (a) World
|
|
131
|
+
*
|
|
132
|
+
* ----
|
|
133
|
+
* (a) This is a footnote.
|
|
134
|
+
*
|
|
135
|
+
* The "(a)" is the caller.
|
|
136
|
+
*
|
|
137
|
+
* If "+", then the caller should be autogenerated.
|
|
138
|
+
* If null, then the caller should be empty.
|
|
139
|
+
* If a string, then the caller should be that string.
|
|
140
|
+
*/
|
|
141
|
+
caller: '+' | string | null;
|
|
142
|
+
/**
|
|
143
|
+
* The verse reference for the footnote.
|
|
144
|
+
*/
|
|
145
|
+
reference?: {
|
|
146
|
+
chapter: number;
|
|
147
|
+
verse: number;
|
|
148
|
+
};
|
|
149
|
+
}
|
|
150
|
+
export interface LineBreak {
|
|
151
|
+
type: 'line_break';
|
|
152
|
+
}
|
|
153
|
+
/**
|
|
154
|
+
* The parse tree that is gathered.
|
|
155
|
+
*/
|
|
156
|
+
export interface CommentaryParseTree {
|
|
157
|
+
type: 'commentary/root';
|
|
158
|
+
/**
|
|
159
|
+
* The books that are contained in the commentary.
|
|
160
|
+
*/
|
|
161
|
+
books: CommentaryBookNode[];
|
|
162
|
+
/**
|
|
163
|
+
* The profiles that are contained in the commentary.
|
|
164
|
+
*/
|
|
165
|
+
profiles?: CommentaryProfileNode[];
|
|
166
|
+
}
|
|
167
|
+
export interface CommentaryBookNode {
|
|
168
|
+
type: 'book';
|
|
169
|
+
book: string;
|
|
170
|
+
introduction: string | null;
|
|
171
|
+
introductionSummary?: string | null;
|
|
172
|
+
chapters: CommentaryChapterNode[];
|
|
173
|
+
}
|
|
174
|
+
export interface CommentaryProfileNode {
|
|
175
|
+
/**
|
|
176
|
+
* The ID of the profile.
|
|
177
|
+
* Used to identify the profile within a commentary.
|
|
178
|
+
*/
|
|
179
|
+
id: string;
|
|
180
|
+
/**
|
|
181
|
+
* The subject(s) of the profile.
|
|
182
|
+
*/
|
|
183
|
+
subject: string;
|
|
184
|
+
/**
|
|
185
|
+
* The Bible reference that the profile is associated with.
|
|
186
|
+
*/
|
|
187
|
+
reference: VerseRef | null;
|
|
188
|
+
/**
|
|
189
|
+
* The content of the profile.
|
|
190
|
+
*/
|
|
191
|
+
content: string[];
|
|
192
|
+
}
|
|
193
|
+
export interface CommentaryChapterNode {
|
|
194
|
+
type: 'chapter';
|
|
195
|
+
number: number;
|
|
196
|
+
introduction: string | null;
|
|
197
|
+
verses: CommentaryVerseNode[];
|
|
198
|
+
}
|
|
199
|
+
export interface CommentaryVerseNode {
|
|
200
|
+
type: 'verse';
|
|
201
|
+
number: number;
|
|
202
|
+
content: string[];
|
|
203
|
+
}
|
|
204
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
import { ParseTree } from './types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Defines a class that can tokenize a stream of characters into tokens.
|
|
4
|
+
*/
|
|
5
|
+
export declare class UsfmTokenizer {
|
|
6
|
+
private _input;
|
|
7
|
+
private _index;
|
|
8
|
+
private _start;
|
|
9
|
+
private get _tokenLength();
|
|
10
|
+
/**
|
|
11
|
+
* Converts the given input into a list of tokens.
|
|
12
|
+
* @param input The input that should be tokenized.
|
|
13
|
+
*/
|
|
14
|
+
tokenize(input: string): SimpleToken[];
|
|
15
|
+
private _parseTokens;
|
|
16
|
+
private _parseToken;
|
|
17
|
+
}
|
|
18
|
+
export interface UsfmParseOptions {
|
|
19
|
+
paragraphs: Set<string>;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Defines a USFM Parser.
|
|
23
|
+
*/
|
|
24
|
+
export declare class UsfmParser {
|
|
25
|
+
private _poem;
|
|
26
|
+
private _wordsOfJesus;
|
|
27
|
+
tokenize(input: string): Token[];
|
|
28
|
+
parse(input: string): ParseTree;
|
|
29
|
+
renderMarkdown(tree: ParseTree): string;
|
|
30
|
+
private _hasAttribute;
|
|
31
|
+
private _text;
|
|
32
|
+
private _throwError;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Determines if the given character is a digit.
|
|
36
|
+
* @param char The character.
|
|
37
|
+
*/
|
|
38
|
+
export declare function isDigit(char: string): boolean;
|
|
39
|
+
/**
|
|
40
|
+
* Determines if the given character is considered whitespace.
|
|
41
|
+
* @param char The character.
|
|
42
|
+
*/
|
|
43
|
+
export declare function isWhitespace(char: string): boolean;
|
|
44
|
+
export declare function t(loc: SourceLocation, kind: T): SimpleToken;
|
|
45
|
+
/**
|
|
46
|
+
* Creates a new source location.
|
|
47
|
+
* @param start The start of the location.
|
|
48
|
+
* @param end The end of the location.
|
|
49
|
+
*/
|
|
50
|
+
export declare function loc(start: number, end: number): SourceLocation;
|
|
51
|
+
/**
|
|
52
|
+
* Creates a new marker token.
|
|
53
|
+
* @param loc The location for the token.
|
|
54
|
+
* @param command The command that the token contains.
|
|
55
|
+
* @param number The number that the marker contains.
|
|
56
|
+
* @param type The type of the marker.
|
|
57
|
+
*/
|
|
58
|
+
export declare function marker(loc: SourceLocation, command: string, number?: number | null, type?: MarkerToken['type']): MarkerToken;
|
|
59
|
+
/**
|
|
60
|
+
* Creates a new word token.
|
|
61
|
+
* @param loc The location for the token.
|
|
62
|
+
* @param word The word contained by the token.
|
|
63
|
+
*/
|
|
64
|
+
export declare function word(loc: SourceLocation, word: string): WordToken;
|
|
65
|
+
export declare function whitespace(loc: SourceLocation, whitespace: string): WhitespaceToken;
|
|
66
|
+
export type T = Token['kind'];
|
|
67
|
+
/**
|
|
68
|
+
* Defines a simple token.
|
|
69
|
+
*/
|
|
70
|
+
export interface SimpleToken {
|
|
71
|
+
kind: T;
|
|
72
|
+
loc: SourceLocation;
|
|
73
|
+
}
|
|
74
|
+
export type Token = MarkerToken | WordToken | WhitespaceToken;
|
|
75
|
+
/**
|
|
76
|
+
* Defines an interface for a USFM marker node.
|
|
77
|
+
* That is, the syntax for a marker.
|
|
78
|
+
*/
|
|
79
|
+
export interface MarkerToken {
|
|
80
|
+
kind: 'marker';
|
|
81
|
+
/**
|
|
82
|
+
* The command that the marker represents.
|
|
83
|
+
* This is generally the name of the marker (like "p" or "v" for paragraph and verse markers)
|
|
84
|
+
*/
|
|
85
|
+
command: string;
|
|
86
|
+
/**
|
|
87
|
+
* The number that the marker contains.
|
|
88
|
+
* Null if no number was specified.
|
|
89
|
+
*/
|
|
90
|
+
number: number | null;
|
|
91
|
+
/**
|
|
92
|
+
* Whether the marker represents a start or an end.
|
|
93
|
+
*/
|
|
94
|
+
type: 'start' | 'end';
|
|
95
|
+
/**
|
|
96
|
+
* The location of the node.
|
|
97
|
+
*/
|
|
98
|
+
loc: SourceLocation;
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Defines an interface for a Whitespace node.
|
|
102
|
+
*/
|
|
103
|
+
export interface WhitespaceToken {
|
|
104
|
+
kind: 'whitespace';
|
|
105
|
+
/**
|
|
106
|
+
* The whitespace contained by the node.
|
|
107
|
+
*/
|
|
108
|
+
whitespace: string;
|
|
109
|
+
/**
|
|
110
|
+
* The location of the node.
|
|
111
|
+
*/
|
|
112
|
+
loc: SourceLocation;
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Defines an interface for a word token.
|
|
116
|
+
*/
|
|
117
|
+
export interface WordToken {
|
|
118
|
+
kind: 'word';
|
|
119
|
+
/**
|
|
120
|
+
* The word contained by the token.
|
|
121
|
+
*/
|
|
122
|
+
word: string;
|
|
123
|
+
/**
|
|
124
|
+
* The location of the word.
|
|
125
|
+
*/
|
|
126
|
+
loc: SourceLocation;
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* The source location of the node.
|
|
130
|
+
*/
|
|
131
|
+
export interface SourceLocation {
|
|
132
|
+
start: number;
|
|
133
|
+
end: number;
|
|
134
|
+
}
|
|
135
|
+
//# sourceMappingURL=usfm-parser.d.ts.map
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { Chapter, ChapterContent, FootnoteReference, ParseTree, Verse, Text, HebrewSubtitle, InlineLineBreak } from './types.js';
|
|
2
|
+
import { RewindableIterator } from './iterators.js';
|
|
3
|
+
/**
|
|
4
|
+
* The version of the parser.
|
|
5
|
+
* Used to determine whether input files need to be re-parsed.
|
|
6
|
+
*/
|
|
7
|
+
export declare const PARSER_VERSION = "2";
|
|
8
|
+
/**
|
|
9
|
+
* Defines a class that is able to parse USX content.
|
|
10
|
+
*/
|
|
11
|
+
export declare class USXParser {
|
|
12
|
+
private _domParser;
|
|
13
|
+
private _noteCounter;
|
|
14
|
+
private _messages;
|
|
15
|
+
private _lastVerse;
|
|
16
|
+
private _currentChapter;
|
|
17
|
+
private _bookId;
|
|
18
|
+
constructor(domParser: DOMParser);
|
|
19
|
+
/**
|
|
20
|
+
* Parses the specified USX content.
|
|
21
|
+
*
|
|
22
|
+
* @param usx The USX content to parse.
|
|
23
|
+
* @returns The parse tree that was generated.
|
|
24
|
+
*/
|
|
25
|
+
parse(usx: string): ParseTree;
|
|
26
|
+
iterateRootContent(usxElement: Element): Generator<ParseTree['content'][0]>;
|
|
27
|
+
iterateChapterContent(chapter: Chapter, nodes: RewindableIterator<Node>): IterableIterator<ChapterContent>;
|
|
28
|
+
iterateVerseContent(chapter: Chapter, verse: Verse, nodes: RewindableIterator<Node>): IterableIterator<string | FootnoteReference | Text | InlineLineBreak>;
|
|
29
|
+
parseVerse(element: Element, chapter: Chapter, nodes: RewindableIterator<Node>): Verse;
|
|
30
|
+
parseHebrewSubtitle(para: Element, chapter: Chapter, nodes: RewindableIterator<Node>): IterableIterator<HebrewSubtitle | Verse>;
|
|
31
|
+
iterateHebrewSubtitleContent(element: Element, chapter: Chapter, nodes: RewindableIterator<Node>): IterableIterator<Verse | string | Text | FootnoteReference | InlineLineBreak>;
|
|
32
|
+
iterateNodeTextContent(nodes: RewindableIterator<Node>, node: Node, chapter: Chapter, verse?: Verse): IterableIterator<string | Text | FootnoteReference | InlineLineBreak>;
|
|
33
|
+
iterateCharContent(char: Element): IterableIterator<string | Text>;
|
|
34
|
+
iterateNote(nodes: RewindableIterator<Node>, node: Element, chapter: Chapter, verse?: Verse): IterableIterator<FootnoteReference>;
|
|
35
|
+
iterateChar(nodes: RewindableIterator<Node>, node: Element): IterableIterator<string | Text>;
|
|
36
|
+
}
|
|
37
|
+
//# sourceMappingURL=usx-parser.d.ts.map
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Normalizes the given language code into a ISO 639 code.
|
|
3
|
+
* @param language The language code to normalize.
|
|
4
|
+
*/
|
|
5
|
+
export declare function normalizeLanguage(language: string): string;
|
|
6
|
+
/**
|
|
7
|
+
* Gets the ID of the translation.
|
|
8
|
+
* @param translation The translation to get the ID for.
|
|
9
|
+
*/
|
|
10
|
+
export declare function getTranslationId(translationId: string): string;
|
|
11
|
+
export declare function isEmptyOrWhitespace(str: string | null | undefined): boolean;
|
|
12
|
+
export declare function getFirstNonEmpty<T extends string>(...values: T[]): T;
|
|
13
|
+
export interface VerseRef {
|
|
14
|
+
book: string;
|
|
15
|
+
chapter: number;
|
|
16
|
+
verse: number;
|
|
17
|
+
/**
|
|
18
|
+
* The rest of the content of the verse.
|
|
19
|
+
*/
|
|
20
|
+
content?: string;
|
|
21
|
+
/**
|
|
22
|
+
* The chapter that the verse reference ends at.
|
|
23
|
+
*/
|
|
24
|
+
endChapter?: number;
|
|
25
|
+
/**
|
|
26
|
+
* The verse that the verse reference ends at.
|
|
27
|
+
*/
|
|
28
|
+
endVerse?: number;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Parses the given verse reference.
|
|
32
|
+
* Formatted like "GEN 1:1".
|
|
33
|
+
*
|
|
34
|
+
* @param text The reference to parse.
|
|
35
|
+
*/
|
|
36
|
+
export declare function parseVerseReference(text: string): VerseRef | null;
|
|
37
|
+
/**
|
|
38
|
+
* Gets the ID of the given book.
|
|
39
|
+
* Returns null if the ID could not be found.
|
|
40
|
+
* @param book The name/ID of the book.
|
|
41
|
+
*/
|
|
42
|
+
export declare function getBookId(book: string): string | null;
|
|
43
|
+
/**
|
|
44
|
+
* A brief list of verses which may appear in some older translations
|
|
45
|
+
* but are not present in more modern translations.
|
|
46
|
+
*/
|
|
47
|
+
export declare const KNOWN_SKIPPED_VERSES: Set<string>;
|
|
48
|
+
//# sourceMappingURL=utils.d.ts.map
|