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.
package/LICENSE ADDED
@@ -0,0 +1,19 @@
1
+ Copyright (c) 2023 Cendyne
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ of this software and associated documentation files (the "Software"), to deal
5
+ in the Software without restriction, including without limitation the rights
6
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
+ copies of the Software, and to permit persons to whom the Software is
8
+ furnished to do so, subject to the following conditions:
9
+
10
+ The above copyright notice and this permission notice shall be included in all
11
+ copies or substantial portions of the Software.
12
+
13
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,3 @@
1
+ # Text Document IR
2
+
3
+ This library breaks document texts into fixed width environments.
@@ -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,27 @@
1
+ export function encodeBase(keys, num, shift) {
2
+ const output = [];
3
+ if (shift && num == 0) {
4
+ return "";
5
+ }
6
+ do {
7
+ const mod = num % keys.length;
8
+ let next = Math.floor((num - mod) / keys.length);
9
+ if (shift) {
10
+ if (mod == 0) {
11
+ next--;
12
+ output.push(keys[keys.length - 1]);
13
+ }
14
+ else {
15
+ output.push(keys[mod - 1]);
16
+ }
17
+ }
18
+ else {
19
+ output.push(keys[mod]);
20
+ }
21
+ num = next;
22
+ } while (num > 0);
23
+ return output.reverse().join("");
24
+ }
25
+ export const NUMERIC = "0123456789".split("");
26
+ export const UPPER_ALPHA = "ABCDEFGHIJKLMNOPQRSTUVWXYZ".split("");
27
+ export const LOWER_ALPHA = "abcdefghijklmnopqrstuvwxyz".split("");
package/esm/deps.d.ts ADDED
@@ -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/esm/deps.js ADDED
@@ -0,0 +1 @@
1
+ export { NodeVisitor } from "document-ir";
package/esm/main.d.ts ADDED
@@ -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
+ }