text-doc-ir 0.0.3 → 0.0.6
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/esm/deps.d.ts +1 -1
- package/esm/main.d.ts +3 -1
- package/esm/main.js +27 -0
- package/package.json +2 -2
- package/script/deps.d.ts +1 -1
- package/script/main.d.ts +3 -1
- package/script/main.js +27 -0
package/esm/deps.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export { NodeVisitor } from "document-ir";
|
|
2
|
-
export type { BlockQuoteNode, BreakNode, BubbleNode, CardNode, CenterNode, ColumnsNode, DocumentNode, EmbedNode, EmojiNode, FigureImageNode, FormattedTextNode, HeaderNode, HighTechAlertNode, HorizontalRuleNode, ImageNode, LinkNode, ListNode, Node, NoteNode, ParagraphNode, QuoteNode, StickerNode, StrikeThroughNode, TextNode, VideoNode, WarningNode, } from "document-ir";
|
|
2
|
+
export type { BlockQuoteNode, BreakNode, BubbleNode, CardNode, CenterNode, ColumnsNode, DefinitionNode, DefinitionReferenceNode, DocumentNode, EmbedNode, EmojiNode, FigureImageNode, FormattedTextNode, HeaderNode, HighTechAlertNode, HorizontalRuleNode, ImageNode, LinkNode, ListNode, Node, NoteNode, ParagraphNode, QuoteNode, StickerNode, StrikeThroughNode, TextNode, VideoNode, WarningNode, } from "document-ir";
|
package/esm/main.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { BlockQuoteNode, BreakNode, BubbleNode, CardNode, CenterNode, ColumnsNode, DocumentNode, EmbedNode, EmojiNode, FigureImageNode, FormattedTextNode, HeaderNode, HighTechAlertNode, HorizontalRuleNode, ImageNode, LinkNode, ListNode, NodeVisitor, NoteNode, ParagraphNode, QuoteNode, StickerNode, StrikeThroughNode, TextNode, VideoNode, WarningNode } from "./deps.js";
|
|
1
|
+
import { BlockQuoteNode, BreakNode, BubbleNode, CardNode, CenterNode, ColumnsNode, DefinitionNode, DefinitionReferenceNode, DocumentNode, EmbedNode, EmojiNode, FigureImageNode, FormattedTextNode, HeaderNode, HighTechAlertNode, HorizontalRuleNode, ImageNode, LinkNode, ListNode, NodeVisitor, NoteNode, ParagraphNode, QuoteNode, StickerNode, StrikeThroughNode, TextNode, VideoNode, WarningNode } from "./deps.js";
|
|
2
2
|
export declare class FixedWidthTextVisitor extends NodeVisitor {
|
|
3
3
|
private width;
|
|
4
4
|
private lines;
|
|
@@ -34,6 +34,8 @@ export declare class FixedWidthTextVisitor extends NodeVisitor {
|
|
|
34
34
|
protected bubble(node: BubbleNode): void;
|
|
35
35
|
protected sticker(node: StickerNode): void;
|
|
36
36
|
protected card(node: CardNode): void;
|
|
37
|
+
protected definitionReference(node: DefinitionReferenceNode): void;
|
|
38
|
+
protected definition(node: DefinitionNode): void;
|
|
37
39
|
protected document(node: DocumentNode): void;
|
|
38
40
|
private counterToDepth;
|
|
39
41
|
private pushBlockContentBegin;
|
package/esm/main.js
CHANGED
|
@@ -583,6 +583,33 @@ export class FixedWidthTextVisitor extends NodeVisitor {
|
|
|
583
583
|
this.pushText("/");
|
|
584
584
|
this.pushBlockContentEnd();
|
|
585
585
|
}
|
|
586
|
+
definitionReference(node) {
|
|
587
|
+
this.visit({
|
|
588
|
+
type: "array",
|
|
589
|
+
content: [
|
|
590
|
+
...node.content,
|
|
591
|
+
],
|
|
592
|
+
});
|
|
593
|
+
}
|
|
594
|
+
definition(node) {
|
|
595
|
+
this.pushBlockContentBegin();
|
|
596
|
+
this.chooseChildren(node.title);
|
|
597
|
+
this.pushText(" (");
|
|
598
|
+
this.chooseChildren(node.abbreviation);
|
|
599
|
+
this.pushText("):");
|
|
600
|
+
this.pushLine();
|
|
601
|
+
const visitor = new FixedWidthTextVisitor(this.width - 2);
|
|
602
|
+
visitor.setState({ ...this.state, numericDepth: 0 });
|
|
603
|
+
visitor.visit({
|
|
604
|
+
type: "array",
|
|
605
|
+
content: node.content,
|
|
606
|
+
});
|
|
607
|
+
for (const line of visitor.getLines()) {
|
|
608
|
+
this.pushEndOfLineIfAnyContent();
|
|
609
|
+
this.lines[Math.max(0, this.lines.length - 1)] = " " + line;
|
|
610
|
+
}
|
|
611
|
+
this.pushBlockContentEnd();
|
|
612
|
+
}
|
|
586
613
|
document(node) {
|
|
587
614
|
this.pushBlockContentBegin();
|
|
588
615
|
let date;
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"module": "./esm/main.js",
|
|
3
3
|
"main": "./script/main.js",
|
|
4
4
|
"name": "text-doc-ir",
|
|
5
|
-
"version": "0.0.
|
|
5
|
+
"version": "0.0.6",
|
|
6
6
|
"description": "Transforms a document intermediate representation into plain text with formatting",
|
|
7
7
|
"license": "MIT",
|
|
8
8
|
"repository": {
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
}
|
|
20
20
|
},
|
|
21
21
|
"dependencies": {
|
|
22
|
-
"document-ir": "0.0.
|
|
22
|
+
"document-ir": "0.0.10"
|
|
23
23
|
},
|
|
24
24
|
"devDependencies": {
|
|
25
25
|
"@types/node": "^18.11.9"
|
package/script/deps.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export { NodeVisitor } from "document-ir";
|
|
2
|
-
export type { BlockQuoteNode, BreakNode, BubbleNode, CardNode, CenterNode, ColumnsNode, DocumentNode, EmbedNode, EmojiNode, FigureImageNode, FormattedTextNode, HeaderNode, HighTechAlertNode, HorizontalRuleNode, ImageNode, LinkNode, ListNode, Node, NoteNode, ParagraphNode, QuoteNode, StickerNode, StrikeThroughNode, TextNode, VideoNode, WarningNode, } from "document-ir";
|
|
2
|
+
export type { BlockQuoteNode, BreakNode, BubbleNode, CardNode, CenterNode, ColumnsNode, DefinitionNode, DefinitionReferenceNode, DocumentNode, EmbedNode, EmojiNode, FigureImageNode, FormattedTextNode, HeaderNode, HighTechAlertNode, HorizontalRuleNode, ImageNode, LinkNode, ListNode, Node, NoteNode, ParagraphNode, QuoteNode, StickerNode, StrikeThroughNode, TextNode, VideoNode, WarningNode, } from "document-ir";
|
package/script/main.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { BlockQuoteNode, BreakNode, BubbleNode, CardNode, CenterNode, ColumnsNode, DocumentNode, EmbedNode, EmojiNode, FigureImageNode, FormattedTextNode, HeaderNode, HighTechAlertNode, HorizontalRuleNode, ImageNode, LinkNode, ListNode, NodeVisitor, NoteNode, ParagraphNode, QuoteNode, StickerNode, StrikeThroughNode, TextNode, VideoNode, WarningNode } from "./deps.js";
|
|
1
|
+
import { BlockQuoteNode, BreakNode, BubbleNode, CardNode, CenterNode, ColumnsNode, DefinitionNode, DefinitionReferenceNode, DocumentNode, EmbedNode, EmojiNode, FigureImageNode, FormattedTextNode, HeaderNode, HighTechAlertNode, HorizontalRuleNode, ImageNode, LinkNode, ListNode, NodeVisitor, NoteNode, ParagraphNode, QuoteNode, StickerNode, StrikeThroughNode, TextNode, VideoNode, WarningNode } from "./deps.js";
|
|
2
2
|
export declare class FixedWidthTextVisitor extends NodeVisitor {
|
|
3
3
|
private width;
|
|
4
4
|
private lines;
|
|
@@ -34,6 +34,8 @@ export declare class FixedWidthTextVisitor extends NodeVisitor {
|
|
|
34
34
|
protected bubble(node: BubbleNode): void;
|
|
35
35
|
protected sticker(node: StickerNode): void;
|
|
36
36
|
protected card(node: CardNode): void;
|
|
37
|
+
protected definitionReference(node: DefinitionReferenceNode): void;
|
|
38
|
+
protected definition(node: DefinitionNode): void;
|
|
37
39
|
protected document(node: DocumentNode): void;
|
|
38
40
|
private counterToDepth;
|
|
39
41
|
private pushBlockContentBegin;
|
package/script/main.js
CHANGED
|
@@ -586,6 +586,33 @@ class FixedWidthTextVisitor extends deps_js_1.NodeVisitor {
|
|
|
586
586
|
this.pushText("/");
|
|
587
587
|
this.pushBlockContentEnd();
|
|
588
588
|
}
|
|
589
|
+
definitionReference(node) {
|
|
590
|
+
this.visit({
|
|
591
|
+
type: "array",
|
|
592
|
+
content: [
|
|
593
|
+
...node.content,
|
|
594
|
+
],
|
|
595
|
+
});
|
|
596
|
+
}
|
|
597
|
+
definition(node) {
|
|
598
|
+
this.pushBlockContentBegin();
|
|
599
|
+
this.chooseChildren(node.title);
|
|
600
|
+
this.pushText(" (");
|
|
601
|
+
this.chooseChildren(node.abbreviation);
|
|
602
|
+
this.pushText("):");
|
|
603
|
+
this.pushLine();
|
|
604
|
+
const visitor = new FixedWidthTextVisitor(this.width - 2);
|
|
605
|
+
visitor.setState({ ...this.state, numericDepth: 0 });
|
|
606
|
+
visitor.visit({
|
|
607
|
+
type: "array",
|
|
608
|
+
content: node.content,
|
|
609
|
+
});
|
|
610
|
+
for (const line of visitor.getLines()) {
|
|
611
|
+
this.pushEndOfLineIfAnyContent();
|
|
612
|
+
this.lines[Math.max(0, this.lines.length - 1)] = " " + line;
|
|
613
|
+
}
|
|
614
|
+
this.pushBlockContentEnd();
|
|
615
|
+
}
|
|
589
616
|
document(node) {
|
|
590
617
|
this.pushBlockContentBegin();
|
|
591
618
|
let date;
|