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
|
/// A lexical token over Norg source.
public struct NorgToken: Equatable, Sendable {
/// What a token represents.
public enum Kind: Equatable, Sendable {
// MARK: Block / line level
/// A heading marker run (`*`…), carrying its level.
case heading(level: Int)
/// An unordered-list marker run (`-`…).
case unorderedList(level: Int)
/// An ordered-list marker run (`~`…).
case orderedList(level: Int)
/// A quote marker run (`>`…).
case quote(level: Int)
/// A definition marker run (`$`…).
case definition(level: Int)
/// A footnote marker run (`^`…).
case footnote(level: Int)
/// A table-cell marker run (`:`…).
case tableCell(level: Int)
/// A task status marker including its parentheses, eg. `(x)`.
case taskStatus(TaskStatus)
/// A weak delimiting line (`---`).
case weakDelimiter
/// A strong delimiting line (`===`).
case strongDelimiter
/// A horizontal rule (`___`).
case horizontalRule
/// A ranged-tag fence marker: the `@` of an opener and of `@end`.
case tagDelimiter
/// A ranged-tag header after `@` (name and parameters), eg. `code swift`.
case tagName
/// A raw body line inside a ranged tag (`@code` … `@end`).
case verbatimBlock
// MARK: Inline level
/// An attached- or verbatim-modifier delimiter (`*`, `/`, `` ` ``, `$`, …);
/// the style identifies which.
case modifierDelimiter(InlineStyle)
/// A run of text carrying a non-empty cumulative style (the content of one
/// or more nested modifiers).
case styledText(InlineStyle)
/// An inline comment, markers included (`%…%`).
case comment
/// An escape: the backslash of `\x` (the escaped character is not a token).
case escape
/// A link/anchor delimiter: `{`, `}`, `[`, or `]`.
case linkDelimiter
/// A link/anchor location (inside `{…}`).
case linkTarget
/// A link/anchor description or label (inside `[…]`).
case linkDescription
}
public let kind: Kind
public let range: Range<String.Index>
public init(kind: Kind, range: Range<String.Index>) {
self.kind = kind
self.range = range
}
}
|