proskomma-core 0.9.18 → 0.9.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/bundle.js +1 -0
- package/dist/index.cjs +1 -0
- package/dist/module.mjs +15888 -0
- package/package.json +23 -34
- package/dist/index.js +0 -8
- package/dist/index.js.LICENSE.txt +0 -23
- package/esm/package.json +0 -3
- package/esm/wrapper.mjs +0 -7
- package/informations/meeting_01_march_2023.md +0 -38
- package/src/graph/index.cjs +0 -201
- package/src/graph/lib/do_cv.cjs +0 -249
- package/src/graph/lib/dump.cjs +0 -40
- package/src/graph/lib/remake_blocks.cjs +0 -57
- package/src/graph/lib/sequence_chars.cjs +0 -84
- package/src/graph/lib/sort.cjs +0 -39
- package/src/graph/lib/tribos.cjs +0 -97
- package/src/graph/lib/tribos_expression.cjs +0 -556
- package/src/graph/lib/tribos_ohm_UNUSED.cjs +0 -37
- package/src/graph/lib/tribos_step.cjs +0 -434
- package/src/graph/mutations/add.cjs +0 -91
- package/src/graph/mutations/delete.cjs +0 -61
- package/src/graph/mutations/index.cjs +0 -54
- package/src/graph/mutations/rehash.cjs +0 -17
- package/src/graph/mutations/tags.cjs +0 -120
- package/src/graph/mutations/update.cjs +0 -210
- package/src/graph/mutations/versification.cjs +0 -96
- package/src/graph/queries/block.cjs +0 -228
- package/src/graph/queries/cIndex.cjs +0 -87
- package/src/graph/queries/cell.cjs +0 -42
- package/src/graph/queries/cv.cjs +0 -19
- package/src/graph/queries/cvBook.cjs +0 -16
- package/src/graph/queries/cvChapter.cjs +0 -16
- package/src/graph/queries/cvIndex.cjs +0 -47
- package/src/graph/queries/cvNavigation.cjs +0 -116
- package/src/graph/queries/cvVerseElement.cjs +0 -84
- package/src/graph/queries/cvVerses.cjs +0 -14
- package/src/graph/queries/doc_set.cjs +0 -220
- package/src/graph/queries/document.cjs +0 -555
- package/src/graph/queries/idParts.cjs +0 -30
- package/src/graph/queries/index.cjs +0 -151
- package/src/graph/queries/inputBlockSpec.cjs +0 -17
- package/src/graph/queries/inputItemObject.cjs +0 -12
- package/src/graph/queries/input_att_spec.cjs +0 -14
- package/src/graph/queries/input_key_matches.cjs +0 -11
- package/src/graph/queries/input_key_value.cjs +0 -11
- package/src/graph/queries/input_key_values.cjs +0 -11
- package/src/graph/queries/input_selector_spec.cjs +0 -19
- package/src/graph/queries/item.cjs +0 -71
- package/src/graph/queries/itemGroup.cjs +0 -75
- package/src/graph/queries/key_value.cjs +0 -18
- package/src/graph/queries/kv_entry.cjs +0 -21
- package/src/graph/queries/kv_sequence.cjs +0 -151
- package/src/graph/queries/node.cjs +0 -44
- package/src/graph/queries/orig.cjs +0 -11
- package/src/graph/queries/regex_index.cjs +0 -18
- package/src/graph/queries/row_equals_spec.cjs +0 -11
- package/src/graph/queries/row_match_spec.cjs +0 -11
- package/src/graph/queries/selector_spec.cjs +0 -29
- package/src/graph/queries/sequence.cjs +0 -314
- package/src/graph/queries/table_sequence.cjs +0 -192
- package/src/graph/queries/tree_sequence.cjs +0 -58
- package/src/graph/queries/verseNumber.cjs +0 -44
- package/src/graph/queries/verseRange.cjs +0 -11
- package/src/graph/queries/versification.cjs +0 -25
- package/src/index.cjs +0 -583
- package/src/model/doc_set.cjs +0 -389
- package/src/model/doc_set_helpers/block.cjs +0 -232
- package/src/model/doc_set_helpers/enum.cjs +0 -87
- package/src/model/doc_set_helpers/item.cjs +0 -198
- package/src/model/doc_set_helpers/rehash.cjs +0 -53
- package/src/model/doc_set_helpers/selectors.cjs +0 -58
- package/src/model/doc_set_helpers/serialize.cjs +0 -22
- package/src/model/doc_set_helpers/unsuccinctify.cjs +0 -288
- package/src/model/doc_set_helpers/update.cjs +0 -290
- package/src/model/document.cjs +0 -369
- package/src/model/document_helpers/blocks.cjs +0 -135
- package/src/model/document_helpers/chapter_verse.cjs +0 -291
- package/src/model/document_helpers/pre_enums.cjs +0 -67
- package/src/model/document_helpers/sequences.cjs +0 -205
- package/src/model/document_helpers/serialize_succinct.cjs +0 -55
- package/src/model/document_helpers/succinct_filter.cjs +0 -102
- package/src/model/versifications/eng_vrs.cjs +0 -455
- package/src/model/versifications/index.cjs +0 -38
- package/src/model/versifications/lxx_vrs.cjs +0 -950
- package/src/model/versifications/org_vrs.cjs +0 -155
- package/src/model/versifications/rsc_vrs.cjs +0 -342
- package/src/model/versifications/rso_vrs.cjs +0 -541
- package/src/model/versifications/vul_vrs.cjs +0 -835
- package/src/parser/index.cjs +0 -504
- package/src/parser/lexers/index.cjs +0 -11
- package/src/parser/lexers/lexingRegexes.cjs +0 -45
- package/src/parser/lexers/nodes.cjs +0 -123
- package/src/parser/lexers/object_for_fragment.cjs +0 -123
- package/src/parser/lexers/tsv.cjs +0 -45
- package/src/parser/lexers/usfm.cjs +0 -17
- package/src/parser/lexers/usx/index.cjs +0 -7
- package/src/parser/lexers/usx/usx_lexer.cjs +0 -321
- package/src/parser/lib/tokenize.cjs +0 -37
- package/src/parser/model/index.cjs +0 -637
- package/src/parser/parser_specs.cjs +0 -781
- package/src/pipelines/perf2x/index.cjs +0 -7
- package/src/pipelines/perf2x/perf2PkJsonPipeline.json +0 -41
- package/src/pipelines/perf2x/perf2usfmPipeline.json +0 -65
- package/src/transforms/calculateUsfmChapterPositions.cjs +0 -106
- package/src/transforms/index.cjs +0 -9
- package/src/transforms/perf2PkJson.cjs +0 -534
- package/src/transforms/perf2usfm.cjs +0 -294
- package/src/util/byteArray.cjs +0 -251
- package/src/util/canons.cjs +0 -117
- package/src/util/enums.cjs +0 -41
- package/src/util/generateId.cjs +0 -6
- package/src/util/graftDefs.cjs +0 -15
- package/src/util/index.cjs +0 -29
- package/src/util/inspectSuccinct.cjs +0 -59
- package/src/util/itemDefs.cjs +0 -33
- package/src/util/parserConstantDefs.cjs +0 -30
- package/src/util/scopeDefs.cjs +0 -173
- package/src/util/scriptlike/blocksSpec.cjs +0 -192
- package/src/util/scriptlike/dodson_lexicon.xsl +0 -19
- package/src/util/scriptlike/dodson_lexicon_to_entries.cjs +0 -85
- package/src/util/scriptlike/open_scriptures_hebrew_lexicon.xsl +0 -28
- package/src/util/scriptlike/open_scriptures_hebrew_lexicon_to_entries.cjs +0 -85
- package/src/util/succinct.cjs +0 -159
- package/src/util/tags.cjs +0 -28
- package/src/util/tokenDefs.cjs +0 -27
- package/src/util/versification.cjs +0 -364
|
@@ -1,534 +0,0 @@
|
|
|
1
|
-
const { PerfRenderFromJson } = require('proskomma-json-tools');
|
|
2
|
-
const xre = require('xregexp');
|
|
3
|
-
const { lexingRegexes } = require('../parser/lexers/lexingRegexes.cjs');
|
|
4
|
-
|
|
5
|
-
const wordLikeRegex = lexingRegexes.filter(r => r[1] === 'wordLike')[0][2];
|
|
6
|
-
const lineSpaceRegex = lexingRegexes.filter(r => r[1] === 'lineSpace')[0][2];
|
|
7
|
-
const punctuationRegex = lexingRegexes.filter(r => r[1] === 'punctuation')[0][2];
|
|
8
|
-
|
|
9
|
-
const closeAllOpenScopes = workspace => {
|
|
10
|
-
[...workspace.os]
|
|
11
|
-
.reverse()
|
|
12
|
-
.forEach(o => {
|
|
13
|
-
workspace.block.items.push({
|
|
14
|
-
type: 'scope',
|
|
15
|
-
subType: 'end',
|
|
16
|
-
payload: o,
|
|
17
|
-
},
|
|
18
|
-
);
|
|
19
|
-
},
|
|
20
|
-
);
|
|
21
|
-
workspace.os = [];
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
const closeParagraphScopes = workspace => {
|
|
25
|
-
[...workspace.os.filter(o => ['span'].includes(o.split('/')[1]))]
|
|
26
|
-
.reverse()
|
|
27
|
-
.forEach(o => {
|
|
28
|
-
workspace.block.items.push({
|
|
29
|
-
type: 'scope',
|
|
30
|
-
subType: 'end',
|
|
31
|
-
payload: o,
|
|
32
|
-
});
|
|
33
|
-
workspace.os = [...workspace.os.filter(wo => wo !== o)];
|
|
34
|
-
},
|
|
35
|
-
);
|
|
36
|
-
};
|
|
37
|
-
|
|
38
|
-
const closeVerseScopes = workspace => {
|
|
39
|
-
[...workspace.os.filter(o => ['verse', 'verses'].includes(o.split('/')[0]))]
|
|
40
|
-
.reverse()
|
|
41
|
-
.forEach(o => {
|
|
42
|
-
workspace.block.items.push({
|
|
43
|
-
type: 'scope',
|
|
44
|
-
subType: 'end',
|
|
45
|
-
payload: o,
|
|
46
|
-
});
|
|
47
|
-
workspace.os = [...workspace.os.filter(wo => wo !== o)];
|
|
48
|
-
},
|
|
49
|
-
);
|
|
50
|
-
};
|
|
51
|
-
|
|
52
|
-
const closeChapterScopes = workspace => {
|
|
53
|
-
[...workspace.os.filter(o => ['chapter'].includes(o.split('/')[0]))]
|
|
54
|
-
.reverse()
|
|
55
|
-
.forEach(o => {
|
|
56
|
-
workspace.block.items.push({
|
|
57
|
-
type: 'scope',
|
|
58
|
-
subType: 'end',
|
|
59
|
-
payload: o,
|
|
60
|
-
});
|
|
61
|
-
workspace.os = [...workspace.os.filter(wo => wo !== o)];
|
|
62
|
-
},
|
|
63
|
-
);
|
|
64
|
-
};
|
|
65
|
-
|
|
66
|
-
const perf2PkJsonActions = {
|
|
67
|
-
|
|
68
|
-
startDocument: [
|
|
69
|
-
{
|
|
70
|
-
description: 'Set up word object',
|
|
71
|
-
test: () => true,
|
|
72
|
-
action: ({
|
|
73
|
-
workspace,
|
|
74
|
-
output,
|
|
75
|
-
}) => {
|
|
76
|
-
output.pkJson = {};
|
|
77
|
-
workspace.sequenceId = null;
|
|
78
|
-
workspace.block = null;
|
|
79
|
-
workspace.os = [];
|
|
80
|
-
workspace.waitingBlockGrafts = [];
|
|
81
|
-
},
|
|
82
|
-
},
|
|
83
|
-
],
|
|
84
|
-
|
|
85
|
-
startSequence: [
|
|
86
|
-
{
|
|
87
|
-
description: 'Add sequence array to output',
|
|
88
|
-
test: () => true,
|
|
89
|
-
action: (environment) => {
|
|
90
|
-
environment.output.pkJson[environment.context.sequences[0].id] = [];
|
|
91
|
-
environment.workspace.sequenceId = environment.context.sequences[0].id;
|
|
92
|
-
},
|
|
93
|
-
},
|
|
94
|
-
],
|
|
95
|
-
|
|
96
|
-
endSequence: [
|
|
97
|
-
{
|
|
98
|
-
description: 'Reset sequenceId pointer',
|
|
99
|
-
test: () => true,
|
|
100
|
-
action: (environment) => {
|
|
101
|
-
closeAllOpenScopes(environment.workspace);
|
|
102
|
-
environment.workspace.sequenceId = environment.context.sequences[1]?.id;
|
|
103
|
-
},
|
|
104
|
-
},
|
|
105
|
-
],
|
|
106
|
-
|
|
107
|
-
unresolvedBlockGraft: [
|
|
108
|
-
{
|
|
109
|
-
description: 'Stash for next para',
|
|
110
|
-
test: () => true,
|
|
111
|
-
action: ({
|
|
112
|
-
context,
|
|
113
|
-
workspace,
|
|
114
|
-
}) => {
|
|
115
|
-
const target = context.sequences[0].block.target;
|
|
116
|
-
|
|
117
|
-
if (target) {
|
|
118
|
-
workspace.waitingBlockGrafts.push({
|
|
119
|
-
type: 'graft',
|
|
120
|
-
subType: context.sequences[0].block.subType,
|
|
121
|
-
payload: context.sequences[0].block.target,
|
|
122
|
-
});
|
|
123
|
-
}
|
|
124
|
-
},
|
|
125
|
-
},
|
|
126
|
-
],
|
|
127
|
-
|
|
128
|
-
unresolvedInlineGraft: [
|
|
129
|
-
{
|
|
130
|
-
description: 'Follow inline grafts',
|
|
131
|
-
test: () => true,
|
|
132
|
-
action: ({
|
|
133
|
-
context,
|
|
134
|
-
workspace,
|
|
135
|
-
}) => {
|
|
136
|
-
const target = context.sequences[0].element.target;
|
|
137
|
-
|
|
138
|
-
if (target) {
|
|
139
|
-
workspace.block.items.push({
|
|
140
|
-
type: 'graft',
|
|
141
|
-
subType: context.sequences[0].element.subType,
|
|
142
|
-
payload: context.sequences[0].element.target,
|
|
143
|
-
});
|
|
144
|
-
}
|
|
145
|
-
},
|
|
146
|
-
},
|
|
147
|
-
],
|
|
148
|
-
|
|
149
|
-
startParagraph: [
|
|
150
|
-
{
|
|
151
|
-
description: 'Add object for paragraph block',
|
|
152
|
-
test: () => true,
|
|
153
|
-
action: ({
|
|
154
|
-
context,
|
|
155
|
-
workspace,
|
|
156
|
-
output,
|
|
157
|
-
}) => {
|
|
158
|
-
workspace.block = {
|
|
159
|
-
os: [...workspace.os],
|
|
160
|
-
is: [],
|
|
161
|
-
bs: {
|
|
162
|
-
type: 'scope',
|
|
163
|
-
subType: 'start',
|
|
164
|
-
payload: `blockTag/${context.sequences[0].block.subType.split(':')[1]}`,
|
|
165
|
-
},
|
|
166
|
-
bg: [...workspace.waitingBlockGrafts],
|
|
167
|
-
items: [],
|
|
168
|
-
};
|
|
169
|
-
output.pkJson[workspace.sequenceId].push(workspace.block);
|
|
170
|
-
},
|
|
171
|
-
},
|
|
172
|
-
],
|
|
173
|
-
endParagraph: [
|
|
174
|
-
{
|
|
175
|
-
description: 'Close open scopes',
|
|
176
|
-
test: () => true,
|
|
177
|
-
action: ({ workspace }) => {
|
|
178
|
-
closeParagraphScopes(workspace);
|
|
179
|
-
workspace.waitingBlockGrafts = [];
|
|
180
|
-
},
|
|
181
|
-
},
|
|
182
|
-
],
|
|
183
|
-
mark: [
|
|
184
|
-
{
|
|
185
|
-
description: 'ts mark as milestone',
|
|
186
|
-
test: ({ context }) => ['usfm:ts'].includes(context.sequences[0].element.subType),
|
|
187
|
-
action: ({ workspace }) => {
|
|
188
|
-
const milestoneScope = `milestone/ts`;
|
|
189
|
-
|
|
190
|
-
if (!workspace.block.is.includes(milestoneScope)) {
|
|
191
|
-
workspace.block.is.push(milestoneScope);
|
|
192
|
-
}
|
|
193
|
-
workspace.os.push(milestoneScope);
|
|
194
|
-
workspace.block.items.push({
|
|
195
|
-
type: 'scope',
|
|
196
|
-
subType: 'start',
|
|
197
|
-
payload: milestoneScope,
|
|
198
|
-
});
|
|
199
|
-
workspace.block.items.push({
|
|
200
|
-
type: 'scope',
|
|
201
|
-
subType: 'end',
|
|
202
|
-
payload: milestoneScope,
|
|
203
|
-
});
|
|
204
|
-
},
|
|
205
|
-
},
|
|
206
|
-
{
|
|
207
|
-
description: 'Chapter',
|
|
208
|
-
test: ({ context }) => ['chapter'].includes(context.sequences[0].element.subType),
|
|
209
|
-
action: ({
|
|
210
|
-
context,
|
|
211
|
-
workspace,
|
|
212
|
-
}) => {
|
|
213
|
-
closeVerseScopes(workspace);
|
|
214
|
-
closeChapterScopes(workspace);
|
|
215
|
-
const element = context.sequences[0].element;
|
|
216
|
-
const chapterScope = `chapter/${element.atts['number']}`;
|
|
217
|
-
|
|
218
|
-
if (!workspace.block.is.includes(chapterScope)) {
|
|
219
|
-
workspace.block.is.push(chapterScope);
|
|
220
|
-
}
|
|
221
|
-
workspace.os.push(chapterScope);
|
|
222
|
-
workspace.block.items.push({
|
|
223
|
-
type: 'scope',
|
|
224
|
-
subType: 'start',
|
|
225
|
-
payload: chapterScope,
|
|
226
|
-
});
|
|
227
|
-
},
|
|
228
|
-
},
|
|
229
|
-
{
|
|
230
|
-
description: 'Verses',
|
|
231
|
-
test: ({ context }) => ['verses'].includes(context.sequences[0].element.subType),
|
|
232
|
-
action: ({
|
|
233
|
-
context,
|
|
234
|
-
workspace,
|
|
235
|
-
}) => {
|
|
236
|
-
closeVerseScopes(workspace);
|
|
237
|
-
const element = context.sequences[0].element;
|
|
238
|
-
const vn = element.atts['number'];
|
|
239
|
-
let va = [parseInt(vn)];
|
|
240
|
-
|
|
241
|
-
if (vn.includes('-')) {
|
|
242
|
-
let [vs, ve] = vn.split('-').map(s => parseInt(s));
|
|
243
|
-
va = [vs];
|
|
244
|
-
|
|
245
|
-
while (vs <= ve) {
|
|
246
|
-
vs++;
|
|
247
|
-
va.push(vs);
|
|
248
|
-
}
|
|
249
|
-
}
|
|
250
|
-
|
|
251
|
-
for (const v of va) {
|
|
252
|
-
const verseScope = `verse/${v}`;
|
|
253
|
-
workspace.os.push(verseScope);
|
|
254
|
-
|
|
255
|
-
if (!workspace.block.is.includes(verseScope)) {
|
|
256
|
-
workspace.block.is.push(verseScope);
|
|
257
|
-
}
|
|
258
|
-
workspace.block.items.push({
|
|
259
|
-
type: 'scope',
|
|
260
|
-
subType: 'start',
|
|
261
|
-
payload: verseScope,
|
|
262
|
-
});
|
|
263
|
-
}
|
|
264
|
-
|
|
265
|
-
const versesScope = `verses/${element.atts['number']}`;
|
|
266
|
-
|
|
267
|
-
if (!workspace.block.is.includes(versesScope)) {
|
|
268
|
-
workspace.block.is.push(versesScope);
|
|
269
|
-
}
|
|
270
|
-
workspace.os.push(versesScope);
|
|
271
|
-
workspace.block.items.push({
|
|
272
|
-
type: 'scope',
|
|
273
|
-
subType: 'start',
|
|
274
|
-
payload: versesScope,
|
|
275
|
-
});
|
|
276
|
-
},
|
|
277
|
-
},
|
|
278
|
-
],
|
|
279
|
-
|
|
280
|
-
startMilestone: [
|
|
281
|
-
{
|
|
282
|
-
description: 'Add scope and update state',
|
|
283
|
-
test: () => true,
|
|
284
|
-
action: ({
|
|
285
|
-
context,
|
|
286
|
-
workspace,
|
|
287
|
-
}) => {
|
|
288
|
-
const element = context.sequences[0].element;
|
|
289
|
-
const milestoneScope = `milestone/${element.subType.split(':')[1]}`;
|
|
290
|
-
|
|
291
|
-
if (!workspace.block.is.includes(milestoneScope)) {
|
|
292
|
-
workspace.block.is.push(milestoneScope);
|
|
293
|
-
}
|
|
294
|
-
workspace.os.push(milestoneScope);
|
|
295
|
-
workspace.block.items.push({
|
|
296
|
-
type: 'scope',
|
|
297
|
-
subType: 'start',
|
|
298
|
-
payload: milestoneScope,
|
|
299
|
-
});
|
|
300
|
-
|
|
301
|
-
for (const [attKey, attValue] of Object.entries(element.atts || {})) {
|
|
302
|
-
const valueParts = attValue.toString().split(',');
|
|
303
|
-
|
|
304
|
-
for (const [partN, part] of valueParts.entries()) {
|
|
305
|
-
const attScope = `attribute/milestone/${element.subType.split(':')[1]}/${attKey}/${partN}/${part}`;
|
|
306
|
-
|
|
307
|
-
if (!workspace.block.is.includes(attScope)) {
|
|
308
|
-
workspace.block.is.push(attScope);
|
|
309
|
-
}
|
|
310
|
-
workspace.os.push(attScope);
|
|
311
|
-
workspace.block.items.push({
|
|
312
|
-
type: 'scope',
|
|
313
|
-
subType: 'start',
|
|
314
|
-
payload: attScope,
|
|
315
|
-
});
|
|
316
|
-
}
|
|
317
|
-
}
|
|
318
|
-
},
|
|
319
|
-
},
|
|
320
|
-
],
|
|
321
|
-
|
|
322
|
-
endMilestone: [
|
|
323
|
-
{
|
|
324
|
-
description: 'Remove scope and update state',
|
|
325
|
-
test: () => true,
|
|
326
|
-
action: ({
|
|
327
|
-
context,
|
|
328
|
-
workspace,
|
|
329
|
-
}) => {
|
|
330
|
-
const element = context.sequences[0].element;
|
|
331
|
-
const attScopeRoot = `attribute/milestone/${element.subType.split(':')[1]}`;
|
|
332
|
-
|
|
333
|
-
for (const att of [...workspace.os.filter(s => s.startsWith(attScopeRoot))].reverse()) {
|
|
334
|
-
workspace.os = workspace.os.filter(o => o !== att);
|
|
335
|
-
workspace.block.items.push({
|
|
336
|
-
type: 'scope',
|
|
337
|
-
subType: 'end',
|
|
338
|
-
payload: att,
|
|
339
|
-
});
|
|
340
|
-
}
|
|
341
|
-
|
|
342
|
-
const milestoneScope = `milestone/${element.subType.split(':')[1]}`;
|
|
343
|
-
workspace.os = workspace.os.filter(s => s !== milestoneScope);
|
|
344
|
-
workspace.block.items.push({
|
|
345
|
-
type: 'scope',
|
|
346
|
-
subType: 'end',
|
|
347
|
-
payload: milestoneScope,
|
|
348
|
-
});
|
|
349
|
-
},
|
|
350
|
-
},
|
|
351
|
-
],
|
|
352
|
-
|
|
353
|
-
startWrapper: [
|
|
354
|
-
{
|
|
355
|
-
description: 'Add scope and update state',
|
|
356
|
-
test: () => true,
|
|
357
|
-
action: ({
|
|
358
|
-
context,
|
|
359
|
-
workspace,
|
|
360
|
-
}) => {
|
|
361
|
-
const element = context.sequences[0].element;
|
|
362
|
-
const wrapperScope = `${element.subType === 'usfm:w' ? 'spanWithAtts' : 'span'}/${element.subType.split(':')[1]}`;
|
|
363
|
-
|
|
364
|
-
if (!workspace.block.is.includes(wrapperScope)) {
|
|
365
|
-
workspace.block.is.push(wrapperScope);
|
|
366
|
-
}
|
|
367
|
-
workspace.os.push(wrapperScope);
|
|
368
|
-
workspace.block.items.push({
|
|
369
|
-
type: 'scope',
|
|
370
|
-
subType: 'start',
|
|
371
|
-
payload: wrapperScope,
|
|
372
|
-
});
|
|
373
|
-
|
|
374
|
-
for (const [attKey, attValue] of Object.entries(element.atts || {})) {
|
|
375
|
-
const valueParts = attValue.toString().split(',');
|
|
376
|
-
|
|
377
|
-
for (const [partN, part] of valueParts.entries()) {
|
|
378
|
-
const attScope = `attribute/spanWithAtts/w/${attKey}/${partN}/${part}`;
|
|
379
|
-
|
|
380
|
-
if (!workspace.block.is.includes(attScope)) {
|
|
381
|
-
workspace.block.is.push(attScope);
|
|
382
|
-
}
|
|
383
|
-
workspace.os.push(attScope);
|
|
384
|
-
workspace.block.items.push({
|
|
385
|
-
type: 'scope',
|
|
386
|
-
subType: 'start',
|
|
387
|
-
payload: attScope,
|
|
388
|
-
});
|
|
389
|
-
}
|
|
390
|
-
}
|
|
391
|
-
},
|
|
392
|
-
},
|
|
393
|
-
],
|
|
394
|
-
|
|
395
|
-
endWrapper: [
|
|
396
|
-
{
|
|
397
|
-
description: 'Remove scope and update state',
|
|
398
|
-
test: () => true,
|
|
399
|
-
action: ({
|
|
400
|
-
context,
|
|
401
|
-
workspace,
|
|
402
|
-
}) => {
|
|
403
|
-
const element = context.sequences[0].element;
|
|
404
|
-
|
|
405
|
-
for (const [attKey, attValue] of [...Object.entries(element.atts || {})].reverse()) {
|
|
406
|
-
const valueParts = attValue.toString().split(',');
|
|
407
|
-
|
|
408
|
-
for (const [partN, part] of [...valueParts.entries()].reverse()) {
|
|
409
|
-
const attScope = `attribute/spanWithAtts/w/${attKey}/${partN}/${part}`;
|
|
410
|
-
workspace.os = workspace.os.filter(o => o !== attScope);
|
|
411
|
-
workspace.block.items.push({
|
|
412
|
-
type: 'scope',
|
|
413
|
-
subType: 'end',
|
|
414
|
-
payload: attScope,
|
|
415
|
-
});
|
|
416
|
-
}
|
|
417
|
-
}
|
|
418
|
-
|
|
419
|
-
const wrapperScope = `${element.subType === 'usfm:w' ? 'spanWithAtts' : 'span'}/${element.subType.split(':')[1]}`;
|
|
420
|
-
workspace.os = workspace.os.filter(s => s !== wrapperScope);
|
|
421
|
-
workspace.block.items.push({
|
|
422
|
-
type: 'scope',
|
|
423
|
-
subType: 'end',
|
|
424
|
-
payload: wrapperScope,
|
|
425
|
-
});
|
|
426
|
-
},
|
|
427
|
-
},
|
|
428
|
-
],
|
|
429
|
-
|
|
430
|
-
text: [
|
|
431
|
-
{
|
|
432
|
-
description: 'Log occurrences',
|
|
433
|
-
test: () => true,
|
|
434
|
-
action: ({
|
|
435
|
-
context,
|
|
436
|
-
workspace,
|
|
437
|
-
}) => {
|
|
438
|
-
const text = context.sequences[0].element.text;
|
|
439
|
-
const re = xre.union(lexingRegexes.map((x) => x[2]));
|
|
440
|
-
const words = xre.match(text, re, 'all');
|
|
441
|
-
|
|
442
|
-
for (const word of words) {
|
|
443
|
-
let subType;
|
|
444
|
-
|
|
445
|
-
if (xre.test(word, wordLikeRegex)) {
|
|
446
|
-
subType = 'wordLike';
|
|
447
|
-
} else if (xre.test(word, lineSpaceRegex)) {
|
|
448
|
-
subType = 'lineSpace';
|
|
449
|
-
} else if (xre.test(word, punctuationRegex)) {
|
|
450
|
-
subType = 'punctuation';
|
|
451
|
-
}
|
|
452
|
-
workspace.block.items.push({
|
|
453
|
-
type: 'token',
|
|
454
|
-
subType,
|
|
455
|
-
payload: word,
|
|
456
|
-
});
|
|
457
|
-
}
|
|
458
|
-
},
|
|
459
|
-
},
|
|
460
|
-
],
|
|
461
|
-
|
|
462
|
-
endDocument: [
|
|
463
|
-
{
|
|
464
|
-
description: 'Rework hanging end cv scopes',
|
|
465
|
-
test: () => true,
|
|
466
|
-
action: ({ output }) => {
|
|
467
|
-
const sequenceBlocks = Object.values(output.pkJson)[0];
|
|
468
|
-
|
|
469
|
-
for (let blockN = 1; blockN < sequenceBlocks.length; blockN++) {
|
|
470
|
-
let thisBlockItems = sequenceBlocks[blockN].items;
|
|
471
|
-
const lastBlockItems = sequenceBlocks[blockN - 1].items;
|
|
472
|
-
let itemN = 0;
|
|
473
|
-
|
|
474
|
-
while (itemN < thisBlockItems.length) {
|
|
475
|
-
const item = thisBlockItems[itemN];
|
|
476
|
-
|
|
477
|
-
if (item.type !== 'scope' || item.subType !== 'end') {
|
|
478
|
-
break;
|
|
479
|
-
}
|
|
480
|
-
itemN++;
|
|
481
|
-
}
|
|
482
|
-
|
|
483
|
-
while (itemN > 0) {
|
|
484
|
-
const movingScope = thisBlockItems.shift();
|
|
485
|
-
lastBlockItems.push(movingScope);
|
|
486
|
-
sequenceBlocks[blockN].os = sequenceBlocks[blockN].os.filter(s => s !== movingScope.payload);
|
|
487
|
-
itemN--;
|
|
488
|
-
}
|
|
489
|
-
}
|
|
490
|
-
},
|
|
491
|
-
},
|
|
492
|
-
],
|
|
493
|
-
|
|
494
|
-
};
|
|
495
|
-
|
|
496
|
-
const perf2PkJsonCode = function ({ perf }) {
|
|
497
|
-
const cl = new PerfRenderFromJson(
|
|
498
|
-
{
|
|
499
|
-
srcJson: perf,
|
|
500
|
-
ignoreMissingSequences: true,
|
|
501
|
-
actions: perf2PkJsonActions,
|
|
502
|
-
},
|
|
503
|
-
);
|
|
504
|
-
const output = {};
|
|
505
|
-
|
|
506
|
-
cl.renderDocument({
|
|
507
|
-
docId: '',
|
|
508
|
-
config: {},
|
|
509
|
-
output,
|
|
510
|
-
});
|
|
511
|
-
return { pkJson: output.pkJson };
|
|
512
|
-
};
|
|
513
|
-
|
|
514
|
-
const perf2PkJson = {
|
|
515
|
-
name: 'perf2PkJson',
|
|
516
|
-
type: 'Transform',
|
|
517
|
-
description: 'PERF=>JSON: Converts PERF to current Proskomma input format',
|
|
518
|
-
documentation: '',
|
|
519
|
-
inputs: [
|
|
520
|
-
{
|
|
521
|
-
name: 'perf',
|
|
522
|
-
type: 'json',
|
|
523
|
-
source: '',
|
|
524
|
-
},
|
|
525
|
-
],
|
|
526
|
-
outputs: [
|
|
527
|
-
{
|
|
528
|
-
name: 'pkJson',
|
|
529
|
-
type: 'json',
|
|
530
|
-
},
|
|
531
|
-
],
|
|
532
|
-
code: perf2PkJsonCode,
|
|
533
|
-
};
|
|
534
|
-
module.exports = perf2PkJson;
|