document-ir 0.5.4 → 0.6.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 { ArrayCollapseTransformer } from './ArrayCollapseTransformer.ts';
|
|
2
|
-
import { BubbleNode, CardNode, ColumnsNode, DefinitionListNode, FigureImageNode, HighTechAlertNode, ImageNode, Node, NoteNode, QuoteNode, RedactedNode, StickerNode, VideoNode } from './types.ts';
|
|
2
|
+
import { AdmonitionNode, BubbleNode, CardNode, ColumnsNode, DefinitionListNode, FigureImageNode, HighTechAlertNode, ImageNode, Node, NoteNode, QuoteNode, RedactedNode, StickerNode, VideoNode } from './types.ts';
|
|
3
3
|
export declare class DocumentThinningTransformer extends ArrayCollapseTransformer {
|
|
4
4
|
protected sticker(node: StickerNode): Promise<Node | null>;
|
|
5
5
|
protected bubble(node: BubbleNode): Promise<Node | null>;
|
|
@@ -11,6 +11,7 @@ export declare class DocumentThinningTransformer extends ArrayCollapseTransforme
|
|
|
11
11
|
protected video(node: VideoNode): Promise<Node | null>;
|
|
12
12
|
protected definitionList(node: DefinitionListNode): Promise<Node | null>;
|
|
13
13
|
protected redacted(_node: RedactedNode): Promise<Node | null>;
|
|
14
|
+
protected admonition(node: AdmonitionNode): Promise<Node | null>;
|
|
14
15
|
protected note(node: NoteNode): Promise<Node | null>;
|
|
15
16
|
protected card(node: CardNode): Promise<Node | null>;
|
|
16
17
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AccordionGroupNode, AccordionTabNode, ArrayNode, BadgeNode, BlockNode, BlockQuoteNode, BoldNode, BreakNode, BubbleNode, CardNode, CenterNode, CodeNode, CodeBlockNode, CodeGroupNode, CodeGroupTabNode, ColumnsNode, DateNode, DateTimeNode, DefinitionListNode, DefinitionNode, DefinitionReferenceNode, DocumentNode, EmbedNode, EmojiNode, FigureCaptionNode, FigureImageNode, FigureNode, FootnoteNode, FootnoteDisplayNode, FormattedTextNode, HeaderNode, HighTechAlertNode, HorizontalRuleNode, ImageNode, ItalicNode, LinkNode, ListNode, Node, NoteNode, PillNode, TimeRangeNode, ParagraphNode, QuoteNode, RedactedNode, RegionNode, ScriptNode, SecretNode, StyleNode, SmallerNode, SocialNode, StandardNode, StickerNode, StrikeThroughNode, SubTextNode, SuperTextNode, TableNode, TableOfContentsNode, TextNode, TimeNode, UnderlineNode, VideoNode, WarningNode } from './types.ts';
|
|
1
|
+
import { AccordionGroupNode, AccordionTabNode, AdmonitionNode, ArrayNode, BadgeNode, BlockNode, BlockQuoteNode, BoldNode, BreakNode, BubbleNode, CardNode, CenterNode, CodeNode, CodeBlockNode, CodeGroupNode, CodeGroupTabNode, ColumnsNode, DateNode, DateTimeNode, DefinitionListNode, DefinitionNode, DefinitionReferenceNode, DocumentNode, EmbedNode, EmojiNode, FigureCaptionNode, FigureImageNode, FigureNode, FootnoteNode, FootnoteDisplayNode, FormattedTextNode, HeaderNode, HighTechAlertNode, HorizontalRuleNode, ImageNode, ItalicNode, LinkNode, ListNode, Node, NoteNode, PillNode, TimeRangeNode, ParagraphNode, QuoteNode, RedactedNode, RegionNode, ScriptNode, SecretNode, StyleNode, SmallerNode, SocialNode, StandardNode, StickerNode, StrikeThroughNode, SubTextNode, SuperTextNode, TableNode, TableOfContentsNode, TextNode, TimeNode, UnderlineNode, VideoNode, WarningNode } from './types.ts';
|
|
2
2
|
export declare class IdentityTransformer {
|
|
3
3
|
protected beforeBlock(): Promise<void>;
|
|
4
4
|
protected afterBlock(): Promise<void>;
|
|
@@ -36,6 +36,7 @@ export declare class IdentityTransformer {
|
|
|
36
36
|
protected image(node: ImageNode): Promise<Node | null>;
|
|
37
37
|
protected italic(node: ItalicNode): Promise<Node | null>;
|
|
38
38
|
protected link(node: LinkNode): Promise<Node | null>;
|
|
39
|
+
protected admonition(node: AdmonitionNode): Promise<Node | null>;
|
|
39
40
|
protected array(node: ArrayNode): Promise<Node | null>;
|
|
40
41
|
protected note(node: NoteNode): Promise<Node | null>;
|
|
41
42
|
protected list(node: ListNode): Promise<Node | null>;
|
package/dist/NodeVisitor.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AccordionGroupNode, AccordionTabNode, ArrayNode, BadgeNode, BlockNode, BlockQuoteNode, BoldNode, BreakNode, BubbleNode, CardNode, CenterNode, CodeNode, CodeBlockNode, CodeGroupNode, CodeGroupTabNode, ColumnsNode, PillNode, StyleNode, DateNode, DateTimeNode, DefinitionListNode, DefinitionNode, DefinitionReferenceNode, DocumentNode, EmbedNode, EmojiNode, FigureCaptionNode, FigureImageNode, FigureNode, FootnoteNode, FootnoteDisplayNode, FormattedTextNode, HeaderNode, HighTechAlertNode, HorizontalRuleNode, ImageNode, ItalicNode, LinkNode, ListNode, Node, NoteNode, TimeRangeNode, ParagraphNode, QuoteNode, RedactedNode, RegionNode, ScriptNode, SecretNode, SmallerNode, SocialNode, StandardNode, StickerNode, StrikeThroughNode, SubTextNode, SuperTextNode, TableNode, TableOfContentsNode, TextNode, TimeNode, UnderlineNode, VideoNode, WarningNode } from './types.ts';
|
|
1
|
+
import { AccordionGroupNode, AccordionTabNode, AdmonitionNode, ArrayNode, BadgeNode, BlockNode, BlockQuoteNode, BoldNode, BreakNode, BubbleNode, CardNode, CenterNode, CodeNode, CodeBlockNode, CodeGroupNode, CodeGroupTabNode, ColumnsNode, PillNode, StyleNode, DateNode, DateTimeNode, DefinitionListNode, DefinitionNode, DefinitionReferenceNode, DocumentNode, EmbedNode, EmojiNode, FigureCaptionNode, FigureImageNode, FigureNode, FootnoteNode, FootnoteDisplayNode, FormattedTextNode, HeaderNode, HighTechAlertNode, HorizontalRuleNode, ImageNode, ItalicNode, LinkNode, ListNode, Node, NoteNode, TimeRangeNode, ParagraphNode, QuoteNode, RedactedNode, RegionNode, ScriptNode, SecretNode, SmallerNode, SocialNode, StandardNode, StickerNode, StrikeThroughNode, SubTextNode, SuperTextNode, TableNode, TableOfContentsNode, TextNode, TimeNode, UnderlineNode, VideoNode, WarningNode } from './types.ts';
|
|
2
2
|
export declare class NodeVisitor {
|
|
3
3
|
protected beforeBlock(): void;
|
|
4
4
|
protected afterBlock(): void;
|
|
@@ -38,6 +38,7 @@ export declare class NodeVisitor {
|
|
|
38
38
|
protected image(_node: ImageNode): void;
|
|
39
39
|
protected italic(node: ItalicNode): void;
|
|
40
40
|
protected link(node: LinkNode): void;
|
|
41
|
+
protected admonition(node: AdmonitionNode): void;
|
|
41
42
|
protected array(node: ArrayNode): void;
|
|
42
43
|
protected note(node: NoteNode): void;
|
|
43
44
|
protected list(node: ListNode): void;
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
var
|
|
2
|
-
var k = (c, t, e) => t in c ?
|
|
1
|
+
var d = Object.defineProperty;
|
|
2
|
+
var k = (c, t, e) => t in c ? d(c, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : c[t] = e;
|
|
3
3
|
var h = (c, t, e) => k(c, typeof t != "symbol" ? t + "" : t, e);
|
|
4
4
|
class u {
|
|
5
5
|
async beforeBlock() {
|
|
@@ -338,6 +338,18 @@ class u {
|
|
|
338
338
|
};
|
|
339
339
|
return t.id != null && (i.id = t.id), t.title && (i.title = t.title), t.target && (i.target = t.target), t.userGeneratedContent && (i.userGeneratedContent = t.userGeneratedContent), t.noReferrer && (i.noReferrer = t.noReferrer), t.noFollow && (i.noFollow = t.noFollow), t.noOpener && (i.noOpener = t.noOpener), i;
|
|
340
340
|
}
|
|
341
|
+
async admonition(t) {
|
|
342
|
+
t.inline || await this.beforeBlock();
|
|
343
|
+
const e = await this.chooseChildren(t.content);
|
|
344
|
+
let i;
|
|
345
|
+
t.title && (i = await this.chooseChildren(t.title)), t.inline || await this.afterBlock();
|
|
346
|
+
const s = {
|
|
347
|
+
type: "admonition",
|
|
348
|
+
admonitionType: t.admonitionType,
|
|
349
|
+
content: e
|
|
350
|
+
};
|
|
351
|
+
return i && (s.title = i), t.collapsable != null && (s.collapsable = t.collapsable), t.collapsed != null && (s.collapsed = t.collapsed), t.inline != null && (s.inline = t.inline), t.id != null && (s.id = t.id), s;
|
|
352
|
+
}
|
|
341
353
|
async array(t) {
|
|
342
354
|
const e = {
|
|
343
355
|
type: "array",
|
|
@@ -767,6 +779,8 @@ class u {
|
|
|
767
779
|
return await this.link(t);
|
|
768
780
|
case "accordion-group":
|
|
769
781
|
return await this.accordionGroup(t);
|
|
782
|
+
case "admonition":
|
|
783
|
+
return await this.admonition(t);
|
|
770
784
|
case "array":
|
|
771
785
|
return await this.array(t);
|
|
772
786
|
case "note":
|
|
@@ -1133,6 +1147,9 @@ class w {
|
|
|
1133
1147
|
link(t) {
|
|
1134
1148
|
this.beforeInline(), this.chooseChildren(t.content), this.afterInline();
|
|
1135
1149
|
}
|
|
1150
|
+
admonition(t) {
|
|
1151
|
+
t.inline || this.beforeBlock(), t.title && this.chooseChildren(t.title), this.chooseChildren(t.content), t.inline || this.afterBlock();
|
|
1152
|
+
}
|
|
1136
1153
|
array(t) {
|
|
1137
1154
|
this.chooseChildren(t.content);
|
|
1138
1155
|
}
|
|
@@ -1245,6 +1262,8 @@ class w {
|
|
|
1245
1262
|
return this.codeGroup(t);
|
|
1246
1263
|
case "accordion-group":
|
|
1247
1264
|
return this.accordionGroup(t);
|
|
1265
|
+
case "admonition":
|
|
1266
|
+
return this.admonition(t);
|
|
1248
1267
|
case "pill":
|
|
1249
1268
|
return this.pill(t);
|
|
1250
1269
|
case "style":
|
|
@@ -1533,6 +1552,18 @@ class C extends g {
|
|
|
1533
1552
|
async redacted(t) {
|
|
1534
1553
|
return null;
|
|
1535
1554
|
}
|
|
1555
|
+
async admonition(t) {
|
|
1556
|
+
if (t.content.length == 0)
|
|
1557
|
+
return null;
|
|
1558
|
+
const e = await this.chooseChildren(t.content);
|
|
1559
|
+
return e ? {
|
|
1560
|
+
type: "paragraph",
|
|
1561
|
+
content: [
|
|
1562
|
+
{ type: "text", text: `${t.admonitionType.charAt(0).toUpperCase() + t.admonitionType.slice(1)}: ` },
|
|
1563
|
+
...e
|
|
1564
|
+
]
|
|
1565
|
+
} : null;
|
|
1566
|
+
}
|
|
1536
1567
|
async note(t) {
|
|
1537
1568
|
if (t.content.length == 0)
|
|
1538
1569
|
return null;
|
|
@@ -1608,7 +1639,7 @@ class x extends w {
|
|
|
1608
1639
|
return this.countText(), this.count;
|
|
1609
1640
|
}
|
|
1610
1641
|
}
|
|
1611
|
-
function
|
|
1642
|
+
function y(c) {
|
|
1612
1643
|
const t = {
|
|
1613
1644
|
headerText: c.header,
|
|
1614
1645
|
headerId: c.headerId,
|
|
@@ -1620,7 +1651,7 @@ function d(c) {
|
|
|
1620
1651
|
e.visit(i);
|
|
1621
1652
|
t.words = e.getCount(), t.totalWords = t.words;
|
|
1622
1653
|
for (const i of c.children) {
|
|
1623
|
-
const s =
|
|
1654
|
+
const s = y(i);
|
|
1624
1655
|
t.children.push(s), t.totalWords += s.totalWords;
|
|
1625
1656
|
}
|
|
1626
1657
|
return t;
|
|
@@ -1660,7 +1691,7 @@ class _ extends u {
|
|
|
1660
1691
|
const a = {
|
|
1661
1692
|
...t
|
|
1662
1693
|
};
|
|
1663
|
-
return a.hierarchy =
|
|
1694
|
+
return a.hierarchy = y(r), a;
|
|
1664
1695
|
}
|
|
1665
1696
|
}
|
|
1666
1697
|
export {
|
package/dist/types.d.ts
CHANGED
|
@@ -1,6 +1,16 @@
|
|
|
1
1
|
export interface NodeIdentity {
|
|
2
2
|
id?: string;
|
|
3
3
|
}
|
|
4
|
+
export type AdmonitionType = "note" | "tip" | "info" | "warning" | "danger";
|
|
5
|
+
export interface AdmonitionNode extends NodeIdentity {
|
|
6
|
+
type: "admonition";
|
|
7
|
+
admonitionType: AdmonitionType;
|
|
8
|
+
content: Node[];
|
|
9
|
+
title?: Node[];
|
|
10
|
+
collapsable?: boolean;
|
|
11
|
+
collapsed?: boolean;
|
|
12
|
+
inline?: boolean;
|
|
13
|
+
}
|
|
4
14
|
export interface ArrayNode extends NodeIdentity {
|
|
5
15
|
type: "array";
|
|
6
16
|
content: Node[];
|
|
@@ -397,7 +407,7 @@ export interface TableOfContentsNode extends NodeIdentity {
|
|
|
397
407
|
content: Node[];
|
|
398
408
|
children: TableOfContentsNode[];
|
|
399
409
|
}
|
|
400
|
-
export type Node = AccordionGroupNode | ArrayNode | BadgeNode | BlockNode | BlockQuoteNode | BoldNode | BreakNode | BubbleNode | CardNode | CenterNode | CodeNode | CodeBlockNode | CodeGroupNode | ColumnsNode | DefinitionNode | DefinitionListNode | DefinitionReferenceNode | EmbedNode | EmojiNode | FigureNode | FigureCaptionNode | FigureImageNode | FootnoteNode | FootnoteDisplayNode | FormattedTextNode | HeaderNode | HighTechAlertNode | HorizontalRuleNode | ImageNode | ItalicNode | LinkNode | ListNode | NoteNode | ParagraphNode | PillNode | QuoteNode | RedactedNode | RegionNode | ScriptNode | SecretNode | StyleNode | SmallerNode | StickerNode | StrikeThroughNode | TextNode | TableNode | SocialNode | UnderlineNode | VideoNode | DateNode | TimeNode | DateTimeNode | SuperTextNode | SubTextNode | TableOfContentsNode | TimeRangeNode | StandardNode | WarningNode;
|
|
410
|
+
export type Node = AccordionGroupNode | AdmonitionNode | ArrayNode | BadgeNode | BlockNode | BlockQuoteNode | BoldNode | BreakNode | BubbleNode | CardNode | CenterNode | CodeNode | CodeBlockNode | CodeGroupNode | ColumnsNode | DefinitionNode | DefinitionListNode | DefinitionReferenceNode | EmbedNode | EmojiNode | FigureNode | FigureCaptionNode | FigureImageNode | FootnoteNode | FootnoteDisplayNode | FormattedTextNode | HeaderNode | HighTechAlertNode | HorizontalRuleNode | ImageNode | ItalicNode | LinkNode | ListNode | NoteNode | ParagraphNode | PillNode | QuoteNode | RedactedNode | RegionNode | ScriptNode | SecretNode | StyleNode | SmallerNode | StickerNode | StrikeThroughNode | TextNode | TableNode | SocialNode | UnderlineNode | VideoNode | DateNode | TimeNode | DateTimeNode | SuperTextNode | SubTextNode | TableOfContentsNode | TimeRangeNode | StandardNode | WarningNode;
|
|
401
411
|
export interface DocumentMeta {
|
|
402
412
|
hidden?: boolean;
|
|
403
413
|
noindex?: boolean;
|