document-ir 0.4.1 → 0.4.3
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/WhitespaceTransformer.d.ts +3 -1
- package/dist/index.js +24 -20
- package/dist/types.d.ts +1 -0
- package/package.json +1 -1
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import { IdentityTransformer } from './IdentityTransformer.ts';
|
|
2
|
-
import { CodeNode, DocumentNode, Node, TextNode } from './types.ts';
|
|
2
|
+
import { BadgeNode, CodeNode, DocumentNode, EmojiNode, Node, TextNode } from './types.ts';
|
|
3
3
|
export declare class WhitespaceTransformer extends IdentityTransformer {
|
|
4
4
|
private stripWhitespace;
|
|
5
5
|
private lastText;
|
|
6
6
|
constructor();
|
|
7
7
|
protected text(node: TextNode): Promise<Node | null>;
|
|
8
8
|
private stripLastText;
|
|
9
|
+
protected emoji(node: EmojiNode): Promise<Node | null>;
|
|
10
|
+
protected badge(node: BadgeNode): Promise<Node | null>;
|
|
9
11
|
protected code(node: CodeNode): Promise<Node | null>;
|
|
10
12
|
protected beforeBlock(): Promise<void>;
|
|
11
13
|
protected afterBlock(): Promise<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 d = (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) => d(c, typeof t != "symbol" ? t + "" : t, e);
|
|
4
4
|
class u {
|
|
5
5
|
async beforeBlock() {
|
|
6
6
|
}
|
|
@@ -92,7 +92,7 @@ class u {
|
|
|
92
92
|
type: "code",
|
|
93
93
|
content: e
|
|
94
94
|
};
|
|
95
|
-
return t.diff != null && (i.diff = t.diff), t.lineNumbers != null && (i.lineNumbers = t.lineNumbers), t.id != null && (i.id = t.id), i;
|
|
95
|
+
return t.language != null && (i.language = t.language), t.diff != null && (i.diff = t.diff), t.lineNumbers != null && (i.lineNumbers = t.lineNumbers), t.id != null && (i.id = t.id), i;
|
|
96
96
|
}
|
|
97
97
|
async codeBlock(t) {
|
|
98
98
|
const i = {
|
|
@@ -273,10 +273,9 @@ class u {
|
|
|
273
273
|
await this.beforeBlock(), await this.afterBlock();
|
|
274
274
|
const e = {
|
|
275
275
|
type: "formatted-text",
|
|
276
|
-
text: t.text || ""
|
|
277
|
-
language: t.language
|
|
276
|
+
text: t.text || ""
|
|
278
277
|
};
|
|
279
|
-
return t.id != null && (e.id = t.id), e;
|
|
278
|
+
return t.language != null && (e.language = t.language), t.id != null && (e.id = t.id), e;
|
|
280
279
|
}
|
|
281
280
|
async header(t) {
|
|
282
281
|
await this.beforeBlock();
|
|
@@ -405,10 +404,9 @@ class u {
|
|
|
405
404
|
type: "quote",
|
|
406
405
|
icon: t.icon,
|
|
407
406
|
name: t.name,
|
|
408
|
-
content: e
|
|
409
|
-
url: t.url
|
|
407
|
+
content: e
|
|
410
408
|
};
|
|
411
|
-
return t.id != null && (i.id = t.id), 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), i;
|
|
412
410
|
}
|
|
413
411
|
async redacted(t) {
|
|
414
412
|
t.style == "block" ? await this.beforeBlock() : await this.beforeInline();
|
|
@@ -622,10 +620,9 @@ class u {
|
|
|
622
620
|
content: e,
|
|
623
621
|
attribution: i,
|
|
624
622
|
header: s,
|
|
625
|
-
media: r
|
|
626
|
-
original: t.original
|
|
623
|
+
media: r
|
|
627
624
|
};
|
|
628
|
-
return t.id != null && (n.id = t.id), n;
|
|
625
|
+
return t.original && (n.original = t.original), t.id != null && (n.id = t.id), n;
|
|
629
626
|
}
|
|
630
627
|
async date(t) {
|
|
631
628
|
await this.beforeInline();
|
|
@@ -857,7 +854,7 @@ class u {
|
|
|
857
854
|
return await this.document(t);
|
|
858
855
|
}
|
|
859
856
|
}
|
|
860
|
-
class
|
|
857
|
+
class g extends u {
|
|
861
858
|
async chooseChildren(t) {
|
|
862
859
|
const e = await super.chooseChildren(t), i = [];
|
|
863
860
|
for (const s of e)
|
|
@@ -890,7 +887,7 @@ class I extends u {
|
|
|
890
887
|
return i;
|
|
891
888
|
}
|
|
892
889
|
}
|
|
893
|
-
class
|
|
890
|
+
class k extends u {
|
|
894
891
|
async text(t) {
|
|
895
892
|
return t.text == "" ? null : t;
|
|
896
893
|
}
|
|
@@ -918,12 +915,19 @@ class T extends u {
|
|
|
918
915
|
stripLastText() {
|
|
919
916
|
this.lastText && (this.lastText.text.endsWith(" ") && (this.lastText.text = this.lastText.text.slice(0, -1)), this.lastText = null), this.stripWhitespace = !0;
|
|
920
917
|
}
|
|
918
|
+
async emoji(e) {
|
|
919
|
+
return this.lastText = null, this.stripWhitespace = !1, await super.emoji(e);
|
|
920
|
+
}
|
|
921
|
+
async badge(e) {
|
|
922
|
+
return this.lastText = null, this.stripWhitespace = !1, await super.badge(e);
|
|
923
|
+
}
|
|
921
924
|
async code(e) {
|
|
925
|
+
this.lastText = null, this.stripWhitespace = !1;
|
|
922
926
|
const i = {
|
|
923
927
|
type: "code",
|
|
924
928
|
content: e.content
|
|
925
929
|
};
|
|
926
|
-
return e.diff != null && (i.diff = e.diff), e.lineNumbers != null && (i.lineNumbers = e.lineNumbers), e.id != null && (i.id = e.id), i;
|
|
930
|
+
return e.language != null && (i.language = e.language), e.diff != null && (i.diff = e.diff), e.lineNumbers != null && (i.lineNumbers = e.lineNumbers), e.id != null && (i.id = e.id), i;
|
|
927
931
|
}
|
|
928
932
|
async beforeBlock() {
|
|
929
933
|
this.stripLastText();
|
|
@@ -933,7 +937,7 @@ class T extends u {
|
|
|
933
937
|
}
|
|
934
938
|
async transform(e) {
|
|
935
939
|
const i = await super.transform(e);
|
|
936
|
-
return await new
|
|
940
|
+
return await new k().transform(i);
|
|
937
941
|
}
|
|
938
942
|
}
|
|
939
943
|
class v extends u {
|
|
@@ -994,7 +998,7 @@ class v extends u {
|
|
|
994
998
|
type: "code",
|
|
995
999
|
content: e.content
|
|
996
1000
|
};
|
|
997
|
-
return e.diff != null && (i.diff = e.diff), e.lineNumbers != null && (i.lineNumbers = e.lineNumbers), e.id != null && (i.id = e.id), i;
|
|
1001
|
+
return e.language != null && (i.language = e.language), e.diff != null && (i.diff = e.diff), e.lineNumbers != null && (i.lineNumbers = e.lineNumbers), e.id != null && (i.id = e.id), i;
|
|
998
1002
|
}
|
|
999
1003
|
async text(e) {
|
|
1000
1004
|
const i = {
|
|
@@ -1343,7 +1347,7 @@ class m extends w {
|
|
|
1343
1347
|
return this.textList.join("");
|
|
1344
1348
|
}
|
|
1345
1349
|
}
|
|
1346
|
-
class B extends
|
|
1350
|
+
class B extends g {
|
|
1347
1351
|
async sticker(t) {
|
|
1348
1352
|
if (t.content.length == 0)
|
|
1349
1353
|
return null;
|
|
@@ -1616,7 +1620,7 @@ class N extends u {
|
|
|
1616
1620
|
}
|
|
1617
1621
|
}
|
|
1618
1622
|
export {
|
|
1619
|
-
|
|
1623
|
+
g as ArrayCollapseTransformer,
|
|
1620
1624
|
B as DocumentThinningTransformer,
|
|
1621
1625
|
u as IdentityTransformer,
|
|
1622
1626
|
w as NodeVisitor,
|
package/dist/types.d.ts
CHANGED