UNPKG

2.92 kBTypeScriptView Raw
1/**
2 * AST Node types list on TxtNode.
3 * Constant value of types
4 * @see https://github.com/textlint/textlint/blob/master/docs/txtnode.md
5 */
6import { TypeofTxtNode } from "./TypeofTxtNode";
7export declare enum ASTNodeTypes {
8 Document = "Document",
9 DocumentExit = "Document:exit",
10 Paragraph = "Paragraph",
11 ParagraphExit = "Paragraph:exit",
12 BlockQuote = "BlockQuote",
13 BlockQuoteExit = "BlockQuote:exit",
14 ListItem = "ListItem",
15 ListItemExit = "ListItem:exit",
16 List = "List",
17 ListExit = "List:exit",
18 Header = "Header",
19 HeaderExit = "Header:exit",
20 CodeBlock = "CodeBlock",
21 CodeBlockExit = "CodeBlock:exit",
22 HtmlBlock = "HtmlBlock",
23 HtmlBlockExit = "HtmlBlock:exit",
24 HorizontalRule = "HorizontalRule",
25 HorizontalRuleExit = "HorizontalRule:exit",
26 Comment = "Comment",
27 CommentExit = "Comment:exit",
28 /**
29 * @deprecated
30 */
31 ReferenceDef = "ReferenceDef",
32 /**
33 * @deprecated
34 */
35 ReferenceDefExit = "ReferenceDef:exit",
36 Str = "Str",
37 StrExit = "Str:exit",
38 Break = "Break",
39 BreakExit = "Break:exit",
40 Emphasis = "Emphasis",
41 EmphasisExit = "Emphasis:exit",
42 Strong = "Strong",
43 StrongExit = "Strong:exit",
44 Html = "Html",
45 HtmlExit = "Html:exit",
46 Link = "Link",
47 LinkExit = "Link:exit",
48 Image = "Image",
49 ImageExit = "Image:exit",
50 Code = "Code",
51 CodeExit = "Code:exit",
52 Delete = "Delete",
53 DeleteExit = "Delete:exit"
54}
55/**
56 * Key of ASTNodeTypes or any string
57 * For example, TxtNodeType is "Document".
58 */
59export declare type TxtNodeType = keyof typeof ASTNodeTypes | string;
60/**
61 * Type utility for TxtNodeType
62 * Return TxtNode interface for the TxtNodeTYpe
63 */
64export { TypeofTxtNode };
65/**
66 * Any TxtNode types
67 */
68export declare type AnyTxtNode = TxtNode | TxtTextNode | TxtParentNode;
69/**
70 * Basic TxtNode
71 * Probably, Real TxtNode implementation has more properties.
72 */
73export interface TxtNode {
74 type: TxtNodeType;
75 raw: string;
76 range: TextNodeRange;
77 loc: TxtNodeLineLocation;
78 parent?: TxtNode;
79 [index: string]: any;
80}
81/**
82 * Location
83 */
84export interface TxtNodeLineLocation {
85 start: TxtNodePosition;
86 end: TxtNodePosition;
87}
88/**
89 * Position's line start with 1.
90 * Position's column start with 0.
91 * This is for compatibility with JavaScript AST.
92 * https://gist.github.com/azu/8866b2cb9b7a933e01fe
93 */
94export interface TxtNodePosition {
95 line: number;
96 column: number;
97}
98/**
99 * Range start with 0
100 */
101export declare type TextNodeRange = [number, number];
102/**
103 * Text Node.
104 * Text Node has inline value.
105 * For example, `Str` Node is an TxtTextNode.
106 */
107export interface TxtTextNode extends TxtNode {
108 value: string;
109}
110/**
111 * Parent Node.
112 * Parent Node has children that are consist of TxtNode or TxtTextNode
113 */
114export interface TxtParentNode extends TxtNode {
115 children: Array<TxtNode | TxtTextNode>;
116}