@storyteller-platform/align 0.1.53 → 0.1.55
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/align/align.cjs +12 -8
- package/dist/align/align.d.cts +1 -1
- package/dist/align/align.d.ts +1 -1
- package/dist/align/align.js +19 -9
- package/dist/align/getSentenceRanges.cjs +3 -2
- package/dist/align/getSentenceRanges.d.cts +1 -1
- package/dist/align/getSentenceRanges.d.ts +1 -1
- package/dist/align/getSentenceRanges.js +3 -2
- package/dist/align/interpolateSentenceRanges.d.cts +1 -1
- package/dist/align/interpolateSentenceRanges.d.ts +1 -1
- package/dist/align/slugify.d.cts +2 -2
- package/dist/align/slugify.d.ts +2 -2
- package/dist/common/shell.cjs +1 -1
- package/dist/common/shell.js +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/markup/markup.cjs +11 -4
- package/dist/markup/markup.js +11 -4
- package/dist/markup/model.cjs +12 -0
- package/dist/markup/model.d.cts +1 -1
- package/dist/markup/model.d.ts +1 -1
- package/dist/markup/model.js +9 -0
- package/dist/markup/parseDom.cjs +9 -0
- package/dist/markup/parseDom.d.cts +1 -1
- package/dist/markup/parseDom.d.ts +1 -1
- package/dist/markup/parseDom.js +12 -0
- package/dist/markup/resolvedPos.d.cts +1 -1
- package/dist/markup/resolvedPos.d.ts +1 -1
- package/dist/markup/serializeDom.d.cts +1 -1
- package/dist/markup/serializeDom.d.ts +1 -1
- package/dist/markup/transform.cjs +23 -45
- package/dist/markup/transform.d.cts +2 -2
- package/dist/markup/transform.d.ts +2 -2
- package/dist/markup/transform.js +23 -43
- package/dist/{model-Bv3yPEdd.d.cts → model-CZ2mMHJO.d.cts} +7 -1
- package/dist/{model-Bv3yPEdd.d.ts → model-CZ2mMHJO.d.ts} +7 -1
- package/dist/readium/manifest.cjs +1 -1
- package/dist/readium/manifest.js +1 -1
- package/dist/snapshot/snapshot.cjs +6 -4
- package/dist/snapshot/snapshot.d.cts +1 -1
- package/dist/snapshot/snapshot.d.ts +1 -1
- package/dist/snapshot/snapshot.js +6 -4
- package/package.json +5 -4
- package/dist/markup/map.cjs +0 -261
- package/dist/markup/map.d.cts +0 -50
- package/dist/markup/map.d.ts +0 -50
- package/dist/markup/map.js +0 -236
package/dist/align/align.cjs
CHANGED
|
@@ -108,16 +108,19 @@ async function align(input, output, transcriptionsDir, audiobookDir, options) {
|
|
|
108
108
|
const epubPath = outFormat === "epub" ? (0, import_node_path.join)(
|
|
109
109
|
(0, import_node_os.tmpdir)(),
|
|
110
110
|
`storyteller-platform-align-${(0, import_node_crypto.randomUUID)()}`,
|
|
111
|
-
(0,
|
|
111
|
+
(0, import_node_path.basename)(output)
|
|
112
112
|
) : input;
|
|
113
113
|
const stack = __using(_stack2, new DisposableStack());
|
|
114
114
|
stack.defer(() => {
|
|
115
115
|
if (outFormat === "epub") {
|
|
116
|
-
|
|
116
|
+
try {
|
|
117
|
+
(0, import_node_fs.rmSync)((0, import_node_path.dirname)(epubPath), { recursive: true, force: true });
|
|
118
|
+
} catch {
|
|
119
|
+
}
|
|
117
120
|
}
|
|
118
121
|
});
|
|
119
122
|
if (outFormat === "epub") {
|
|
120
|
-
await (0, import_promises.mkdir)((0,
|
|
123
|
+
await (0, import_promises.mkdir)((0, import_node_path.dirname)(epubPath), { recursive: true });
|
|
121
124
|
await (0, import_promises.copyFile)(input, epubPath);
|
|
122
125
|
}
|
|
123
126
|
const audiobookFiles = await (0, import_promises.readdir)(audiobookDir).then(
|
|
@@ -157,7 +160,7 @@ async function align(input, output, transcriptionsDir, audiobookDir, options) {
|
|
|
157
160
|
const timing = await aligner.alignBook(options.onProgress);
|
|
158
161
|
if (outFormat === "epub") {
|
|
159
162
|
await epub.saveAndClose();
|
|
160
|
-
await (0, import_promises.mkdir)((0,
|
|
163
|
+
await (0, import_promises.mkdir)((0, import_node_path.dirname)(output), { recursive: true });
|
|
161
164
|
await (0, import_promises.copyFile)(epubPath, output);
|
|
162
165
|
} else {
|
|
163
166
|
var _stack = [];
|
|
@@ -165,7 +168,7 @@ async function align(input, output, transcriptionsDir, audiobookDir, options) {
|
|
|
165
168
|
const guidedNavigationDocuments = await (0, import_guidedNavigation.generateGuidedNavigationDocuments)(epub);
|
|
166
169
|
const manifest = (0, import_guidedNavigation.generateGuidedNavigationManifest)(
|
|
167
170
|
new import_shared.LocalizedString(
|
|
168
|
-
await epub.getTitle() ?? (0,
|
|
171
|
+
await epub.getTitle() ?? (0, import_node_path.basename)(input, (0, import_node_path.extname)(input))
|
|
169
172
|
),
|
|
170
173
|
guidedNavigationDocuments
|
|
171
174
|
);
|
|
@@ -358,7 +361,7 @@ class Aligner {
|
|
|
358
361
|
);
|
|
359
362
|
await Promise.all(
|
|
360
363
|
audiofiles.map(async (audiofile) => {
|
|
361
|
-
const { name, base } = (0,
|
|
364
|
+
const { name, base } = (0, import_node_path.parse)(audiofile);
|
|
362
365
|
const id = `audio_${name}`;
|
|
363
366
|
const manifest = await this.epub.getManifest();
|
|
364
367
|
if (id in manifest) return;
|
|
@@ -430,8 +433,9 @@ class Aligner {
|
|
|
430
433
|
},
|
|
431
434
|
[]
|
|
432
435
|
);
|
|
433
|
-
const
|
|
434
|
-
const
|
|
436
|
+
const cursor = mapping.invert().cursor();
|
|
437
|
+
const mappedTranscriptionOffset = cursor.map(transcriptionOffset);
|
|
438
|
+
const mappedEndTranscriptionOffset = cursor.map(endTranscriptionOffset);
|
|
435
439
|
this.report.chapters.push({
|
|
436
440
|
href: chapter.href,
|
|
437
441
|
transcriptionOffset: mappedTranscriptionOffset,
|
package/dist/align/align.d.cts
CHANGED
|
@@ -4,7 +4,7 @@ import { Epub } from '@storyteller-platform/epub';
|
|
|
4
4
|
import { RecognitionResult } from '@storyteller-platform/ghost-story/recognition';
|
|
5
5
|
import { StorytellerTranscription } from './getSentenceRanges.cjs';
|
|
6
6
|
import '@echogarden/text-segmentation';
|
|
7
|
-
import '@storyteller-platform/
|
|
7
|
+
import '@storyteller-platform/mapping';
|
|
8
8
|
|
|
9
9
|
interface AudioFileContext {
|
|
10
10
|
start: number;
|
package/dist/align/align.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ import { Epub } from '@storyteller-platform/epub';
|
|
|
4
4
|
import { RecognitionResult } from '@storyteller-platform/ghost-story/recognition';
|
|
5
5
|
import { StorytellerTranscription } from './getSentenceRanges.js';
|
|
6
6
|
import '@echogarden/text-segmentation';
|
|
7
|
-
import '@storyteller-platform/
|
|
7
|
+
import '@storyteller-platform/mapping';
|
|
8
8
|
|
|
9
9
|
interface AudioFileContext {
|
|
10
10
|
start: number;
|
package/dist/align/align.js
CHANGED
|
@@ -14,7 +14,13 @@ import {
|
|
|
14
14
|
writeFile
|
|
15
15
|
} from "node:fs/promises";
|
|
16
16
|
import { tmpdir } from "node:os";
|
|
17
|
-
import {
|
|
17
|
+
import {
|
|
18
|
+
basename as autoBasename,
|
|
19
|
+
dirname as autoDirname,
|
|
20
|
+
extname,
|
|
21
|
+
join as autoJoin,
|
|
22
|
+
parse as autoParse
|
|
23
|
+
} from "node:path";
|
|
18
24
|
import { basename, dirname, parse, relative } from "node:path/posix";
|
|
19
25
|
import { LocalizedString } from "@readium/shared";
|
|
20
26
|
import { enumerate, max } from "itertools";
|
|
@@ -57,16 +63,19 @@ async function align(input, output, transcriptionsDir, audiobookDir, options) {
|
|
|
57
63
|
const epubPath = outFormat === "epub" ? autoJoin(
|
|
58
64
|
tmpdir(),
|
|
59
65
|
`storyteller-platform-align-${randomUUID()}`,
|
|
60
|
-
|
|
66
|
+
autoBasename(output)
|
|
61
67
|
) : input;
|
|
62
68
|
const stack = __using(_stack2, new DisposableStack());
|
|
63
69
|
stack.defer(() => {
|
|
64
70
|
if (outFormat === "epub") {
|
|
65
|
-
|
|
71
|
+
try {
|
|
72
|
+
rmSync(autoDirname(epubPath), { recursive: true, force: true });
|
|
73
|
+
} catch {
|
|
74
|
+
}
|
|
66
75
|
}
|
|
67
76
|
});
|
|
68
77
|
if (outFormat === "epub") {
|
|
69
|
-
await mkdir(
|
|
78
|
+
await mkdir(autoDirname(epubPath), { recursive: true });
|
|
70
79
|
await copyFile(input, epubPath);
|
|
71
80
|
}
|
|
72
81
|
const audiobookFiles = await readdir(audiobookDir).then(
|
|
@@ -106,7 +115,7 @@ async function align(input, output, transcriptionsDir, audiobookDir, options) {
|
|
|
106
115
|
const timing = await aligner.alignBook(options.onProgress);
|
|
107
116
|
if (outFormat === "epub") {
|
|
108
117
|
await epub.saveAndClose();
|
|
109
|
-
await mkdir(
|
|
118
|
+
await mkdir(autoDirname(output), { recursive: true });
|
|
110
119
|
await copyFile(epubPath, output);
|
|
111
120
|
} else {
|
|
112
121
|
var _stack = [];
|
|
@@ -114,7 +123,7 @@ async function align(input, output, transcriptionsDir, audiobookDir, options) {
|
|
|
114
123
|
const guidedNavigationDocuments = await generateGuidedNavigationDocuments(epub);
|
|
115
124
|
const manifest = generateGuidedNavigationManifest(
|
|
116
125
|
new LocalizedString(
|
|
117
|
-
await epub.getTitle() ??
|
|
126
|
+
await epub.getTitle() ?? autoBasename(input, extname(input))
|
|
118
127
|
),
|
|
119
128
|
guidedNavigationDocuments
|
|
120
129
|
);
|
|
@@ -307,7 +316,7 @@ class Aligner {
|
|
|
307
316
|
);
|
|
308
317
|
await Promise.all(
|
|
309
318
|
audiofiles.map(async (audiofile) => {
|
|
310
|
-
const { name, base } =
|
|
319
|
+
const { name, base } = autoParse(audiofile);
|
|
311
320
|
const id = `audio_${name}`;
|
|
312
321
|
const manifest = await this.epub.getManifest();
|
|
313
322
|
if (id in manifest) return;
|
|
@@ -379,8 +388,9 @@ class Aligner {
|
|
|
379
388
|
},
|
|
380
389
|
[]
|
|
381
390
|
);
|
|
382
|
-
const
|
|
383
|
-
const
|
|
391
|
+
const cursor = mapping.invert().cursor();
|
|
392
|
+
const mappedTranscriptionOffset = cursor.map(transcriptionOffset);
|
|
393
|
+
const mappedEndTranscriptionOffset = cursor.map(endTranscriptionOffset);
|
|
384
394
|
this.report.chapters.push({
|
|
385
395
|
href: chapter.href,
|
|
386
396
|
transcriptionOffset: mappedTranscriptionOffset,
|
|
@@ -141,10 +141,11 @@ function errorAlignWithNarrowing(refSentences, hyp, narrowStart, narrowEnd) {
|
|
|
141
141
|
return { alignments, slice: [slice[0] + narrowed[0], slice[0] + narrowed[1]] };
|
|
142
142
|
}
|
|
143
143
|
function mapTranscriptionTimeline(transcription, mapping) {
|
|
144
|
+
const cursor = mapping.cursor();
|
|
144
145
|
return transcription.timeline.map((entry) => ({
|
|
145
146
|
...entry,
|
|
146
|
-
mappedStartOffsetUtf16:
|
|
147
|
-
mappedEndOffsetUtf16:
|
|
147
|
+
mappedStartOffsetUtf16: cursor.map(entry.startOffsetUtf16 ?? 0, "end"),
|
|
148
|
+
mappedEndOffsetUtf16: cursor.map(entry.endOffsetUtf16 ?? 0, "start")
|
|
148
149
|
}));
|
|
149
150
|
}
|
|
150
151
|
async function getSentenceRanges(transcriptionText, mappedTimeline, sentences, chapterId, chapterOffset, chapterEndOffset, granularity, locale) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as _storyteller_platform_ghost_story from '@storyteller-platform/ghost-story';
|
|
2
2
|
import { TimelineEntry } from '@storyteller-platform/ghost-story';
|
|
3
3
|
import { SegmentationResult } from '@echogarden/text-segmentation';
|
|
4
|
-
import { Mapping } from '@storyteller-platform/
|
|
4
|
+
import { Mapping } from '@storyteller-platform/mapping';
|
|
5
5
|
|
|
6
6
|
type StorytellerTimelineEntry = TimelineEntry & {
|
|
7
7
|
audiofile: string;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as _storyteller_platform_ghost_story from '@storyteller-platform/ghost-story';
|
|
2
2
|
import { TimelineEntry } from '@storyteller-platform/ghost-story';
|
|
3
3
|
import { SegmentationResult } from '@echogarden/text-segmentation';
|
|
4
|
-
import { Mapping } from '@storyteller-platform/
|
|
4
|
+
import { Mapping } from '@storyteller-platform/mapping';
|
|
5
5
|
|
|
6
6
|
type StorytellerTimelineEntry = TimelineEntry & {
|
|
7
7
|
audiofile: string;
|
|
@@ -114,10 +114,11 @@ function errorAlignWithNarrowing(refSentences, hyp, narrowStart, narrowEnd) {
|
|
|
114
114
|
return { alignments, slice: [slice[0] + narrowed[0], slice[0] + narrowed[1]] };
|
|
115
115
|
}
|
|
116
116
|
function mapTranscriptionTimeline(transcription, mapping) {
|
|
117
|
+
const cursor = mapping.cursor();
|
|
117
118
|
return transcription.timeline.map((entry) => ({
|
|
118
119
|
...entry,
|
|
119
|
-
mappedStartOffsetUtf16:
|
|
120
|
-
mappedEndOffsetUtf16:
|
|
120
|
+
mappedStartOffsetUtf16: cursor.map(entry.startOffsetUtf16 ?? 0, "end"),
|
|
121
|
+
mappedEndOffsetUtf16: cursor.map(entry.endOffsetUtf16 ?? 0, "start")
|
|
121
122
|
}));
|
|
122
123
|
}
|
|
123
124
|
async function getSentenceRanges(transcriptionText, mappedTimeline, sentences, chapterId, chapterOffset, chapterEndOffset, granularity, locale) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { SentenceRange } from './getSentenceRanges.cjs';
|
|
2
2
|
import '@storyteller-platform/ghost-story';
|
|
3
3
|
import '@echogarden/text-segmentation';
|
|
4
|
-
import '@storyteller-platform/
|
|
4
|
+
import '@storyteller-platform/mapping';
|
|
5
5
|
|
|
6
6
|
/** A "slot" is a sentence that needs to be synthesised. */
|
|
7
7
|
type Slot = {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { SentenceRange } from './getSentenceRanges.js';
|
|
2
2
|
import '@storyteller-platform/ghost-story';
|
|
3
3
|
import '@echogarden/text-segmentation';
|
|
4
|
-
import '@storyteller-platform/
|
|
4
|
+
import '@storyteller-platform/mapping';
|
|
5
5
|
|
|
6
6
|
/** A "slot" is a sentence that needs to be synthesised. */
|
|
7
7
|
type Slot = {
|
package/dist/align/slugify.d.cts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as _storyteller_platform_mapping from '@storyteller-platform/mapping';
|
|
2
2
|
|
|
3
3
|
declare function slugify(text: string, locale: Intl.Locale): Promise<{
|
|
4
4
|
result: string;
|
|
5
|
-
mapping:
|
|
5
|
+
mapping: _storyteller_platform_mapping.Mapping;
|
|
6
6
|
}>;
|
|
7
7
|
|
|
8
8
|
export { slugify };
|
package/dist/align/slugify.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as _storyteller_platform_mapping from '@storyteller-platform/mapping';
|
|
2
2
|
|
|
3
3
|
declare function slugify(text: string, locale: Intl.Locale): Promise<{
|
|
4
4
|
result: string;
|
|
5
|
-
mapping:
|
|
5
|
+
mapping: _storyteller_platform_mapping.Mapping;
|
|
6
6
|
}>;
|
|
7
7
|
|
|
8
8
|
export { slugify };
|
package/dist/common/shell.cjs
CHANGED
|
@@ -22,7 +22,7 @@ __export(shell_exports, {
|
|
|
22
22
|
});
|
|
23
23
|
module.exports = __toCommonJS(shell_exports);
|
|
24
24
|
function quotePath(path) {
|
|
25
|
-
return `"${path.replaceAll(/(["
|
|
25
|
+
return `"${path.replaceAll(/(["$`])/g, "\\$1")}"`;
|
|
26
26
|
}
|
|
27
27
|
// Annotate the CommonJS export names for ESM import in node:
|
|
28
28
|
0 && (module.exports = {
|
package/dist/common/shell.js
CHANGED
package/dist/index.d.cts
CHANGED
|
@@ -12,4 +12,4 @@ import '@storyteller-platform/epub';
|
|
|
12
12
|
import '@storyteller-platform/ghost-story/recognition';
|
|
13
13
|
import './align/getSentenceRanges.cjs';
|
|
14
14
|
import '@echogarden/text-segmentation';
|
|
15
|
-
import '@storyteller-platform/
|
|
15
|
+
import '@storyteller-platform/mapping';
|
package/dist/index.d.ts
CHANGED
|
@@ -12,4 +12,4 @@ import '@storyteller-platform/epub';
|
|
|
12
12
|
import '@storyteller-platform/ghost-story/recognition';
|
|
13
13
|
import './align/getSentenceRanges.js';
|
|
14
14
|
import '@echogarden/text-segmentation';
|
|
15
|
-
import '@storyteller-platform/
|
|
15
|
+
import '@storyteller-platform/mapping';
|
package/dist/markup/markup.cjs
CHANGED
|
@@ -128,6 +128,8 @@ async function markupChapter(chapterId, chapterXml, granularity, locale) {
|
|
|
128
128
|
const original = (0, import_parseDom.parseDom)(import_epub.Epub.getXmlChildren(body));
|
|
129
129
|
const inlined = (0, import_transform.inlineFootnotes)(original);
|
|
130
130
|
const lifted = (0, import_transform.liftText)(inlined.root);
|
|
131
|
+
const invertedLiftMapping = lifted.mapping.invert();
|
|
132
|
+
const cursor = invertedLiftMapping.cursor();
|
|
131
133
|
const segmentation = await (0, import_segmentation.segmentChapter)(lifted.result, {
|
|
132
134
|
primaryLocale: locale
|
|
133
135
|
});
|
|
@@ -137,26 +139,31 @@ async function markupChapter(chapterId, chapterXml, granularity, locale) {
|
|
|
137
139
|
let i = 0;
|
|
138
140
|
for (const sentence of segmentation) {
|
|
139
141
|
if (granularity === "word") {
|
|
142
|
+
const snapshot = cursor.value();
|
|
140
143
|
let j = 0;
|
|
141
144
|
let wordPos = pos;
|
|
142
145
|
for (const word of sentence.words.entries) {
|
|
143
146
|
if (!word.isPunctuation) {
|
|
144
147
|
root = (0, import_transform.addMark)(
|
|
145
148
|
root,
|
|
146
|
-
|
|
147
|
-
|
|
149
|
+
cursor.map(wordPos, "end"),
|
|
150
|
+
cursor.map(
|
|
151
|
+
wordPos + word.text.replace(/\n$/, "").length,
|
|
152
|
+
"start"
|
|
153
|
+
),
|
|
148
154
|
new import_model.Mark("span", { id: `${chapterId}-s${i}-w${j}` })
|
|
149
155
|
);
|
|
150
156
|
j++;
|
|
151
157
|
}
|
|
152
158
|
wordPos += word.text.replace(/\n$/, "").length;
|
|
153
159
|
}
|
|
160
|
+
cursor.reset(snapshot);
|
|
154
161
|
}
|
|
155
162
|
if (sentence.text.match(/\S/)) {
|
|
156
163
|
root = (0, import_transform.addMark)(
|
|
157
164
|
root,
|
|
158
|
-
|
|
159
|
-
|
|
165
|
+
cursor.map(pos, "end"),
|
|
166
|
+
cursor.map(pos + sentence.text.replace(/\n$/, "").length, "start"),
|
|
160
167
|
new import_model.Mark("span", { id: `${chapterId}-s${i}` })
|
|
161
168
|
);
|
|
162
169
|
i++;
|
package/dist/markup/markup.js
CHANGED
|
@@ -71,6 +71,8 @@ async function markupChapter(chapterId, chapterXml, granularity, locale) {
|
|
|
71
71
|
const original = parseDom(Epub.getXmlChildren(body));
|
|
72
72
|
const inlined = inlineFootnotes(original);
|
|
73
73
|
const lifted = liftText(inlined.root);
|
|
74
|
+
const invertedLiftMapping = lifted.mapping.invert();
|
|
75
|
+
const cursor = invertedLiftMapping.cursor();
|
|
74
76
|
const segmentation = await segmentChapter(lifted.result, {
|
|
75
77
|
primaryLocale: locale
|
|
76
78
|
});
|
|
@@ -80,26 +82,31 @@ async function markupChapter(chapterId, chapterXml, granularity, locale) {
|
|
|
80
82
|
let i = 0;
|
|
81
83
|
for (const sentence of segmentation) {
|
|
82
84
|
if (granularity === "word") {
|
|
85
|
+
const snapshot = cursor.value();
|
|
83
86
|
let j = 0;
|
|
84
87
|
let wordPos = pos;
|
|
85
88
|
for (const word of sentence.words.entries) {
|
|
86
89
|
if (!word.isPunctuation) {
|
|
87
90
|
root = addMark(
|
|
88
91
|
root,
|
|
89
|
-
|
|
90
|
-
|
|
92
|
+
cursor.map(wordPos, "end"),
|
|
93
|
+
cursor.map(
|
|
94
|
+
wordPos + word.text.replace(/\n$/, "").length,
|
|
95
|
+
"start"
|
|
96
|
+
),
|
|
91
97
|
new Mark("span", { id: `${chapterId}-s${i}-w${j}` })
|
|
92
98
|
);
|
|
93
99
|
j++;
|
|
94
100
|
}
|
|
95
101
|
wordPos += word.text.replace(/\n$/, "").length;
|
|
96
102
|
}
|
|
103
|
+
cursor.reset(snapshot);
|
|
97
104
|
}
|
|
98
105
|
if (sentence.text.match(/\S/)) {
|
|
99
106
|
root = addMark(
|
|
100
107
|
root,
|
|
101
|
-
|
|
102
|
-
|
|
108
|
+
cursor.map(pos, "end"),
|
|
109
|
+
cursor.map(pos + sentence.text.replace(/\n$/, "").length, "start"),
|
|
103
110
|
new Mark("span", { id: `${chapterId}-s${i}` })
|
|
104
111
|
);
|
|
105
112
|
i++;
|
package/dist/markup/model.cjs
CHANGED
|
@@ -23,6 +23,9 @@ __export(model_exports, {
|
|
|
23
23
|
Node: () => Node,
|
|
24
24
|
NoterefNode: () => NoterefNode,
|
|
25
25
|
Root: () => Root,
|
|
26
|
+
RubyNode: () => RubyNode,
|
|
27
|
+
RubyParenthesisNode: () => RubyParenthesisNode,
|
|
28
|
+
RubyTextNode: () => RubyTextNode,
|
|
26
29
|
TextNode: () => TextNode,
|
|
27
30
|
descendants: () => descendants
|
|
28
31
|
});
|
|
@@ -235,6 +238,12 @@ class NoterefNode extends Node {
|
|
|
235
238
|
}
|
|
236
239
|
class FootnoteNode extends Node {
|
|
237
240
|
}
|
|
241
|
+
class RubyParenthesisNode extends Node {
|
|
242
|
+
}
|
|
243
|
+
class RubyTextNode extends Node {
|
|
244
|
+
}
|
|
245
|
+
class RubyNode extends Node {
|
|
246
|
+
}
|
|
238
247
|
class Mark {
|
|
239
248
|
constructor(tagName, attrs = {}) {
|
|
240
249
|
this.tagName = tagName;
|
|
@@ -300,6 +309,9 @@ function descendants(node, cb, pos = 0) {
|
|
|
300
309
|
Node,
|
|
301
310
|
NoterefNode,
|
|
302
311
|
Root,
|
|
312
|
+
RubyNode,
|
|
313
|
+
RubyParenthesisNode,
|
|
314
|
+
RubyTextNode,
|
|
303
315
|
TextNode,
|
|
304
316
|
descendants
|
|
305
317
|
});
|
package/dist/markup/model.d.cts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import '@storyteller-platform/epub';
|
|
2
|
-
export { F as FootnoteNode, M as Mark, N as Node, b as NoterefNode, R as Root, T as TextNode,
|
|
2
|
+
export { F as FootnoteNode, M as Mark, N as Node, b as NoterefNode, R as Root, e as RubyNode, c as RubyParenthesisNode, d as RubyTextNode, T as TextNode, f as descendants } from '../model-CZ2mMHJO.cjs';
|
package/dist/markup/model.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import '@storyteller-platform/epub';
|
|
2
|
-
export { F as FootnoteNode, M as Mark, N as Node, b as NoterefNode, R as Root, T as TextNode,
|
|
2
|
+
export { F as FootnoteNode, M as Mark, N as Node, b as NoterefNode, R as Root, e as RubyNode, c as RubyParenthesisNode, d as RubyTextNode, T as TextNode, f as descendants } from '../model-CZ2mMHJO.js';
|
package/dist/markup/model.js
CHANGED
|
@@ -207,6 +207,12 @@ class NoterefNode extends Node {
|
|
|
207
207
|
}
|
|
208
208
|
class FootnoteNode extends Node {
|
|
209
209
|
}
|
|
210
|
+
class RubyParenthesisNode extends Node {
|
|
211
|
+
}
|
|
212
|
+
class RubyTextNode extends Node {
|
|
213
|
+
}
|
|
214
|
+
class RubyNode extends Node {
|
|
215
|
+
}
|
|
210
216
|
class Mark {
|
|
211
217
|
constructor(tagName, attrs = {}) {
|
|
212
218
|
this.tagName = tagName;
|
|
@@ -271,6 +277,9 @@ export {
|
|
|
271
277
|
Node,
|
|
272
278
|
NoterefNode,
|
|
273
279
|
Root,
|
|
280
|
+
RubyNode,
|
|
281
|
+
RubyParenthesisNode,
|
|
282
|
+
RubyTextNode,
|
|
274
283
|
TextNode,
|
|
275
284
|
descendants
|
|
276
285
|
};
|
package/dist/markup/parseDom.cjs
CHANGED
|
@@ -81,6 +81,15 @@ class Parser {
|
|
|
81
81
|
);
|
|
82
82
|
return footnoteNode;
|
|
83
83
|
}
|
|
84
|
+
if (tagName === "ruby") {
|
|
85
|
+
return new import_model.RubyNode(tagName, attrs, blockChildren, marks);
|
|
86
|
+
}
|
|
87
|
+
if (tagName === "rt") {
|
|
88
|
+
return new import_model.RubyTextNode(tagName, attrs, blockChildren, marks);
|
|
89
|
+
}
|
|
90
|
+
if (tagName === "rp") {
|
|
91
|
+
return new import_model.RubyParenthesisNode(tagName, attrs, blockChildren, marks);
|
|
92
|
+
}
|
|
84
93
|
if (import_semantics.BLOCKS.includes(tagName)) {
|
|
85
94
|
return new import_model.Node(tagName, attrs, blockChildren, marks);
|
|
86
95
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ParsedXml } from '@storyteller-platform/epub';
|
|
2
|
-
import { R as Root, N as Node } from '../model-
|
|
2
|
+
import { R as Root, N as Node } from '../model-CZ2mMHJO.cjs';
|
|
3
3
|
|
|
4
4
|
declare function parseDom(xml: ParsedXml): Root;
|
|
5
5
|
declare function findFootnotePairs(root: Root | Node): Map<number, number>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ParsedXml } from '@storyteller-platform/epub';
|
|
2
|
-
import { R as Root, N as Node } from '../model-
|
|
2
|
+
import { R as Root, N as Node } from '../model-CZ2mMHJO.js';
|
|
3
3
|
|
|
4
4
|
declare function parseDom(xml: ParsedXml): Root;
|
|
5
5
|
declare function findFootnotePairs(root: Root | Node): Map<number, number>;
|
package/dist/markup/parseDom.js
CHANGED
|
@@ -6,6 +6,9 @@ import {
|
|
|
6
6
|
Node,
|
|
7
7
|
NoterefNode,
|
|
8
8
|
Root,
|
|
9
|
+
RubyNode,
|
|
10
|
+
RubyParenthesisNode,
|
|
11
|
+
RubyTextNode,
|
|
9
12
|
TextNode,
|
|
10
13
|
descendants
|
|
11
14
|
} from "./model.js";
|
|
@@ -66,6 +69,15 @@ class Parser {
|
|
|
66
69
|
);
|
|
67
70
|
return footnoteNode;
|
|
68
71
|
}
|
|
72
|
+
if (tagName === "ruby") {
|
|
73
|
+
return new RubyNode(tagName, attrs, blockChildren, marks);
|
|
74
|
+
}
|
|
75
|
+
if (tagName === "rt") {
|
|
76
|
+
return new RubyTextNode(tagName, attrs, blockChildren, marks);
|
|
77
|
+
}
|
|
78
|
+
if (tagName === "rp") {
|
|
79
|
+
return new RubyParenthesisNode(tagName, attrs, blockChildren, marks);
|
|
80
|
+
}
|
|
69
81
|
if (BLOCKS.includes(tagName)) {
|
|
70
82
|
return new Node(tagName, attrs, blockChildren, marks);
|
|
71
83
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { a as ResolvedPos } from '../model-
|
|
1
|
+
export { a as ResolvedPos } from '../model-CZ2mMHJO.cjs';
|
|
2
2
|
import '@storyteller-platform/epub';
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { a as ResolvedPos } from '../model-
|
|
1
|
+
export { a as ResolvedPos } from '../model-CZ2mMHJO.js';
|
|
2
2
|
import '@storyteller-platform/epub';
|