text-doc-ir 0.0.2

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.
@@ -0,0 +1,3 @@
1
+ {
2
+ "type": "module"
3
+ }
package/package.json ADDED
@@ -0,0 +1,27 @@
1
+ {
2
+ "module": "./esm/main.js",
3
+ "main": "./script/main.js",
4
+ "name": "text-doc-ir",
5
+ "version": "0.0.2",
6
+ "description": "Transforms a document intermediate representation into plain text with formatting",
7
+ "license": "MIT",
8
+ "repository": {
9
+ "type": "git",
10
+ "url": "git+https://github.com/cendyne/text-doc-ir.git"
11
+ },
12
+ "bugs": {
13
+ "url": "https://github.com/cendyne/text-doc-ir/issues"
14
+ },
15
+ "exports": {
16
+ ".": {
17
+ "import": "./esm/main.js",
18
+ "require": "./script/main.js"
19
+ }
20
+ },
21
+ "dependencies": {
22
+ "document-ir": "0.0.8"
23
+ },
24
+ "devDependencies": {
25
+ "@types/node": "^18.11.9"
26
+ }
27
+ }
@@ -0,0 +1,4 @@
1
+ export declare function encodeBase(keys: string[], num: number, shift: boolean): string;
2
+ export declare const NUMERIC: string[];
3
+ export declare const UPPER_ALPHA: string[];
4
+ export declare const LOWER_ALPHA: string[];
@@ -0,0 +1,31 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.LOWER_ALPHA = exports.UPPER_ALPHA = exports.NUMERIC = exports.encodeBase = void 0;
4
+ function encodeBase(keys, num, shift) {
5
+ const output = [];
6
+ if (shift && num == 0) {
7
+ return "";
8
+ }
9
+ do {
10
+ const mod = num % keys.length;
11
+ let next = Math.floor((num - mod) / keys.length);
12
+ if (shift) {
13
+ if (mod == 0) {
14
+ next--;
15
+ output.push(keys[keys.length - 1]);
16
+ }
17
+ else {
18
+ output.push(keys[mod - 1]);
19
+ }
20
+ }
21
+ else {
22
+ output.push(keys[mod]);
23
+ }
24
+ num = next;
25
+ } while (num > 0);
26
+ return output.reverse().join("");
27
+ }
28
+ exports.encodeBase = encodeBase;
29
+ exports.NUMERIC = "0123456789".split("");
30
+ exports.UPPER_ALPHA = "ABCDEFGHIJKLMNOPQRSTUVWXYZ".split("");
31
+ exports.LOWER_ALPHA = "abcdefghijklmnopqrstuvwxyz".split("");
@@ -0,0 +1,2 @@
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";
package/script/deps.js ADDED
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.NodeVisitor = void 0;
4
+ var document_ir_1 = require("document-ir");
5
+ Object.defineProperty(exports, "NodeVisitor", { enumerable: true, get: function () { return document_ir_1.NodeVisitor; } });
@@ -0,0 +1,46 @@
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";
2
+ export declare class FixedWidthTextVisitor extends NodeVisitor {
3
+ private width;
4
+ private lines;
5
+ private lazyLines;
6
+ private breakLazy;
7
+ private spaceLazy;
8
+ private breakCount;
9
+ private state;
10
+ constructor(width: number);
11
+ private setState;
12
+ protected text(node: TextNode): void;
13
+ protected formattedText(node: FormattedTextNode): void;
14
+ protected horizontalRule(node: HorizontalRuleNode): void;
15
+ protected break_(node: BreakNode): void;
16
+ protected paragraph(node: ParagraphNode): void;
17
+ protected list(node: ListNode): void;
18
+ protected columns(node: ColumnsNode): void;
19
+ protected link(node: LinkNode): void;
20
+ protected image(node: ImageNode): void;
21
+ protected figureImage(node: FigureImageNode): void;
22
+ protected emoji(node: EmojiNode): void;
23
+ protected video(node: VideoNode): void;
24
+ protected embed(node: EmbedNode): void;
25
+ protected header(node: HeaderNode): void;
26
+ protected strikeThrough(node: StrikeThroughNode): void;
27
+ protected note(node: NoteNode): void;
28
+ protected center(node: CenterNode): void;
29
+ protected warning(node: WarningNode): void;
30
+ protected highTechAlert(node: HighTechAlertNode): void;
31
+ protected blockQuote(node: BlockQuoteNode): void;
32
+ protected quote(node: QuoteNode): void;
33
+ protected bubble(node: BubbleNode): void;
34
+ protected sticker(node: StickerNode): void;
35
+ protected card(node: CardNode): void;
36
+ protected document(node: DocumentNode): void;
37
+ private counterToDepth;
38
+ private pushBlockContentBegin;
39
+ private pushBlockContentEnd;
40
+ private pushLazyLines;
41
+ private pushEndOfLineIfAnyContent;
42
+ private getLastLine;
43
+ private pushText;
44
+ private pushLine;
45
+ getLines(): readonly string[];
46
+ }