/
CMNode.h
181 lines (148 loc) · 3.74 KB
/
CMNode.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
//
// CMNode.h
// CocoaMarkdown
//
// Created by Indragie on 1/12/15.
// Copyright (c) 2015 Indragie Karunaratne. All rights reserved.
//
#import <Foundation/Foundation.h>
@class CMIterator;
typedef NS_ENUM(NSInteger, CMNodeType) {
/* Error status */
CMNodeTypeNone,
/* Block */
CMNodeTypeDocument,
CMNodeTypeBlockQuote,
CMNodeTypeList,
CMNodeTypeItem,
CMNodeTypeCodeBlock,
CMNodeTypeHTML,
CMNodeTypeCustomBlock,
CMNodeTypeParagraph,
CMNodeTypeHeader,
CMNodeTypeHRule,
CMNodeTypeFirstBlock = CMNodeTypeDocument,
CMNodeTypeLastBlock = CMNodeTypeHRule,
/* Inline */
CMNodeTypeText,
CMNodeTypeSoftbreak,
CMNodeTypeLinebreak,
CMNodeTypeCode,
CMNodeTypeInlineHTML,
CMNodeTypeCustomInline,
CMNodeTypeEmphasis,
CMNodeTypeStrong,
CMNodeTypeLink,
CMNodeTypeImage,
CMNodeTypeFirstInline = CMNodeTypeText,
CMNodeTypeLastInline = CMNodeTypeImage
};
typedef NS_ENUM(NSInteger, CMListType) {
CMListTypeNone,
CMListTypeUnordered,
CMListTypeOrdered
};
typedef NS_ENUM(NSInteger, CMDelimeterType) {
CMDelimeterTypeNone,
CMDelimeterTypePeriod,
CMDelimeterTypeParen
};
/**
* Immutable interface to a CommonMark node.
*/
@interface CMNode : NSObject
/**
* Creates an iterator for the node tree that has the
* receiver as its root.
*
* @return A new iterator.
*/
- (CMIterator *)iterator;
/**
* The next node in the sequence, or `nil` if there is none.
*/
@property (readonly) CMNode *next;
/**
* The previous node in the sequence, or `nil` if there is none.
*/
@property (readonly) CMNode *previous;
/**
* The receiver's parent node, or `nil` if there is none.
*/
@property (readonly) CMNode *parent;
/**
* The first child node of the receiver, or `nil` if there is none.
*/
@property (readonly) CMNode *firstChild;
/**
* The last child node of the receiver, or `nil` if there is none.
*/
@property (readonly) CMNode *lastChild;
/**
* The type of the node, or `CMNodeTypeNone` on error.
*/
@property (readonly) CMNodeType type;
/**
* String representation of `type`.
*/
@property (readonly) NSString *humanReadableType;
/**
* String contents of the receiver, or `nil` if there is none.
*/
@property (readonly) NSString *stringValue;
/**
* Header level of the receiver, or `0` if the receiver is not a header.
*/
@property (readonly) NSInteger headerLevel;
/**
* Info string from a fenced code block, or `nil` if there is none.
*/
@property (readonly) NSString *fencedCodeInfo;
/**
* The receiver's list type, or `CMListTypeNone` if the receiver
* is not a list.
*/
@property (readonly) CMListType listType;
/**
* The receiver's list delimeter type, or `CMDelimeterTypeNone` if the
* receiver is not a list.
*/
@property (readonly) CMDelimeterType listDelimeterType;
/**
* Starting number of the list, or `0` if the receiver is not
* an ordered list.
*/
@property (readonly) NSInteger listStartingNumber;
/**
* `YES` if the receiver is a tight list, `NO` otherwise.
*/
@property (readonly) BOOL listTight;
/**
* Link or image URL string (as set in the document), or `nil` if there is none.
*/
@property (readonly) NSString *URLString;
/**
* Link or image URL, or `nil` if there is none.
*/
@property (readonly) NSURL *URL;
/**
* Link or image title, or `nil` if there is none.
*/
@property (readonly) NSString *title;
/**
* The line on which the receiver begins.
*/
@property (readonly) NSInteger startLine;
/**
* The column on which the receiver begins.
*/
@property (readonly) NSInteger startColumn;
/**
* The line on which the receiver ends.
*/
@property (readonly) NSInteger endLine;
/**
* The column on which the receiver ends.
*/
@property (readonly) NSInteger endColumn;
@end