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
//! Inline-level event types.
use crate::Range;
/// Events emitted by the inline parser.
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum InlineEvent {
/// Plain text content.
Text(Range),
/// Inline code content (already resolved, no further parsing).
Code(Range),
/// Start of emphasis (`*em*` or `_em_`).
EmphasisStart,
/// End of emphasis.
EmphasisEnd,
/// Start of strong emphasis (`**strong**` or `__strong__`).
StrongStart,
/// End of strong emphasis.
StrongEnd,
/// Start of strikethrough (`~~text~~`).
StrikethroughStart,
/// End of strikethrough.
StrikethroughEnd,
/// Start of subscript (`~text~`).
SubscriptStart,
/// End of subscript.
SubscriptEnd,
/// Start of superscript (`^text^`).
SuperscriptStart,
/// End of superscript.
SuperscriptEnd,
/// Start of highlight/mark (`==text==`).
HighlightStart,
/// End of highlight/mark.
HighlightEnd,
/// Start of a link `[text](url)`.
LinkStart {
/// URL destination.
url: Range,
/// Optional title.
title: Option<Range>,
},
/// Start of a reference-style link `[text][label]`.
LinkStartRef {
/// Index into the link reference store.
def_index: u32,
},
/// End of a link.
LinkEnd,
/// Start of an image ``.
ImageStart {
/// URL destination.
url: Range,
/// Optional title.
title: Option<Range>,
},
/// Start of a reference-style image `![alt][label]`.
ImageStartRef {
/// Index into the link reference store.
def_index: u32,
},
/// End of an image (after alt text).
ImageEnd,
/// Autolink `<url>` or `<email>`.
Autolink {
/// The URL or email.
url: Range,
/// Whether this is an email autolink.
is_email: bool,
},
/// Autolink literal (bare URL, www link, or email without angle brackets).
AutolinkLiteral {
/// The matched text range.
url: Range,
/// Kind of autolink literal.
kind: crate::inline::links::AutolinkLiteralKind,
},
/// Raw inline HTML (not escaped or parsed).
Html(Range),
/// Soft line break (newline in source).
SoftBreak,
/// Hard line break (two spaces + newline or backslash + newline).
HardBreak,
/// Backslash escape - the escaped character.
EscapedChar(u8),
/// Footnote reference `[^label]`.
FootnoteRef {
/// Index into the footnote store.
def_index: u32,
},
/// Pandoc-style inline footnote content from `^[...]`.
///
/// The range covers only the note content, without `^[` and `]`.
InlineFootnote(Range),
/// Inline math span (`$...$`).
MathInline(Range),
/// Display math span (`$$...$$`).
MathDisplay(Range),
/// An inline MDX JavaScript expression, including its `{` and `}` delimiters.
#[cfg(feature = "mdx")]
MdxExpression(Range),
/// An inline MDX JSX opening tag, including its delimiters.
#[cfg(feature = "mdx")]
MdxJsxOpen(Range),
/// An inline MDX JSX closing tag, including its delimiters.
#[cfg(feature = "mdx")]
MdxJsxClose(Range),
/// An inline MDX JSX self-closing tag, including its delimiters.
#[cfg(feature = "mdx")]
MdxJsxSelfClose(Range),
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_event_size() {
// Events should be reasonably small (Link/Image have url + Option<Range>)
assert!(std::mem::size_of::<InlineEvent>() <= 32);
}
}