document-ir 0.5.2 → 0.5.4
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/NodeVisitor.d.ts +8 -1
- package/dist/index.js +48 -16
- package/dist/types.d.ts +1 -0
- package/package.json +1 -1
package/dist/NodeVisitor.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ArrayNode, BadgeNode, BlockNode, BlockQuoteNode, BoldNode, BreakNode, BubbleNode, CardNode, CenterNode, CodeNode, ColumnsNode, DateNode, DateTimeNode, DefinitionListNode, DefinitionNode, DefinitionReferenceNode, DocumentNode, EmbedNode, EmojiNode, FigureCaptionNode, FigureImageNode, FigureNode, FootnoteNode, FootnoteDisplayNode, FormattedTextNode, HeaderNode, HighTechAlertNode, HorizontalRuleNode, ImageNode, ItalicNode, LinkNode, ListNode, Node, NoteNode, TimeRangeNode, ParagraphNode, QuoteNode, RedactedNode, RegionNode, ScriptNode, SecretNode, SmallerNode, SocialNode, StandardNode, StickerNode, StrikeThroughNode, SubTextNode, SuperTextNode, TableNode, TableOfContentsNode, TextNode, TimeNode, UnderlineNode, VideoNode, WarningNode } from './types.ts';
|
|
1
|
+
import { AccordionGroupNode, AccordionTabNode, ArrayNode, BadgeNode, BlockNode, BlockQuoteNode, BoldNode, BreakNode, BubbleNode, CardNode, CenterNode, CodeNode, CodeBlockNode, CodeGroupNode, CodeGroupTabNode, ColumnsNode, PillNode, StyleNode, DateNode, DateTimeNode, DefinitionListNode, DefinitionNode, DefinitionReferenceNode, DocumentNode, EmbedNode, EmojiNode, FigureCaptionNode, FigureImageNode, FigureNode, FootnoteNode, FootnoteDisplayNode, FormattedTextNode, HeaderNode, HighTechAlertNode, HorizontalRuleNode, ImageNode, ItalicNode, LinkNode, ListNode, Node, NoteNode, TimeRangeNode, ParagraphNode, QuoteNode, RedactedNode, RegionNode, ScriptNode, SecretNode, SmallerNode, SocialNode, StandardNode, StickerNode, StrikeThroughNode, SubTextNode, SuperTextNode, TableNode, TableOfContentsNode, TextNode, TimeNode, UnderlineNode, VideoNode, WarningNode } from './types.ts';
|
|
2
2
|
export declare class NodeVisitor {
|
|
3
3
|
protected beforeBlock(): void;
|
|
4
4
|
protected afterBlock(): void;
|
|
@@ -13,6 +13,13 @@ export declare class NodeVisitor {
|
|
|
13
13
|
protected bubble(node: BubbleNode): void;
|
|
14
14
|
protected center(node: CenterNode): void;
|
|
15
15
|
protected code(node: CodeNode): void;
|
|
16
|
+
protected codeBlock(node: CodeBlockNode): void;
|
|
17
|
+
protected accordionTab(node: AccordionTabNode): void;
|
|
18
|
+
protected accordionGroup(node: AccordionGroupNode): void;
|
|
19
|
+
protected codeGroupTab(node: CodeGroupTabNode): void;
|
|
20
|
+
protected codeGroup(node: CodeGroupNode): void;
|
|
21
|
+
protected pill(node: PillNode): void;
|
|
22
|
+
protected style(_node: StyleNode): void;
|
|
16
23
|
protected columns(node: ColumnsNode): void;
|
|
17
24
|
protected definition(node: DefinitionNode): void;
|
|
18
25
|
protected definitionList(node: DefinitionListNode): void;
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var h = (c, t, e) =>
|
|
1
|
+
var y = Object.defineProperty;
|
|
2
|
+
var k = (c, t, e) => t in c ? y(c, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : c[t] = e;
|
|
3
|
+
var h = (c, t, e) => k(c, typeof t != "symbol" ? t + "" : t, e);
|
|
4
4
|
class u {
|
|
5
5
|
async beforeBlock() {
|
|
6
6
|
}
|
|
@@ -406,7 +406,7 @@ class u {
|
|
|
406
406
|
name: t.name,
|
|
407
407
|
content: e
|
|
408
408
|
};
|
|
409
|
-
return t.id != null && (i.id = t.id), t.url && (i.url = t.url), t.orientation && (i.orientation = t.orientation), i;
|
|
409
|
+
return t.id != null && (i.id = t.id), t.url && (i.url = t.url), t.orientation && (i.orientation = t.orientation), t.author != null && (i.author = t.author), i;
|
|
410
410
|
}
|
|
411
411
|
async redacted(t) {
|
|
412
412
|
t.style == "block" ? await this.beforeBlock() : await this.beforeInline();
|
|
@@ -855,7 +855,7 @@ class u {
|
|
|
855
855
|
return await this.document(t);
|
|
856
856
|
}
|
|
857
857
|
}
|
|
858
|
-
class
|
|
858
|
+
class g extends u {
|
|
859
859
|
async chooseChildren(t) {
|
|
860
860
|
const e = await super.chooseChildren(t), i = [];
|
|
861
861
|
for (const s of e)
|
|
@@ -1023,7 +1023,7 @@ class N extends u {
|
|
|
1023
1023
|
return this.reviewBlock(this.root), i;
|
|
1024
1024
|
}
|
|
1025
1025
|
}
|
|
1026
|
-
class
|
|
1026
|
+
class w {
|
|
1027
1027
|
beforeBlock() {
|
|
1028
1028
|
}
|
|
1029
1029
|
afterBlock() {
|
|
@@ -1059,6 +1059,28 @@ class b {
|
|
|
1059
1059
|
code(t) {
|
|
1060
1060
|
this.beforeInline(), this.chooseChildren(t.content), this.afterInline();
|
|
1061
1061
|
}
|
|
1062
|
+
codeBlock(t) {
|
|
1063
|
+
this.code(t.content);
|
|
1064
|
+
}
|
|
1065
|
+
accordionTab(t) {
|
|
1066
|
+
this.beforeInline(), this.chooseChildren(t.header), this.afterInline(), this.beforeBlock(), this.chooseChildren(t.content), this.afterBlock();
|
|
1067
|
+
}
|
|
1068
|
+
accordionGroup(t) {
|
|
1069
|
+
for (const e of t.tabs)
|
|
1070
|
+
this.accordionTab(e);
|
|
1071
|
+
}
|
|
1072
|
+
codeGroupTab(t) {
|
|
1073
|
+
this.beforeInline(), this.chooseChildren(t.header), this.afterInline(), this.code(t.content);
|
|
1074
|
+
}
|
|
1075
|
+
codeGroup(t) {
|
|
1076
|
+
for (const e of t.tabs)
|
|
1077
|
+
this.codeGroupTab(e);
|
|
1078
|
+
}
|
|
1079
|
+
pill(t) {
|
|
1080
|
+
this.beforeInline(), this.chooseChildren(t.content), this.afterInline();
|
|
1081
|
+
}
|
|
1082
|
+
style(t) {
|
|
1083
|
+
}
|
|
1062
1084
|
columns(t) {
|
|
1063
1085
|
for (const e of t.columns)
|
|
1064
1086
|
this.beforeBlock(), this.chooseChildren(e), this.afterBlock();
|
|
@@ -1217,6 +1239,16 @@ class b {
|
|
|
1217
1239
|
return this.center(t);
|
|
1218
1240
|
case "code":
|
|
1219
1241
|
return this.code(t);
|
|
1242
|
+
case "code-block":
|
|
1243
|
+
return this.codeBlock(t);
|
|
1244
|
+
case "code-group":
|
|
1245
|
+
return this.codeGroup(t);
|
|
1246
|
+
case "accordion-group":
|
|
1247
|
+
return this.accordionGroup(t);
|
|
1248
|
+
case "pill":
|
|
1249
|
+
return this.pill(t);
|
|
1250
|
+
case "style":
|
|
1251
|
+
return this.style(t);
|
|
1220
1252
|
case "columns":
|
|
1221
1253
|
return this.columns(t);
|
|
1222
1254
|
case "definition":
|
|
@@ -1324,7 +1356,7 @@ class b {
|
|
|
1324
1356
|
t.type == "document" ? this.document(t) : this.choose(t);
|
|
1325
1357
|
}
|
|
1326
1358
|
}
|
|
1327
|
-
class B extends
|
|
1359
|
+
class B extends w {
|
|
1328
1360
|
constructor() {
|
|
1329
1361
|
super();
|
|
1330
1362
|
h(this, "textList");
|
|
@@ -1359,7 +1391,7 @@ class B extends b {
|
|
|
1359
1391
|
return this.textList.join("");
|
|
1360
1392
|
}
|
|
1361
1393
|
}
|
|
1362
|
-
class C extends
|
|
1394
|
+
class C extends g {
|
|
1363
1395
|
async sticker(t) {
|
|
1364
1396
|
if (t.content.length == 0)
|
|
1365
1397
|
return null;
|
|
@@ -1550,7 +1582,7 @@ class C extends k {
|
|
|
1550
1582
|
};
|
|
1551
1583
|
}
|
|
1552
1584
|
}
|
|
1553
|
-
class x extends
|
|
1585
|
+
class x extends w {
|
|
1554
1586
|
constructor() {
|
|
1555
1587
|
super();
|
|
1556
1588
|
h(this, "count");
|
|
@@ -1576,7 +1608,7 @@ class x extends b {
|
|
|
1576
1608
|
return this.countText(), this.count;
|
|
1577
1609
|
}
|
|
1578
1610
|
}
|
|
1579
|
-
function
|
|
1611
|
+
function d(c) {
|
|
1580
1612
|
const t = {
|
|
1581
1613
|
headerText: c.header,
|
|
1582
1614
|
headerId: c.headerId,
|
|
@@ -1588,7 +1620,7 @@ function y(c) {
|
|
|
1588
1620
|
e.visit(i);
|
|
1589
1621
|
t.words = e.getCount(), t.totalWords = t.words;
|
|
1590
1622
|
for (const i of c.children) {
|
|
1591
|
-
const s =
|
|
1623
|
+
const s = d(i);
|
|
1592
1624
|
t.children.push(s), t.totalWords += s.totalWords;
|
|
1593
1625
|
}
|
|
1594
1626
|
return t;
|
|
@@ -1621,21 +1653,21 @@ class _ extends u {
|
|
|
1621
1653
|
depth: o.level,
|
|
1622
1654
|
children: [],
|
|
1623
1655
|
nodes: []
|
|
1624
|
-
},
|
|
1625
|
-
|
|
1656
|
+
}, b = o.htmlId || o.id;
|
|
1657
|
+
b && (f.headerId = b), s[s.length - 1].children.push(f), s.push(f), n = o.level;
|
|
1626
1658
|
} else
|
|
1627
1659
|
s[s.length - 1].nodes.push(o);
|
|
1628
1660
|
const a = {
|
|
1629
1661
|
...t
|
|
1630
1662
|
};
|
|
1631
|
-
return a.hierarchy =
|
|
1663
|
+
return a.hierarchy = d(r), a;
|
|
1632
1664
|
}
|
|
1633
1665
|
}
|
|
1634
1666
|
export {
|
|
1635
|
-
|
|
1667
|
+
g as ArrayCollapseTransformer,
|
|
1636
1668
|
C as DocumentThinningTransformer,
|
|
1637
1669
|
u as IdentityTransformer,
|
|
1638
|
-
|
|
1670
|
+
w as NodeVisitor,
|
|
1639
1671
|
T as TextCollapseTransformer,
|
|
1640
1672
|
B as TextVisitor,
|
|
1641
1673
|
N as WhitespaceStretchingTransformer,
|
package/dist/types.d.ts
CHANGED