proskomma-core 0.11.3 → 0.11.5
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/index.js +44 -30
- package/dist/index.mjs +44 -30
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -15992,7 +15992,7 @@ var bitset = { exports: {} };
|
|
|
15992
15992
|
var bitsetExports = bitset.exports;
|
|
15993
15993
|
const BitSet = /* @__PURE__ */ getDefaultExportFromCjs(bitsetExports);
|
|
15994
15994
|
const name = "proskomma-core";
|
|
15995
|
-
const version = "0.11.
|
|
15995
|
+
const version = "0.11.5";
|
|
15996
15996
|
const description$h = "A Scripture Runtime Engine";
|
|
15997
15997
|
const files = [
|
|
15998
15998
|
"dist"
|
|
@@ -43377,6 +43377,16 @@ const Sequence = class {
|
|
|
43377
43377
|
}
|
|
43378
43378
|
this.activeScopes = [];
|
|
43379
43379
|
}
|
|
43380
|
+
closeCellScopes(parser) {
|
|
43381
|
+
const firstCellIndex = this.activeScopes.findIndex((sc) => sc.label.startsWith("cell/"));
|
|
43382
|
+
if (firstCellIndex < 0) {
|
|
43383
|
+
return;
|
|
43384
|
+
}
|
|
43385
|
+
for (const activeScope of this.activeScopes.slice(firstCellIndex).reverse()) {
|
|
43386
|
+
this.closeActiveScope(parser, activeScope);
|
|
43387
|
+
}
|
|
43388
|
+
this.activeScopes = this.activeScopes.slice(0, firstCellIndex);
|
|
43389
|
+
}
|
|
43380
43390
|
closeActiveScope(parser, sc) {
|
|
43381
43391
|
this.addItem({
|
|
43382
43392
|
type: "scope",
|
|
@@ -43696,31 +43706,30 @@ const Block = class {
|
|
|
43696
43706
|
}
|
|
43697
43707
|
}
|
|
43698
43708
|
for (const swaStart of swaStarts) {
|
|
43709
|
+
const spanLabel = this.items[swaStart - 1].payload;
|
|
43710
|
+
const attPrefix = `attribute/${spanLabel}/`;
|
|
43699
43711
|
let pos = swaStart;
|
|
43700
|
-
let
|
|
43712
|
+
let others = [];
|
|
43701
43713
|
let scopes = [];
|
|
43702
|
-
while (
|
|
43703
|
-
if (pos >= this.items.length) {
|
|
43704
|
-
break;
|
|
43705
|
-
}
|
|
43714
|
+
while (pos < this.items.length) {
|
|
43706
43715
|
const item = this.items[pos];
|
|
43707
|
-
if (item.type === "
|
|
43708
|
-
|
|
43709
|
-
} else if (item.subType === "start" && item.payload.startsWith(
|
|
43716
|
+
if (item.type === "scope" && item.payload === spanLabel) {
|
|
43717
|
+
break;
|
|
43718
|
+
} else if (item.subType === "start" && item.payload.startsWith(attPrefix)) {
|
|
43710
43719
|
scopes.push(item);
|
|
43711
43720
|
} else {
|
|
43712
|
-
|
|
43721
|
+
others.push(item);
|
|
43713
43722
|
}
|
|
43714
43723
|
pos++;
|
|
43715
43724
|
}
|
|
43716
|
-
if (
|
|
43725
|
+
if (others.length !== 0 && scopes.length !== 0) {
|
|
43717
43726
|
let pos2 = swaStart;
|
|
43718
43727
|
for (const s of scopes) {
|
|
43719
43728
|
this.items[pos2] = s;
|
|
43720
43729
|
pos2++;
|
|
43721
43730
|
}
|
|
43722
|
-
for (const
|
|
43723
|
-
this.items[pos2] =
|
|
43731
|
+
for (const o of others) {
|
|
43732
|
+
this.items[pos2] = o;
|
|
43724
43733
|
pos2++;
|
|
43725
43734
|
}
|
|
43726
43735
|
}
|
|
@@ -44273,6 +44282,8 @@ const specs = (pt) => [
|
|
|
44273
44282
|
// ROW - Make new block
|
|
44274
44283
|
contexts: [["startTag", "tagName", ["tr"]]],
|
|
44275
44284
|
parser: {
|
|
44285
|
+
// End open cells in the row they belong to, before the new row's block is created
|
|
44286
|
+
before: (parser) => parser.closeActiveScopes("endBlock"),
|
|
44276
44287
|
newBlock: true,
|
|
44277
44288
|
newScopes: []
|
|
44278
44289
|
}
|
|
@@ -44513,22 +44524,13 @@ const specs = (pt) => [
|
|
|
44513
44524
|
// CELL - unpick tagName, add scope
|
|
44514
44525
|
contexts: [["startTag", "tagName", ["th", "thr", "tc", "tcr"]]],
|
|
44515
44526
|
parser: {
|
|
44527
|
+
// Cells don't nest, so any cell marker (any column number or range) ends an open cell
|
|
44528
|
+
before: (parser) => parser.closeActiveScopes("startCell"),
|
|
44516
44529
|
newScopes: [
|
|
44517
44530
|
{
|
|
44518
44531
|
label: (pt2) => labelForScope$2("cell", [pt2.fullTagName]),
|
|
44519
44532
|
endedBy: [
|
|
44520
|
-
"
|
|
44521
|
-
"startTag/thr",
|
|
44522
|
-
"startTag/tc",
|
|
44523
|
-
"startTag/tcr",
|
|
44524
|
-
"startTag/th2",
|
|
44525
|
-
"startTag/thr2",
|
|
44526
|
-
"startTag/tc2",
|
|
44527
|
-
"startTag/tcr2",
|
|
44528
|
-
"startTag/th3",
|
|
44529
|
-
"startTag/thr3",
|
|
44530
|
-
"startTag/tc3",
|
|
44531
|
-
"startTag/tcr3",
|
|
44533
|
+
"startCell",
|
|
44532
44534
|
"endBlock",
|
|
44533
44535
|
"endTag/$fullTagName$"
|
|
44534
44536
|
]
|
|
@@ -44563,7 +44565,7 @@ const specs = (pt) => [
|
|
|
44563
44565
|
{
|
|
44564
44566
|
// END MILESTONE - close scope, clear attribute context
|
|
44565
44567
|
contexts: [["endMilestoneMarker"]],
|
|
44566
|
-
parser: { during: (parser) => parser.clearAttributeContext() }
|
|
44568
|
+
parser: { during: (parser) => parser.clearAttributeContext("milestone") }
|
|
44567
44569
|
},
|
|
44568
44570
|
{
|
|
44569
44571
|
// ATTRIBUTE - open scope based on attribute context
|
|
@@ -44721,7 +44723,9 @@ const Parser2 = class {
|
|
|
44721
44723
|
parentSequence: null,
|
|
44722
44724
|
baseSequenceType: "main",
|
|
44723
44725
|
inlineSequenceType: null,
|
|
44724
|
-
attributeContext: null
|
|
44726
|
+
attributeContext: null,
|
|
44727
|
+
spanAttributeContext: null,
|
|
44728
|
+
milestoneAttributeContext: null
|
|
44725
44729
|
};
|
|
44726
44730
|
}
|
|
44727
44731
|
parseItem(lexedItem) {
|
|
@@ -44809,6 +44813,7 @@ const Parser2 = class {
|
|
|
44809
44813
|
if (emptySequences) {
|
|
44810
44814
|
seq.removeGraftsToEmptySequences(emptySequences);
|
|
44811
44815
|
}
|
|
44816
|
+
seq.closeCellScopes(this);
|
|
44812
44817
|
seq.addTableScopes();
|
|
44813
44818
|
seq.close(this);
|
|
44814
44819
|
this.substitutePubNumberScopes(seq);
|
|
@@ -45130,11 +45135,20 @@ const Parser2 = class {
|
|
|
45130
45135
|
payload: label
|
|
45131
45136
|
});
|
|
45132
45137
|
}
|
|
45138
|
+
// Milestones may sit inside spans with attributes (eg \w ... \zx-s |a="b"\* ... \zx-e\* |lemma="c"\w*),
|
|
45139
|
+
// so keep separate contexts for each, with the milestone context taking priority while it is open
|
|
45133
45140
|
setAttributeContext(label) {
|
|
45134
|
-
|
|
45141
|
+
const contextKey = label.startsWith("milestone") ? "milestoneAttributeContext" : "spanAttributeContext";
|
|
45142
|
+
this.current[contextKey] = label;
|
|
45143
|
+
this.updateAttributeContext();
|
|
45144
|
+
}
|
|
45145
|
+
clearAttributeContext(scopeType) {
|
|
45146
|
+
const contextKey = scopeType === "milestone" ? "milestoneAttributeContext" : "spanAttributeContext";
|
|
45147
|
+
this.current[contextKey] = null;
|
|
45148
|
+
this.updateAttributeContext();
|
|
45135
45149
|
}
|
|
45136
|
-
|
|
45137
|
-
this.current.attributeContext = null;
|
|
45150
|
+
updateAttributeContext() {
|
|
45151
|
+
this.current.attributeContext = this.current.milestoneAttributeContext || this.current.spanAttributeContext || null;
|
|
45138
45152
|
}
|
|
45139
45153
|
};
|
|
45140
45154
|
const ByteArray$2 = utils.ByteArray;
|
package/dist/index.mjs
CHANGED
|
@@ -15990,7 +15990,7 @@ var bitset = { exports: {} };
|
|
|
15990
15990
|
var bitsetExports = bitset.exports;
|
|
15991
15991
|
const BitSet = /* @__PURE__ */ getDefaultExportFromCjs(bitsetExports);
|
|
15992
15992
|
const name = "proskomma-core";
|
|
15993
|
-
const version = "0.11.
|
|
15993
|
+
const version = "0.11.5";
|
|
15994
15994
|
const description$h = "A Scripture Runtime Engine";
|
|
15995
15995
|
const files = [
|
|
15996
15996
|
"dist"
|
|
@@ -43375,6 +43375,16 @@ const Sequence = class {
|
|
|
43375
43375
|
}
|
|
43376
43376
|
this.activeScopes = [];
|
|
43377
43377
|
}
|
|
43378
|
+
closeCellScopes(parser) {
|
|
43379
|
+
const firstCellIndex = this.activeScopes.findIndex((sc) => sc.label.startsWith("cell/"));
|
|
43380
|
+
if (firstCellIndex < 0) {
|
|
43381
|
+
return;
|
|
43382
|
+
}
|
|
43383
|
+
for (const activeScope of this.activeScopes.slice(firstCellIndex).reverse()) {
|
|
43384
|
+
this.closeActiveScope(parser, activeScope);
|
|
43385
|
+
}
|
|
43386
|
+
this.activeScopes = this.activeScopes.slice(0, firstCellIndex);
|
|
43387
|
+
}
|
|
43378
43388
|
closeActiveScope(parser, sc) {
|
|
43379
43389
|
this.addItem({
|
|
43380
43390
|
type: "scope",
|
|
@@ -43694,31 +43704,30 @@ const Block = class {
|
|
|
43694
43704
|
}
|
|
43695
43705
|
}
|
|
43696
43706
|
for (const swaStart of swaStarts) {
|
|
43707
|
+
const spanLabel = this.items[swaStart - 1].payload;
|
|
43708
|
+
const attPrefix = `attribute/${spanLabel}/`;
|
|
43697
43709
|
let pos = swaStart;
|
|
43698
|
-
let
|
|
43710
|
+
let others = [];
|
|
43699
43711
|
let scopes = [];
|
|
43700
|
-
while (
|
|
43701
|
-
if (pos >= this.items.length) {
|
|
43702
|
-
break;
|
|
43703
|
-
}
|
|
43712
|
+
while (pos < this.items.length) {
|
|
43704
43713
|
const item = this.items[pos];
|
|
43705
|
-
if (item.type === "
|
|
43706
|
-
|
|
43707
|
-
} else if (item.subType === "start" && item.payload.startsWith(
|
|
43714
|
+
if (item.type === "scope" && item.payload === spanLabel) {
|
|
43715
|
+
break;
|
|
43716
|
+
} else if (item.subType === "start" && item.payload.startsWith(attPrefix)) {
|
|
43708
43717
|
scopes.push(item);
|
|
43709
43718
|
} else {
|
|
43710
|
-
|
|
43719
|
+
others.push(item);
|
|
43711
43720
|
}
|
|
43712
43721
|
pos++;
|
|
43713
43722
|
}
|
|
43714
|
-
if (
|
|
43723
|
+
if (others.length !== 0 && scopes.length !== 0) {
|
|
43715
43724
|
let pos2 = swaStart;
|
|
43716
43725
|
for (const s of scopes) {
|
|
43717
43726
|
this.items[pos2] = s;
|
|
43718
43727
|
pos2++;
|
|
43719
43728
|
}
|
|
43720
|
-
for (const
|
|
43721
|
-
this.items[pos2] =
|
|
43729
|
+
for (const o of others) {
|
|
43730
|
+
this.items[pos2] = o;
|
|
43722
43731
|
pos2++;
|
|
43723
43732
|
}
|
|
43724
43733
|
}
|
|
@@ -44271,6 +44280,8 @@ const specs = (pt) => [
|
|
|
44271
44280
|
// ROW - Make new block
|
|
44272
44281
|
contexts: [["startTag", "tagName", ["tr"]]],
|
|
44273
44282
|
parser: {
|
|
44283
|
+
// End open cells in the row they belong to, before the new row's block is created
|
|
44284
|
+
before: (parser) => parser.closeActiveScopes("endBlock"),
|
|
44274
44285
|
newBlock: true,
|
|
44275
44286
|
newScopes: []
|
|
44276
44287
|
}
|
|
@@ -44511,22 +44522,13 @@ const specs = (pt) => [
|
|
|
44511
44522
|
// CELL - unpick tagName, add scope
|
|
44512
44523
|
contexts: [["startTag", "tagName", ["th", "thr", "tc", "tcr"]]],
|
|
44513
44524
|
parser: {
|
|
44525
|
+
// Cells don't nest, so any cell marker (any column number or range) ends an open cell
|
|
44526
|
+
before: (parser) => parser.closeActiveScopes("startCell"),
|
|
44514
44527
|
newScopes: [
|
|
44515
44528
|
{
|
|
44516
44529
|
label: (pt2) => labelForScope$2("cell", [pt2.fullTagName]),
|
|
44517
44530
|
endedBy: [
|
|
44518
|
-
"
|
|
44519
|
-
"startTag/thr",
|
|
44520
|
-
"startTag/tc",
|
|
44521
|
-
"startTag/tcr",
|
|
44522
|
-
"startTag/th2",
|
|
44523
|
-
"startTag/thr2",
|
|
44524
|
-
"startTag/tc2",
|
|
44525
|
-
"startTag/tcr2",
|
|
44526
|
-
"startTag/th3",
|
|
44527
|
-
"startTag/thr3",
|
|
44528
|
-
"startTag/tc3",
|
|
44529
|
-
"startTag/tcr3",
|
|
44531
|
+
"startCell",
|
|
44530
44532
|
"endBlock",
|
|
44531
44533
|
"endTag/$fullTagName$"
|
|
44532
44534
|
]
|
|
@@ -44561,7 +44563,7 @@ const specs = (pt) => [
|
|
|
44561
44563
|
{
|
|
44562
44564
|
// END MILESTONE - close scope, clear attribute context
|
|
44563
44565
|
contexts: [["endMilestoneMarker"]],
|
|
44564
|
-
parser: { during: (parser) => parser.clearAttributeContext() }
|
|
44566
|
+
parser: { during: (parser) => parser.clearAttributeContext("milestone") }
|
|
44565
44567
|
},
|
|
44566
44568
|
{
|
|
44567
44569
|
// ATTRIBUTE - open scope based on attribute context
|
|
@@ -44719,7 +44721,9 @@ const Parser2 = class {
|
|
|
44719
44721
|
parentSequence: null,
|
|
44720
44722
|
baseSequenceType: "main",
|
|
44721
44723
|
inlineSequenceType: null,
|
|
44722
|
-
attributeContext: null
|
|
44724
|
+
attributeContext: null,
|
|
44725
|
+
spanAttributeContext: null,
|
|
44726
|
+
milestoneAttributeContext: null
|
|
44723
44727
|
};
|
|
44724
44728
|
}
|
|
44725
44729
|
parseItem(lexedItem) {
|
|
@@ -44807,6 +44811,7 @@ const Parser2 = class {
|
|
|
44807
44811
|
if (emptySequences) {
|
|
44808
44812
|
seq.removeGraftsToEmptySequences(emptySequences);
|
|
44809
44813
|
}
|
|
44814
|
+
seq.closeCellScopes(this);
|
|
44810
44815
|
seq.addTableScopes();
|
|
44811
44816
|
seq.close(this);
|
|
44812
44817
|
this.substitutePubNumberScopes(seq);
|
|
@@ -45128,11 +45133,20 @@ const Parser2 = class {
|
|
|
45128
45133
|
payload: label
|
|
45129
45134
|
});
|
|
45130
45135
|
}
|
|
45136
|
+
// Milestones may sit inside spans with attributes (eg \w ... \zx-s |a="b"\* ... \zx-e\* |lemma="c"\w*),
|
|
45137
|
+
// so keep separate contexts for each, with the milestone context taking priority while it is open
|
|
45131
45138
|
setAttributeContext(label) {
|
|
45132
|
-
|
|
45139
|
+
const contextKey = label.startsWith("milestone") ? "milestoneAttributeContext" : "spanAttributeContext";
|
|
45140
|
+
this.current[contextKey] = label;
|
|
45141
|
+
this.updateAttributeContext();
|
|
45142
|
+
}
|
|
45143
|
+
clearAttributeContext(scopeType) {
|
|
45144
|
+
const contextKey = scopeType === "milestone" ? "milestoneAttributeContext" : "spanAttributeContext";
|
|
45145
|
+
this.current[contextKey] = null;
|
|
45146
|
+
this.updateAttributeContext();
|
|
45133
45147
|
}
|
|
45134
|
-
|
|
45135
|
-
this.current.attributeContext = null;
|
|
45148
|
+
updateAttributeContext() {
|
|
45149
|
+
this.current.attributeContext = this.current.milestoneAttributeContext || this.current.spanAttributeContext || null;
|
|
45136
45150
|
}
|
|
45137
45151
|
};
|
|
45138
45152
|
const ByteArray$2 = utils.ByteArray;
|