document-ir 0.5.0 → 0.5.1
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 +31 -31
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var h = (c, t, e) =>
|
|
1
|
+
var d = Object.defineProperty;
|
|
2
|
+
var g = (c, t, e) => t in c ? d(c, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : c[t] = e;
|
|
3
|
+
var h = (c, t, e) => g(c, typeof t != "symbol" ? t + "" : t, e);
|
|
4
4
|
class u {
|
|
5
5
|
async beforeBlock() {
|
|
6
6
|
}
|
|
@@ -855,7 +855,7 @@ class u {
|
|
|
855
855
|
return await this.document(t);
|
|
856
856
|
}
|
|
857
857
|
}
|
|
858
|
-
class
|
|
858
|
+
class k extends u {
|
|
859
859
|
async chooseChildren(t) {
|
|
860
860
|
const e = await super.chooseChildren(t), i = [];
|
|
861
861
|
for (const s of e)
|
|
@@ -867,7 +867,7 @@ class g extends u {
|
|
|
867
867
|
return i;
|
|
868
868
|
}
|
|
869
869
|
}
|
|
870
|
-
class
|
|
870
|
+
class T extends u {
|
|
871
871
|
async chooseChildren(t) {
|
|
872
872
|
const e = await super.chooseChildren(t), i = [];
|
|
873
873
|
let s = null, r;
|
|
@@ -888,12 +888,12 @@ class I extends u {
|
|
|
888
888
|
return i;
|
|
889
889
|
}
|
|
890
890
|
}
|
|
891
|
-
class
|
|
891
|
+
class m extends u {
|
|
892
892
|
async text(t) {
|
|
893
893
|
return t.text == "" ? null : t;
|
|
894
894
|
}
|
|
895
895
|
}
|
|
896
|
-
class
|
|
896
|
+
class v extends u {
|
|
897
897
|
constructor() {
|
|
898
898
|
super();
|
|
899
899
|
h(this, "stripWhitespace");
|
|
@@ -938,10 +938,10 @@ class T extends u {
|
|
|
938
938
|
}
|
|
939
939
|
async transform(e) {
|
|
940
940
|
const i = await super.transform(e);
|
|
941
|
-
return await new
|
|
941
|
+
return await new m().transform(i);
|
|
942
942
|
}
|
|
943
943
|
}
|
|
944
|
-
class
|
|
944
|
+
class N extends u {
|
|
945
945
|
constructor() {
|
|
946
946
|
super();
|
|
947
947
|
h(this, "root");
|
|
@@ -1013,7 +1013,7 @@ class v extends u {
|
|
|
1013
1013
|
return this.reviewBlock(this.root), i;
|
|
1014
1014
|
}
|
|
1015
1015
|
}
|
|
1016
|
-
class
|
|
1016
|
+
class b {
|
|
1017
1017
|
beforeBlock() {
|
|
1018
1018
|
}
|
|
1019
1019
|
afterBlock() {
|
|
@@ -1314,7 +1314,7 @@ class w {
|
|
|
1314
1314
|
t.type == "document" ? this.document(t) : this.choose(t);
|
|
1315
1315
|
}
|
|
1316
1316
|
}
|
|
1317
|
-
class
|
|
1317
|
+
class B extends b {
|
|
1318
1318
|
constructor() {
|
|
1319
1319
|
super();
|
|
1320
1320
|
h(this, "textList");
|
|
@@ -1349,7 +1349,7 @@ class m extends w {
|
|
|
1349
1349
|
return this.textList.join("");
|
|
1350
1350
|
}
|
|
1351
1351
|
}
|
|
1352
|
-
class
|
|
1352
|
+
class C extends k {
|
|
1353
1353
|
async sticker(t) {
|
|
1354
1354
|
if (t.content.length == 0)
|
|
1355
1355
|
return null;
|
|
@@ -1540,7 +1540,7 @@ class B extends g {
|
|
|
1540
1540
|
};
|
|
1541
1541
|
}
|
|
1542
1542
|
}
|
|
1543
|
-
class
|
|
1543
|
+
class x extends b {
|
|
1544
1544
|
constructor() {
|
|
1545
1545
|
super();
|
|
1546
1546
|
h(this, "count");
|
|
@@ -1566,29 +1566,29 @@ class C extends w {
|
|
|
1566
1566
|
return this.countText(), this.count;
|
|
1567
1567
|
}
|
|
1568
1568
|
}
|
|
1569
|
-
function
|
|
1569
|
+
function y(c) {
|
|
1570
1570
|
const t = {
|
|
1571
1571
|
headerText: c.header,
|
|
1572
1572
|
headerId: c.headerId,
|
|
1573
1573
|
words: 0,
|
|
1574
1574
|
totalWords: 0,
|
|
1575
1575
|
children: []
|
|
1576
|
-
}, e = new
|
|
1576
|
+
}, e = new x();
|
|
1577
1577
|
for (const i of c.nodes)
|
|
1578
1578
|
e.visit(i);
|
|
1579
1579
|
t.words = e.getCount(), t.totalWords = t.words;
|
|
1580
1580
|
for (const i of c.children) {
|
|
1581
|
-
const s =
|
|
1581
|
+
const s = y(i);
|
|
1582
1582
|
t.children.push(s), t.totalWords += s.totalWords;
|
|
1583
1583
|
}
|
|
1584
1584
|
return t;
|
|
1585
1585
|
}
|
|
1586
|
-
class
|
|
1586
|
+
class R extends u {
|
|
1587
1587
|
constructor() {
|
|
1588
1588
|
super();
|
|
1589
1589
|
}
|
|
1590
1590
|
async transform(t) {
|
|
1591
|
-
const e = JSON.parse(JSON.stringify(t)), i = await new
|
|
1591
|
+
const e = JSON.parse(JSON.stringify(t)), i = await new C().transform(e), s = [], r = {
|
|
1592
1592
|
header: t.title,
|
|
1593
1593
|
headerId: "title",
|
|
1594
1594
|
nodes: [],
|
|
@@ -1604,32 +1604,32 @@ class N extends u {
|
|
|
1604
1604
|
if (o.level <= n)
|
|
1605
1605
|
for (let p = s.length - 1; p > 0; p--)
|
|
1606
1606
|
s[p].depth >= o.level && s.pop();
|
|
1607
|
-
const l = new
|
|
1607
|
+
const l = new B();
|
|
1608
1608
|
l.visit(o);
|
|
1609
1609
|
const f = {
|
|
1610
1610
|
header: l.getText(),
|
|
1611
1611
|
depth: o.level,
|
|
1612
1612
|
children: [],
|
|
1613
1613
|
nodes: []
|
|
1614
|
-
};
|
|
1615
|
-
|
|
1614
|
+
}, w = o.htmlId || o.id;
|
|
1615
|
+
w && (f.headerId = w), s[s.length - 1].children.push(f), s.push(f), n = o.level;
|
|
1616
1616
|
} else
|
|
1617
1617
|
s[s.length - 1].nodes.push(o);
|
|
1618
1618
|
const a = {
|
|
1619
1619
|
...t
|
|
1620
1620
|
};
|
|
1621
|
-
return a.hierarchy =
|
|
1621
|
+
return a.hierarchy = y(r), a;
|
|
1622
1622
|
}
|
|
1623
1623
|
}
|
|
1624
1624
|
export {
|
|
1625
|
-
|
|
1626
|
-
|
|
1625
|
+
k as ArrayCollapseTransformer,
|
|
1626
|
+
C as DocumentThinningTransformer,
|
|
1627
1627
|
u as IdentityTransformer,
|
|
1628
|
-
|
|
1629
|
-
|
|
1630
|
-
|
|
1631
|
-
|
|
1632
|
-
|
|
1633
|
-
|
|
1634
|
-
|
|
1628
|
+
b as NodeVisitor,
|
|
1629
|
+
T as TextCollapseTransformer,
|
|
1630
|
+
B as TextVisitor,
|
|
1631
|
+
N as WhitespaceStretchingTransformer,
|
|
1632
|
+
v as WhitespaceTransformer,
|
|
1633
|
+
R as WordCounterTransformer,
|
|
1634
|
+
x as WordCounterVisitor
|
|
1635
1635
|
};
|