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
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
/*
* Copyright (c) 2024-2025 R3BL LLC
* All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
//! This is the lowest priority parser called by
//! [crate::parse_inline_fragments_until_eol_or_eoi()].
//!
//! It matches anything that is not a special character. This is used to parse plain text.
//! It works with the specialized parsers in
//! [crate::parse_inline_fragments_until_eol_or_eoi()] such as:
//! - [crate::parse_fragment_starts_with_underscore_err_on_new_line()],
//! - [crate::parse_fragment_starts_with_star_err_on_new_line()],
//! - [crate::parse_fragment_starts_with_backtick_err_on_new_line()], etc.
//!
//! It also works hand in hand with
//! [specialized_parser_delim_matchers::take_starts_with_delim_no_new_line()] which is
//! used by the specialized parsers.
//!
//! To see this in action, set the [DEBUG_MD_PARSER_STDOUT] to true, and run all the tests
//! in [crate::parse_fragments_in_a_line].
use ;
use crate::;
// XMARK: Lowest priority parser for "plain text" Markdown fragment
/// This is the lowest priority parser called by
/// [crate::parse_inline_fragments_until_eol_or_eoi()], which itself is called:
/// 1. Repeatedly in a loop by
/// [crate::parse_block_markdown_text_with_or_without_new_line()].
/// 2. And by [crate::parse_block_markdown_text_with_checkbox_policy_with_or_without_new_line()].
///
/// It will match anything that is not a special character. This is used to parse plain
/// text.
///
/// However, when it encounters a special character, it will break the input at that
/// character and split the input into two parts, and return them:
/// 1. The plain text.
/// 2. And the remainder (after the special character).
///
/// This gives the other more specialized parsers a chance to address these special
/// characters (like italic, bold, links, etc.), when this function is called repeatedly:
/// - By [crate::parse_block_markdown_text_with_or_without_new_line()],
/// - Which repeatedly calls [crate::parse_inline_fragments_until_eol_or_eoi()]. This
/// function actually runs the specialized parsers.
/// - Which calls this function repeatedly (if the specialized parsers don't match & error
/// out). This serves as a "catch all" parser.
///
/// If these more specialized parsers error out, then this parser will be called again to
/// parse the remainder; this time the input will start with the special character; and in
/// this edge case it will take the input until the first new line; or until the end of
/// the input.
///
/// More info: <https://github.com/dimfeld/export-logseq-notes/blob/40f4d78546bec269ad25d99e779f58de64f4a505/src/parse_string.rs#L132>
/// See: [specialized_parser_delim_matchers::take_starts_with_delim_no_new_line()].
/// This is a special set of chars called `set_1`.
///
/// This is used to check if the input starts with any of these special characters, which
/// must have at least 2 occurrences for it to be parsed by the specialized parsers. If
/// only 1 occurrence is found, then this parser's `Edge case -> Special case` will take
/// care of it by splitting the input, and returning the first part as plain text, and the
/// remainder as the input to be parsed by the specialized parsers.
/// This is a special set of chars called `set_2`.
///
/// This is used to detect the `Edge case -> Normal case` where the input starts with any
/// of these special characters, and the input is taken until the first new line, and
/// return as plain text. Unless both of the following are true:
/// 1. input is in [get_sp_char_set_1()] and,
/// 2. count is 1.
/// This is a special set of chars called `set_3`.
///
/// This is used to detect the `Normal case` where the input does not start with any of
/// the special characters in [get_sp_char_set_2()]. The input is taken until the first
/// special character, and split there. This returns the chunk until the first special
/// character as [crate::MdLineFragment::Plain], and the remainder of the input gets a
/// chance to be parsed by the specialized parsers.