document-ir 0.4.0 → 0.4.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.
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { IdentityTransformer } from './IdentityTransformer.ts';
|
|
2
|
-
import { DocumentNode, Node, TextNode } from './types.ts';
|
|
2
|
+
import { CodeNode, DocumentNode, Node, TextNode } from './types.ts';
|
|
3
3
|
interface BlockInfo {
|
|
4
4
|
type: "_block";
|
|
5
5
|
content: WhiteSpaceContainer[];
|
|
@@ -20,6 +20,7 @@ export declare class WhitespaceStretchingTransformer extends IdentityTransformer
|
|
|
20
20
|
protected beforeInline(): Promise<void>;
|
|
21
21
|
protected afterInline(): Promise<void>;
|
|
22
22
|
protected reviewBlock(block: BlockInfo): void;
|
|
23
|
+
protected code(node: CodeNode): Promise<Node | null>;
|
|
23
24
|
protected text(node: TextNode): Promise<Node | null>;
|
|
24
25
|
transform(node: DocumentNode): Promise<DocumentNode>;
|
|
25
26
|
}
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { IdentityTransformer } from './IdentityTransformer.ts';
|
|
2
|
-
import { DocumentNode, Node, TextNode } from './types.ts';
|
|
2
|
+
import { CodeNode, DocumentNode, 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 code(node: CodeNode): Promise<Node | null>;
|
|
9
10
|
protected beforeBlock(): Promise<void>;
|
|
10
11
|
protected afterBlock(): Promise<void>;
|
|
11
12
|
transform(node: DocumentNode): Promise<DocumentNode>;
|
package/dist/index.js
CHANGED
|
@@ -918,6 +918,13 @@ class T extends u {
|
|
|
918
918
|
stripLastText() {
|
|
919
919
|
this.lastText && (this.lastText.text.endsWith(" ") && (this.lastText.text = this.lastText.text.slice(0, -1)), this.lastText = null), this.stripWhitespace = !0;
|
|
920
920
|
}
|
|
921
|
+
async code(e) {
|
|
922
|
+
const i = {
|
|
923
|
+
type: "code",
|
|
924
|
+
content: e.content
|
|
925
|
+
};
|
|
926
|
+
return e.diff != null && (i.diff = e.diff), e.lineNumbers != null && (i.lineNumbers = e.lineNumbers), e.id != null && (i.id = e.id), i;
|
|
927
|
+
}
|
|
921
928
|
async beforeBlock() {
|
|
922
929
|
this.stripLastText();
|
|
923
930
|
}
|
|
@@ -982,6 +989,13 @@ class v extends u {
|
|
|
982
989
|
!n.node || !a.node || n.level != a.level && (n.level < a.level ? a.node.text.startsWith(" ") && (a.node.text = a.node.text.slice(1), n.node.text += " ") : n.level > a.level && n.node.text.endsWith(" ") && (n.node.text = n.node.text.slice(0, -1), a.node.text = ` ${a.node.text}`));
|
|
983
990
|
}
|
|
984
991
|
}
|
|
992
|
+
async code(e) {
|
|
993
|
+
const i = {
|
|
994
|
+
type: "code",
|
|
995
|
+
content: e.content
|
|
996
|
+
};
|
|
997
|
+
return e.diff != null && (i.diff = e.diff), e.lineNumbers != null && (i.lineNumbers = e.lineNumbers), e.id != null && (i.id = e.id), i;
|
|
998
|
+
}
|
|
985
999
|
async text(e) {
|
|
986
1000
|
const i = {
|
|
987
1001
|
type: "text",
|