@helloao/tools 0.0.17 → 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.
|
@@ -36,7 +36,10 @@ const chapterHeadingSchema = import_zod.z.object({
|
|
|
36
36
|
});
|
|
37
37
|
const verseSchema = import_zod.z.object({
|
|
38
38
|
type: import_zod.z.literal("text"),
|
|
39
|
-
id: import_zod.z.string()
|
|
39
|
+
id: import_zod.z.string(),
|
|
40
|
+
bookCode: import_zod.z.string().optional(),
|
|
41
|
+
chapter: import_zod.z.number().optional(),
|
|
42
|
+
verse: import_zod.z.number().optional()
|
|
40
43
|
});
|
|
41
44
|
const paratextSchema = import_zod.z.object({
|
|
42
45
|
type: import_zod.z.literal("paratext"),
|
|
@@ -95,11 +98,11 @@ class CodexParser {
|
|
|
95
98
|
}
|
|
96
99
|
chapter.content.push(...content);
|
|
97
100
|
}
|
|
98
|
-
function addReference(
|
|
99
|
-
addChapterContent(
|
|
101
|
+
function addReference(ref2, content) {
|
|
102
|
+
addChapterContent(ref2.chapter, [
|
|
100
103
|
{
|
|
101
104
|
type: "verse",
|
|
102
|
-
number:
|
|
105
|
+
number: ref2.verse,
|
|
103
106
|
content
|
|
104
107
|
}
|
|
105
108
|
]);
|
|
@@ -113,6 +116,24 @@ class CodexParser {
|
|
|
113
116
|
content: [content]
|
|
114
117
|
};
|
|
115
118
|
}
|
|
119
|
+
function addLineBreaks(lines2) {
|
|
120
|
+
return lines2.reduce(
|
|
121
|
+
(prev, current) => {
|
|
122
|
+
if (prev.length === 0) return [current];
|
|
123
|
+
else
|
|
124
|
+
return [
|
|
125
|
+
...prev,
|
|
126
|
+
{
|
|
127
|
+
lineBreak: true
|
|
128
|
+
},
|
|
129
|
+
current
|
|
130
|
+
];
|
|
131
|
+
},
|
|
132
|
+
[]
|
|
133
|
+
);
|
|
134
|
+
}
|
|
135
|
+
let previousReference = null;
|
|
136
|
+
let lines = [];
|
|
116
137
|
for (let cell of data.cells) {
|
|
117
138
|
if (cell.languageId === "html" && cell.value) {
|
|
118
139
|
if (!cell.metadata) continue;
|
|
@@ -120,31 +141,57 @@ class CodexParser {
|
|
|
120
141
|
if (!metadataResult.success) continue;
|
|
121
142
|
const metadata = metadataResult.data;
|
|
122
143
|
if (metadata.type === "text") {
|
|
123
|
-
|
|
124
|
-
if (!reference)
|
|
125
|
-
|
|
144
|
+
let reference = (0, import_utils.parseVerseReference)(metadata.id);
|
|
145
|
+
if (!reference) {
|
|
146
|
+
if (metadata.bookCode && metadata.chapter) {
|
|
147
|
+
const bookId = (0, import_utils.getBookId)(metadata.bookCode);
|
|
148
|
+
if (!bookId) {
|
|
149
|
+
throw new Error(
|
|
150
|
+
"Could not find book ID for code: " + metadata.bookCode
|
|
151
|
+
);
|
|
152
|
+
}
|
|
153
|
+
if (metadata.verse) {
|
|
154
|
+
reference = {
|
|
155
|
+
book: bookId,
|
|
156
|
+
chapter: metadata.chapter,
|
|
157
|
+
verse: metadata.verse
|
|
158
|
+
};
|
|
159
|
+
} else if (previousReference?.verse) {
|
|
160
|
+
if (previousReference.chapter !== metadata.chapter || previousReference.book !== bookId) {
|
|
161
|
+
throw new Error(
|
|
162
|
+
"Cannot infer verse number for non-consecutive verse reference."
|
|
163
|
+
);
|
|
164
|
+
}
|
|
165
|
+
reference = {
|
|
166
|
+
book: bookId,
|
|
167
|
+
chapter: metadata.chapter,
|
|
168
|
+
verse: previousReference.verse
|
|
169
|
+
};
|
|
170
|
+
} else {
|
|
171
|
+
throw new Error(
|
|
172
|
+
"Could not find verse reference in metadata."
|
|
173
|
+
);
|
|
174
|
+
}
|
|
175
|
+
} else {
|
|
176
|
+
throw new Error(
|
|
177
|
+
"Could not find verse reference in metadata."
|
|
178
|
+
);
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
if (previousReference && (reference.book !== previousReference.book || reference.chapter !== previousReference.chapter || reference.verse !== previousReference.verse)) {
|
|
182
|
+
addReference(previousReference, addLineBreaks(lines));
|
|
183
|
+
lines = [];
|
|
184
|
+
}
|
|
185
|
+
previousReference = reference;
|
|
126
186
|
if (!root.id) root.id = reference.book;
|
|
127
187
|
const content = stripHTML(cell.value);
|
|
128
|
-
const
|
|
129
|
-
|
|
130
|
-
if (prev.length === 0) return [current];
|
|
131
|
-
else
|
|
132
|
-
return [
|
|
133
|
-
...prev,
|
|
134
|
-
{
|
|
135
|
-
lineBreak: true
|
|
136
|
-
},
|
|
137
|
-
current
|
|
138
|
-
];
|
|
139
|
-
},
|
|
140
|
-
[]
|
|
141
|
-
);
|
|
142
|
-
addReference(reference, lines);
|
|
188
|
+
const newLines = content.split("\n");
|
|
189
|
+
lines.push(...newLines);
|
|
143
190
|
} else if (metadata.type === "paratext") {
|
|
144
191
|
const reference = (0, import_utils.parseVerseReference)(`${metadata.id}:1`);
|
|
145
192
|
if (reference) {
|
|
146
193
|
const content = stripHTML(cell.value);
|
|
147
|
-
const
|
|
194
|
+
const lines2 = content.split("\n").reduce((prev, current) => {
|
|
148
195
|
if (prev.length === 0)
|
|
149
196
|
return [toHeading(current)];
|
|
150
197
|
else
|
|
@@ -156,7 +203,7 @@ class CodexParser {
|
|
|
156
203
|
toHeading(current)
|
|
157
204
|
];
|
|
158
205
|
}, []);
|
|
159
|
-
|
|
206
|
+
lines2.forEach(
|
|
160
207
|
(line) => addChapterContent(reference.chapter, [line])
|
|
161
208
|
);
|
|
162
209
|
} else {
|
|
@@ -174,6 +221,9 @@ class CodexParser {
|
|
|
174
221
|
}
|
|
175
222
|
}
|
|
176
223
|
}
|
|
224
|
+
if (previousReference) {
|
|
225
|
+
addReference(previousReference, addLineBreaks(lines));
|
|
226
|
+
}
|
|
177
227
|
for (let chapter of chapters.values()) {
|
|
178
228
|
root.content.push(chapter);
|
|
179
229
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../parser/codex-parser.ts"],
|
|
4
|
-
"sourcesContent": ["import { z } from 'zod';\nimport {\n Chapter,\n ChapterContent,\n ParseTree,\n Verse,\n VerseContent,\n} from './types.js';\nimport { parseVerseReference, VerseRef } from '../utils.js';\n\nexport const chapterHeadingSchema = z.object({\n type: z.literal('chapter-heading'),\n data: z.object({\n chapter: z.coerce.number().int(),\n }),\n});\n\nexport const verseSchema = z.object({\n type: z.literal('text'),\n id: z.string(),\n});\n\nexport const paratextSchema = z.object({\n type: z.literal('paratext'),\n id: z.string(),\n});\n\nexport const metadataSchema = z.discriminatedUnion('type', [\n chapterHeadingSchema,\n verseSchema,\n paratextSchema,\n]);\n\nexport const codexSchema = z.object({\n cells: z.array(\n z.object({\n kind: z.number(),\n languageId: z.string(),\n value: z.string(),\n metadata: z\n .object({\n type: z.string(),\n })\n .passthrough()\n .nullable()\n .optional(),\n })\n ),\n});\n\n/**\n * Defines a parser for codex files.\n */\nexport class CodexParser {\n // TODO:\n // /**\n // * Whether to preserve markdown in the parsed content.\n // */\n // preserveMarkdown: boolean = true;\n\n private _noteCounter: number = 0;\n\n /**\n * Parses the specified codex content.\n *\n * @param codex The codex content to parse.\n * @returns The parse tree that was generated.\n */\n public parse(codex: string): ParseTree {\n const json = JSON.parse(codex);\n const data = codexSchema.parse(json);\n\n let root: ParseTree = {\n type: 'root',\n content: [],\n };\n\n let chapters: Map<number, Chapter> = new Map();\n let lastChapter: Chapter | null = null;\n\n function addChapterContent(\n chapterNumber: number,\n content: ChapterContent[]\n ) {\n let chapter = chapters.get(chapterNumber);\n if (!chapter) {\n chapter = {\n type: 'chapter',\n number: chapterNumber,\n content: [],\n footnotes: [],\n };\n lastChapter = chapter;\n chapters.set(chapterNumber, chapter);\n }\n\n chapter.content.push(...content);\n }\n\n function addReference(ref: VerseRef, content: Verse['content']) {\n addChapterContent(ref.chapter, [\n {\n type: 'verse',\n number: ref.verse,\n content: content,\n },\n ]);\n }\n\n function stripHTML(value: string) {\n return value.replace(/<[^>]*>/g, '');\n }\n\n function toHeading(content: string) {\n return {\n type: 'heading',\n content: [content],\n } satisfies ChapterContent;\n }\n\n for (let cell of data.cells) {\n if (cell.languageId === 'html' && cell.value) {\n if (!cell.metadata) continue; // ignore html cells without metadata\n\n const metadataResult = metadataSchema.safeParse(cell.metadata);\n\n if (!metadataResult.success) continue; // ignore cells with invalid/unknown metadata\n const metadata = metadataResult.data;\n if (metadata.type === 'text') {\n
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,iBAAkB;AAQlB,
|
|
6
|
-
"names": []
|
|
4
|
+
"sourcesContent": ["import { z } from 'zod';\nimport {\n Chapter,\n ChapterContent,\n ParseTree,\n Verse,\n VerseContent,\n} from './types.js';\nimport { getBookId, parseVerseReference, VerseRef } from '../utils.js';\nimport { ref } from 'process';\n\nexport const chapterHeadingSchema = z.object({\n type: z.literal('chapter-heading'),\n data: z.object({\n chapter: z.coerce.number().int(),\n }),\n});\n\nexport const verseSchema = z.object({\n type: z.literal('text'),\n id: z.string(),\n bookCode: z.string().optional(),\n chapter: z.number().optional(),\n verse: z.number().optional(),\n});\n\nexport const paratextSchema = z.object({\n type: z.literal('paratext'),\n id: z.string(),\n});\n\nexport const metadataSchema = z.discriminatedUnion('type', [\n chapterHeadingSchema,\n verseSchema,\n paratextSchema,\n]);\n\nexport const codexSchema = z.object({\n cells: z.array(\n z.object({\n kind: z.number(),\n languageId: z.string(),\n value: z.string(),\n metadata: z\n .object({\n type: z.string(),\n })\n .passthrough()\n .nullable()\n .optional(),\n })\n ),\n});\n\n/**\n * Defines a parser for codex files.\n */\nexport class CodexParser {\n // TODO:\n // /**\n // * Whether to preserve markdown in the parsed content.\n // */\n // preserveMarkdown: boolean = true;\n\n private _noteCounter: number = 0;\n\n /**\n * Parses the specified codex content.\n *\n * @param codex The codex content to parse.\n * @returns The parse tree that was generated.\n */\n public parse(codex: string): ParseTree {\n const json = JSON.parse(codex);\n const data = codexSchema.parse(json);\n\n let root: ParseTree = {\n type: 'root',\n content: [],\n };\n\n let chapters: Map<number, Chapter> = new Map();\n let lastChapter: Chapter | null = null;\n\n function addChapterContent(\n chapterNumber: number,\n content: ChapterContent[]\n ) {\n let chapter = chapters.get(chapterNumber);\n if (!chapter) {\n chapter = {\n type: 'chapter',\n number: chapterNumber,\n content: [],\n footnotes: [],\n };\n lastChapter = chapter;\n chapters.set(chapterNumber, chapter);\n }\n\n chapter.content.push(...content);\n }\n\n function addReference(ref: VerseRef, content: Verse['content']) {\n addChapterContent(ref.chapter, [\n {\n type: 'verse',\n number: ref.verse,\n content: content,\n },\n ]);\n }\n\n function stripHTML(value: string) {\n return value.replace(/<[^>]*>/g, '');\n }\n\n function toHeading(content: string) {\n return {\n type: 'heading',\n content: [content],\n } satisfies ChapterContent;\n }\n\n function addLineBreaks(lines: Verse['content']) {\n return lines.reduce(\n (prev, current) => {\n if (prev.length === 0) return [current];\n else\n return [\n ...prev,\n {\n lineBreak: true,\n },\n current,\n ] satisfies Verse['content'];\n },\n [] as Verse['content']\n );\n }\n\n let previousReference: VerseRef | null = null;\n let lines: Verse['content'] = [];\n\n for (let cell of data.cells) {\n if (cell.languageId === 'html' && cell.value) {\n if (!cell.metadata) continue; // ignore html cells without metadata\n\n const metadataResult = metadataSchema.safeParse(cell.metadata);\n\n if (!metadataResult.success) continue; // ignore cells with invalid/unknown metadata\n const metadata = metadataResult.data;\n if (metadata.type === 'text') {\n let reference = parseVerseReference(metadata.id);\n if (!reference) {\n if (metadata.bookCode && metadata.chapter) {\n const bookId = getBookId(metadata.bookCode);\n if (!bookId) {\n throw new Error(\n 'Could not find book ID for code: ' +\n metadata.bookCode\n );\n }\n\n if (metadata.verse) {\n reference = {\n book: bookId,\n chapter: metadata.chapter,\n verse: metadata.verse,\n };\n } else if (previousReference?.verse) {\n if (\n previousReference.chapter !==\n metadata.chapter ||\n previousReference.book !== bookId\n ) {\n throw new Error(\n 'Cannot infer verse number for non-consecutive verse reference.'\n );\n }\n\n // Sometimes codex doesn't include verse numbers for every cell, so we infer it from the previous reference\n reference = {\n book: bookId,\n chapter: metadata.chapter,\n verse: previousReference.verse,\n };\n } else {\n throw new Error(\n 'Could not find verse reference in metadata.'\n );\n }\n } else {\n throw new Error(\n 'Could not find verse reference in metadata.'\n );\n }\n }\n\n if (\n previousReference &&\n (reference.book !== previousReference.book ||\n reference.chapter !== previousReference.chapter ||\n reference.verse !== previousReference.verse)\n ) {\n addReference(previousReference, addLineBreaks(lines));\n lines = [];\n }\n\n previousReference = reference;\n\n if (!root.id) root.id = reference.book; // set book id if not already set\n\n const content = stripHTML(cell.value);\n\n // add line breaks in heading if there are multiple lines\n const newLines = content.split('\\n');\n\n lines.push(...newLines);\n } else if (metadata.type === 'paratext') {\n const reference = parseVerseReference(`${metadata.id}:1`); // chapter headings do not have a verse reference always default to 1\n if (reference) {\n const content = stripHTML(cell.value);\n\n // add line breaks in heading if there are multiple lines\n const lines = content\n .split('\\n')\n .reduce<ChapterContent[]>((prev, current) => {\n if (prev.length === 0)\n return [toHeading(current)];\n else\n return [\n ...prev,\n {\n type: 'line_break',\n },\n toHeading(current),\n ] satisfies ChapterContent[];\n }, []);\n\n lines.forEach((line) =>\n addChapterContent(reference.chapter, [line])\n );\n } else {\n // parse paratext that isn't a chapter reference as footnote\n const content = stripHTML(cell.value);\n if (!cell.metadata) {\n if (lastChapter) {\n (lastChapter as Chapter).footnotes.push({\n noteId: this._noteCounter++,\n text: content,\n caller: null,\n });\n }\n }\n }\n }\n }\n }\n\n if (previousReference) {\n addReference(previousReference, addLineBreaks(lines));\n }\n\n for (let chapter of chapters.values()) {\n root.content.push(chapter);\n }\n\n return root;\n }\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,iBAAkB;AAQlB,mBAAyD;AAGlD,MAAM,uBAAuB,aAAE,OAAO;AAAA,EACzC,MAAM,aAAE,QAAQ,i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B,CAAC,MAAM,YAAY;AACzC,kBAAI,KAAK,WAAW;AAChB,uBAAO,CAAC,UAAU,OAAO,CAAC;AAAA;AAE1B,uBAAO;AAAA,kBACH,GAAG;AAAA,kBACH;AAAA,oBACI,MAAM;AAAA,kBACV;AAAA,kBACA,UAAU,OAAO;AAAA,gBACrB;AAAA,YACR,GAAG,CAAC,CAAC;AAET,YAAAA,OAAM;AAAA,cAAQ,CAAC,SACX,kBAAkB,UAAU,SAAS,CAAC,IAAI,CAAC;AAAA,YAC/C;AAAA,UACJ,OAAO;AAEH,kBAAM,UAAU,UAAU,KAAK,KAAK;AACpC,gBAAI,CAAC,KAAK,UAAU;AAChB,kBAAI,aAAa;AACb,gBAAC,YAAwB,UAAU,KAAK;AAAA,kBACpC,QAAQ,KAAK;AAAA,kBACb,MAAM;AAAA,kBACN,QAAQ;AAAA,gBACZ,CAAC;AAAA,cACL;AAAA,YACJ;AAAA,UACJ;AAAA,QACJ;AAAA,MACJ;AAAA,IACJ;AAEA,QAAI,mBAAmB;AACnB,mBAAa,mBAAmB,cAAc,KAAK,CAAC;AAAA,IACxD;AAEA,aAAS,WAAW,SAAS,OAAO,GAAG;AACnC,WAAK,QAAQ,KAAK,OAAO;AAAA,IAC7B;AAEA,WAAO;AAAA,EACX;AACJ;",
|
|
6
|
+
"names": ["ref", "lines"]
|
|
7
7
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
import { z } from "zod";
|
|
3
|
-
import { parseVerseReference } from "../utils.js";
|
|
3
|
+
import { getBookId, parseVerseReference } from "../utils.js";
|
|
4
4
|
export const chapterHeadingSchema = z.object({
|
|
5
5
|
type: z.literal("chapter-heading"),
|
|
6
6
|
data: z.object({
|
|
@@ -9,7 +9,10 @@ export const chapterHeadingSchema = z.object({
|
|
|
9
9
|
});
|
|
10
10
|
export const verseSchema = z.object({
|
|
11
11
|
type: z.literal("text"),
|
|
12
|
-
id: z.string()
|
|
12
|
+
id: z.string(),
|
|
13
|
+
bookCode: z.string().optional(),
|
|
14
|
+
chapter: z.number().optional(),
|
|
15
|
+
verse: z.number().optional()
|
|
13
16
|
});
|
|
14
17
|
export const paratextSchema = z.object({
|
|
15
18
|
type: z.literal("paratext"),
|
|
@@ -68,11 +71,11 @@ export class CodexParser {
|
|
|
68
71
|
}
|
|
69
72
|
chapter.content.push(...content);
|
|
70
73
|
}
|
|
71
|
-
function addReference(
|
|
72
|
-
addChapterContent(
|
|
74
|
+
function addReference(ref2, content) {
|
|
75
|
+
addChapterContent(ref2.chapter, [
|
|
73
76
|
{
|
|
74
77
|
type: "verse",
|
|
75
|
-
number:
|
|
78
|
+
number: ref2.verse,
|
|
76
79
|
content
|
|
77
80
|
}
|
|
78
81
|
]);
|
|
@@ -86,6 +89,24 @@ export class CodexParser {
|
|
|
86
89
|
content: [content]
|
|
87
90
|
};
|
|
88
91
|
}
|
|
92
|
+
function addLineBreaks(lines2) {
|
|
93
|
+
return lines2.reduce(
|
|
94
|
+
(prev, current) => {
|
|
95
|
+
if (prev.length === 0) return [current];
|
|
96
|
+
else
|
|
97
|
+
return [
|
|
98
|
+
...prev,
|
|
99
|
+
{
|
|
100
|
+
lineBreak: true
|
|
101
|
+
},
|
|
102
|
+
current
|
|
103
|
+
];
|
|
104
|
+
},
|
|
105
|
+
[]
|
|
106
|
+
);
|
|
107
|
+
}
|
|
108
|
+
let previousReference = null;
|
|
109
|
+
let lines = [];
|
|
89
110
|
for (let cell of data.cells) {
|
|
90
111
|
if (cell.languageId === "html" && cell.value) {
|
|
91
112
|
if (!cell.metadata) continue;
|
|
@@ -93,31 +114,57 @@ export class CodexParser {
|
|
|
93
114
|
if (!metadataResult.success) continue;
|
|
94
115
|
const metadata = metadataResult.data;
|
|
95
116
|
if (metadata.type === "text") {
|
|
96
|
-
|
|
97
|
-
if (!reference)
|
|
98
|
-
|
|
117
|
+
let reference = parseVerseReference(metadata.id);
|
|
118
|
+
if (!reference) {
|
|
119
|
+
if (metadata.bookCode && metadata.chapter) {
|
|
120
|
+
const bookId = getBookId(metadata.bookCode);
|
|
121
|
+
if (!bookId) {
|
|
122
|
+
throw new Error(
|
|
123
|
+
"Could not find book ID for code: " + metadata.bookCode
|
|
124
|
+
);
|
|
125
|
+
}
|
|
126
|
+
if (metadata.verse) {
|
|
127
|
+
reference = {
|
|
128
|
+
book: bookId,
|
|
129
|
+
chapter: metadata.chapter,
|
|
130
|
+
verse: metadata.verse
|
|
131
|
+
};
|
|
132
|
+
} else if (previousReference?.verse) {
|
|
133
|
+
if (previousReference.chapter !== metadata.chapter || previousReference.book !== bookId) {
|
|
134
|
+
throw new Error(
|
|
135
|
+
"Cannot infer verse number for non-consecutive verse reference."
|
|
136
|
+
);
|
|
137
|
+
}
|
|
138
|
+
reference = {
|
|
139
|
+
book: bookId,
|
|
140
|
+
chapter: metadata.chapter,
|
|
141
|
+
verse: previousReference.verse
|
|
142
|
+
};
|
|
143
|
+
} else {
|
|
144
|
+
throw new Error(
|
|
145
|
+
"Could not find verse reference in metadata."
|
|
146
|
+
);
|
|
147
|
+
}
|
|
148
|
+
} else {
|
|
149
|
+
throw new Error(
|
|
150
|
+
"Could not find verse reference in metadata."
|
|
151
|
+
);
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
if (previousReference && (reference.book !== previousReference.book || reference.chapter !== previousReference.chapter || reference.verse !== previousReference.verse)) {
|
|
155
|
+
addReference(previousReference, addLineBreaks(lines));
|
|
156
|
+
lines = [];
|
|
157
|
+
}
|
|
158
|
+
previousReference = reference;
|
|
99
159
|
if (!root.id) root.id = reference.book;
|
|
100
160
|
const content = stripHTML(cell.value);
|
|
101
|
-
const
|
|
102
|
-
|
|
103
|
-
if (prev.length === 0) return [current];
|
|
104
|
-
else
|
|
105
|
-
return [
|
|
106
|
-
...prev,
|
|
107
|
-
{
|
|
108
|
-
lineBreak: true
|
|
109
|
-
},
|
|
110
|
-
current
|
|
111
|
-
];
|
|
112
|
-
},
|
|
113
|
-
[]
|
|
114
|
-
);
|
|
115
|
-
addReference(reference, lines);
|
|
161
|
+
const newLines = content.split("\n");
|
|
162
|
+
lines.push(...newLines);
|
|
116
163
|
} else if (metadata.type === "paratext") {
|
|
117
164
|
const reference = parseVerseReference(`${metadata.id}:1`);
|
|
118
165
|
if (reference) {
|
|
119
166
|
const content = stripHTML(cell.value);
|
|
120
|
-
const
|
|
167
|
+
const lines2 = content.split("\n").reduce((prev, current) => {
|
|
121
168
|
if (prev.length === 0)
|
|
122
169
|
return [toHeading(current)];
|
|
123
170
|
else
|
|
@@ -129,7 +176,7 @@ export class CodexParser {
|
|
|
129
176
|
toHeading(current)
|
|
130
177
|
];
|
|
131
178
|
}, []);
|
|
132
|
-
|
|
179
|
+
lines2.forEach(
|
|
133
180
|
(line) => addChapterContent(reference.chapter, [line])
|
|
134
181
|
);
|
|
135
182
|
} else {
|
|
@@ -147,6 +194,9 @@ export class CodexParser {
|
|
|
147
194
|
}
|
|
148
195
|
}
|
|
149
196
|
}
|
|
197
|
+
if (previousReference) {
|
|
198
|
+
addReference(previousReference, addLineBreaks(lines));
|
|
199
|
+
}
|
|
150
200
|
for (let chapter of chapters.values()) {
|
|
151
201
|
root.content.push(chapter);
|
|
152
202
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../parser/codex-parser.ts"],
|
|
4
|
-
"sourcesContent": ["import { z } from 'zod';\nimport {\n Chapter,\n ChapterContent,\n ParseTree,\n Verse,\n VerseContent,\n} from './types.js';\nimport { parseVerseReference, VerseRef } from '../utils.js';\n\nexport const chapterHeadingSchema = z.object({\n type: z.literal('chapter-heading'),\n data: z.object({\n chapter: z.coerce.number().int(),\n }),\n});\n\nexport const verseSchema = z.object({\n type: z.literal('text'),\n id: z.string(),\n});\n\nexport const paratextSchema = z.object({\n type: z.literal('paratext'),\n id: z.string(),\n});\n\nexport const metadataSchema = z.discriminatedUnion('type', [\n chapterHeadingSchema,\n verseSchema,\n paratextSchema,\n]);\n\nexport const codexSchema = z.object({\n cells: z.array(\n z.object({\n kind: z.number(),\n languageId: z.string(),\n value: z.string(),\n metadata: z\n .object({\n type: z.string(),\n })\n .passthrough()\n .nullable()\n .optional(),\n })\n ),\n});\n\n/**\n * Defines a parser for codex files.\n */\nexport class CodexParser {\n // TODO:\n // /**\n // * Whether to preserve markdown in the parsed content.\n // */\n // preserveMarkdown: boolean = true;\n\n private _noteCounter: number = 0;\n\n /**\n * Parses the specified codex content.\n *\n * @param codex The codex content to parse.\n * @returns The parse tree that was generated.\n */\n public parse(codex: string): ParseTree {\n const json = JSON.parse(codex);\n const data = codexSchema.parse(json);\n\n let root: ParseTree = {\n type: 'root',\n content: [],\n };\n\n let chapters: Map<number, Chapter> = new Map();\n let lastChapter: Chapter | null = null;\n\n function addChapterContent(\n chapterNumber: number,\n content: ChapterContent[]\n ) {\n let chapter = chapters.get(chapterNumber);\n if (!chapter) {\n chapter = {\n type: 'chapter',\n number: chapterNumber,\n content: [],\n footnotes: [],\n };\n lastChapter = chapter;\n chapters.set(chapterNumber, chapter);\n }\n\n chapter.content.push(...content);\n }\n\n function addReference(ref: VerseRef, content: Verse['content']) {\n addChapterContent(ref.chapter, [\n {\n type: 'verse',\n number: ref.verse,\n content: content,\n },\n ]);\n }\n\n function stripHTML(value: string) {\n return value.replace(/<[^>]*>/g, '');\n }\n\n function toHeading(content: string) {\n return {\n type: 'heading',\n content: [content],\n } satisfies ChapterContent;\n }\n\n for (let cell of data.cells) {\n if (cell.languageId === 'html' && cell.value) {\n if (!cell.metadata) continue; // ignore html cells without metadata\n\n const metadataResult = metadataSchema.safeParse(cell.metadata);\n\n if (!metadataResult.success) continue; // ignore cells with invalid/unknown metadata\n const metadata = metadataResult.data;\n if (metadata.type === 'text') {\n
|
|
5
|
-
"mappings": ";AAAA,SAAS,SAAS;AAQlB,SAAS,2BAAqC;
|
|
6
|
-
"names": []
|
|
4
|
+
"sourcesContent": ["import { z } from 'zod';\nimport {\n Chapter,\n ChapterContent,\n ParseTree,\n Verse,\n VerseContent,\n} from './types.js';\nimport { getBookId, parseVerseReference, VerseRef } from '../utils.js';\nimport { ref } from 'process';\n\nexport const chapterHeadingSchema = z.object({\n type: z.literal('chapter-heading'),\n data: z.object({\n chapter: z.coerce.number().int(),\n }),\n});\n\nexport const verseSchema = z.object({\n type: z.literal('text'),\n id: z.string(),\n bookCode: z.string().optional(),\n chapter: z.number().optional(),\n verse: z.number().optional(),\n});\n\nexport const paratextSchema = z.object({\n type: z.literal('paratext'),\n id: z.string(),\n});\n\nexport const metadataSchema = z.discriminatedUnion('type', [\n chapterHeadingSchema,\n verseSchema,\n paratextSchema,\n]);\n\nexport const codexSchema = z.object({\n cells: z.array(\n z.object({\n kind: z.number(),\n languageId: z.string(),\n value: z.string(),\n metadata: z\n .object({\n type: z.string(),\n })\n .passthrough()\n .nullable()\n .optional(),\n })\n ),\n});\n\n/**\n * Defines a parser for codex files.\n */\nexport class CodexParser {\n // TODO:\n // /**\n // * Whether to preserve markdown in the parsed content.\n // */\n // preserveMarkdown: boolean = true;\n\n private _noteCounter: number = 0;\n\n /**\n * Parses the specified codex content.\n *\n * @param codex The codex content to parse.\n * @returns The parse tree that was generated.\n */\n public parse(codex: string): ParseTree {\n const json = JSON.parse(codex);\n const data = codexSchema.parse(json);\n\n let root: ParseTree = {\n type: 'root',\n content: [],\n };\n\n let chapters: Map<number, Chapter> = new Map();\n let lastChapter: Chapter | null = null;\n\n function addChapterContent(\n chapterNumber: number,\n content: ChapterContent[]\n ) {\n let chapter = chapters.get(chapterNumber);\n if (!chapter) {\n chapter = {\n type: 'chapter',\n number: chapterNumber,\n content: [],\n footnotes: [],\n };\n lastChapter = chapter;\n chapters.set(chapterNumber, chapter);\n }\n\n chapter.content.push(...content);\n }\n\n function addReference(ref: VerseRef, content: Verse['content']) {\n addChapterContent(ref.chapter, [\n {\n type: 'verse',\n number: ref.verse,\n content: content,\n },\n ]);\n }\n\n function stripHTML(value: string) {\n return value.replace(/<[^>]*>/g, '');\n }\n\n function toHeading(content: string) {\n return {\n type: 'heading',\n content: [content],\n } satisfies ChapterContent;\n }\n\n function addLineBreaks(lines: Verse['content']) {\n return lines.reduce(\n (prev, current) => {\n if (prev.length === 0) return [current];\n else\n return [\n ...prev,\n {\n lineBreak: true,\n },\n current,\n ] satisfies Verse['content'];\n },\n [] as Verse['content']\n );\n }\n\n let previousReference: VerseRef | null = null;\n let lines: Verse['content'] = [];\n\n for (let cell of data.cells) {\n if (cell.languageId === 'html' && cell.value) {\n if (!cell.metadata) continue; // ignore html cells without metadata\n\n const metadataResult = metadataSchema.safeParse(cell.metadata);\n\n if (!metadataResult.success) continue; // ignore cells with invalid/unknown metadata\n const metadata = metadataResult.data;\n if (metadata.type === 'text') {\n let reference = parseVerseReference(metadata.id);\n if (!reference) {\n if (metadata.bookCode && metadata.chapter) {\n const bookId = getBookId(metadata.bookCode);\n if (!bookId) {\n throw new Error(\n 'Could not find book ID for code: ' +\n metadata.bookCode\n );\n }\n\n if (metadata.verse) {\n reference = {\n book: bookId,\n chapter: metadata.chapter,\n verse: metadata.verse,\n };\n } else if (previousReference?.verse) {\n if (\n previousReference.chapter !==\n metadata.chapter ||\n previousReference.book !== bookId\n ) {\n throw new Error(\n 'Cannot infer verse number for non-consecutive verse reference.'\n );\n }\n\n // Sometimes codex doesn't include verse numbers for every cell, so we infer it from the previous reference\n reference = {\n book: bookId,\n chapter: metadata.chapter,\n verse: previousReference.verse,\n };\n } else {\n throw new Error(\n 'Could not find verse reference in metadata.'\n );\n }\n } else {\n throw new Error(\n 'Could not find verse reference in metadata.'\n );\n }\n }\n\n if (\n previousReference &&\n (reference.book !== previousReference.book ||\n reference.chapter !== previousReference.chapter ||\n reference.verse !== previousReference.verse)\n ) {\n addReference(previousReference, addLineBreaks(lines));\n lines = [];\n }\n\n previousReference = reference;\n\n if (!root.id) root.id = reference.book; // set book id if not already set\n\n const content = stripHTML(cell.value);\n\n // add line breaks in heading if there are multiple lines\n const newLines = content.split('\\n');\n\n lines.push(...newLines);\n } else if (metadata.type === 'paratext') {\n const reference = parseVerseReference(`${metadata.id}:1`); // chapter headings do not have a verse reference always default to 1\n if (reference) {\n const content = stripHTML(cell.value);\n\n // add line breaks in heading if there are multiple lines\n const lines = content\n .split('\\n')\n .reduce<ChapterContent[]>((prev, current) => {\n if (prev.length === 0)\n return [toHeading(current)];\n else\n return [\n ...prev,\n {\n type: 'line_break',\n },\n toHeading(current),\n ] satisfies ChapterContent[];\n }, []);\n\n lines.forEach((line) =>\n addChapterContent(reference.chapter, [line])\n );\n } else {\n // parse paratext that isn't a chapter reference as footnote\n const content = stripHTML(cell.value);\n if (!cell.metadata) {\n if (lastChapter) {\n (lastChapter as Chapter).footnotes.push({\n noteId: this._noteCounter++,\n text: content,\n caller: null,\n });\n }\n }\n }\n }\n }\n }\n\n if (previousReference) {\n addReference(previousReference, addLineBreaks(lines));\n }\n\n for (let chapter of chapters.values()) {\n root.content.push(chapter);\n }\n\n return root;\n }\n}\n"],
|
|
5
|
+
"mappings": ";AAAA,SAAS,SAAS;AAQlB,SAAS,WAAW,2BAAqC;AAGlD,aAAM,uBAAuB,EAAE,OAAO;AAAA,EACzC,MAAM,EAAE,QAAQ,iBAAiB;AAAA,EACjC,MAAM,EAAE,OAAO;AAAA,IACX,SAAS,EAAE,OAAO,OAAO,EAAE,IAAI;AAAA,EACnC,CAAC;AACL,CAAC;AAEM,aAAM,cAAc,EAAE,OAAO;AAAA,EAChC,MAAM,EAAE,QAAQ,MAAM;AAAA,EACtB,IAAI,EAAE,OAAO;AAAA,EACb,UAAU,EAAE,OAAO,EAAE,SAAS;AAAA,EAC9B,SAAS,EAAE,OAAO,EAAE,SAAS;AAAA,EAC7B,OAAO,EAAE,OAAO,EAAE,SAAS;AAC/B,CAAC;AAEM,aAAM,iBAAiB,EAAE,OAAO;AAAA,EACnC,MAAM,EAAE,QAAQ,UAAU;AAAA,EAC1B,IAAI,EAAE,OAAO;AACjB,CAAC;AAEM,aAAM,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,KAAK;AAAA,kBACb,MAAM;AAAA,kBACN,QAAQ;AAAA,gBACZ,CAAC;AAAA,cACL;AAAA,YACJ;AAAA,UACJ;AAAA,QACJ;AAAA,MACJ;AAAA,IACJ;AAEA,QAAI,mBAAmB;AACnB,mBAAa,mBAAmB,cAAc,KAAK,CAAC;AAAA,IACxD;AAEA,aAAS,WAAW,SAAS,OAAO,GAAG;AACnC,WAAK,QAAQ,KAAK,OAAO;AAAA,IAC7B;AAEA,WAAO;AAAA,EACX;AACJ;",
|
|
6
|
+
"names": ["ref", "lines"]
|
|
7
7
|
}
|
|
@@ -23,12 +23,21 @@ export declare const chapterHeadingSchema: z.ZodObject<{
|
|
|
23
23
|
export declare const verseSchema: z.ZodObject<{
|
|
24
24
|
type: z.ZodLiteral<"text">;
|
|
25
25
|
id: z.ZodString;
|
|
26
|
+
bookCode: z.ZodOptional<z.ZodString>;
|
|
27
|
+
chapter: z.ZodOptional<z.ZodNumber>;
|
|
28
|
+
verse: z.ZodOptional<z.ZodNumber>;
|
|
26
29
|
}, "strip", z.ZodTypeAny, {
|
|
27
30
|
id: string;
|
|
28
31
|
type: "text";
|
|
32
|
+
chapter?: number | undefined;
|
|
33
|
+
verse?: number | undefined;
|
|
34
|
+
bookCode?: string | undefined;
|
|
29
35
|
}, {
|
|
30
36
|
id: string;
|
|
31
37
|
type: "text";
|
|
38
|
+
chapter?: number | undefined;
|
|
39
|
+
verse?: number | undefined;
|
|
40
|
+
bookCode?: string | undefined;
|
|
32
41
|
}>;
|
|
33
42
|
export declare const paratextSchema: z.ZodObject<{
|
|
34
43
|
type: z.ZodLiteral<"paratext">;
|
|
@@ -62,12 +71,21 @@ export declare const metadataSchema: z.ZodDiscriminatedUnion<"type", [z.ZodObjec
|
|
|
62
71
|
}>, z.ZodObject<{
|
|
63
72
|
type: z.ZodLiteral<"text">;
|
|
64
73
|
id: z.ZodString;
|
|
74
|
+
bookCode: z.ZodOptional<z.ZodString>;
|
|
75
|
+
chapter: z.ZodOptional<z.ZodNumber>;
|
|
76
|
+
verse: z.ZodOptional<z.ZodNumber>;
|
|
65
77
|
}, "strip", z.ZodTypeAny, {
|
|
66
78
|
id: string;
|
|
67
79
|
type: "text";
|
|
80
|
+
chapter?: number | undefined;
|
|
81
|
+
verse?: number | undefined;
|
|
82
|
+
bookCode?: string | undefined;
|
|
68
83
|
}, {
|
|
69
84
|
id: string;
|
|
70
85
|
type: "text";
|
|
86
|
+
chapter?: number | undefined;
|
|
87
|
+
verse?: number | undefined;
|
|
88
|
+
bookCode?: string | undefined;
|
|
71
89
|
}>, z.ZodObject<{
|
|
72
90
|
type: z.ZodLiteral<"paratext">;
|
|
73
91
|
id: z.ZodString;
|