@@ -162,11 +162,6 @@ type token_that_always_begins_an_inline_element =
162
162
let _check_subset : token_that_always_begins_an_inline_element -> Token.t =
163
163
fun t -> (t :> Token.t )
164
164
165
- (* The different contexts in which the inline parser [inline_element] and
166
- [delimited_inline_parser] can be called. The inline parser's behavior depends
167
- somewhat on the context: new lines are forbidden in light tables. *)
168
- type inline_context = In_light_table | Outside_light_table
169
-
170
165
(* Consumes tokens that make up a single non-link inline element:
171
166
172
167
- a horizontal space ([`Space], significant in inline elements),
@@ -188,12 +183,8 @@ type inline_context = In_light_table | Outside_light_table
188
183
189
184
This function consumes exactly the tokens that make up the element. *)
190
185
let rec inline_element :
191
- input ->
192
- Loc. span ->
193
- context :inline_context ->
194
- _ ->
195
- Ast. inline_element with_location =
196
- fun input location ~context next_token ->
186
+ input -> Loc. span -> _ -> Ast. inline_element with_location =
187
+ fun input location next_token ->
197
188
match next_token with
198
189
| `Space _ as token ->
199
190
junk input;
@@ -226,8 +217,7 @@ let rec inline_element :
226
217
in
227
218
let content, brace_location =
228
219
delimited_inline_element_list ~parent_markup
229
- ~parent_markup_location: location ~requires_leading_whitespace ~context
230
- input
220
+ ~parent_markup_location: location ~requires_leading_whitespace input
231
221
in
232
222
233
223
let location = Loc. span [ location; brace_location ] in
@@ -255,7 +245,7 @@ let rec inline_element :
255
245
let content, brace_location =
256
246
delimited_inline_element_list ~parent_markup
257
247
~parent_markup_location: location ~requires_leading_whitespace: false
258
- ~context input
248
+ input
259
249
in
260
250
261
251
let location = Loc. span [ location; brace_location ] in
@@ -293,7 +283,7 @@ let rec inline_element :
293
283
let content, brace_location =
294
284
delimited_inline_element_list ~parent_markup
295
285
~parent_markup_location: location ~requires_leading_whitespace: false
296
- ~context input
286
+ input
297
287
in
298
288
299
289
`Link (u, content) |> Loc. at (Loc. span [ location; brace_location ])
@@ -324,11 +314,9 @@ and delimited_inline_element_list :
324
314
parent_markup :[< Token. t ] ->
325
315
parent_markup_location :Loc. span ->
326
316
requires_leading_whitespace :bool ->
327
- context :inline_context ->
328
317
input ->
329
318
Ast. inline_element with_location list * Loc. span =
330
- fun ~parent_markup ~parent_markup_location ~requires_leading_whitespace
331
- ~context input ->
319
+ fun ~parent_markup ~parent_markup_location ~requires_leading_whitespace input ->
332
320
(* [~at_start_of_line] is used to interpret [`Minus] and [`Plus]. These are
333
321
word tokens if not the first non-whitespace tokens on their line. Then,
334
322
they are allowed in a non-link element list. *)
@@ -351,17 +339,10 @@ and delimited_inline_element_list :
351
339
it is an internal space, and we want to add it to the non-link inline
352
340
element list. *)
353
341
| (`Space _ | #token_that_always_begins_an_inline_element ) as token ->
354
- let acc =
355
- inline_element input next_token.location ~context token :: acc
356
- in
342
+ let acc = inline_element input next_token.location token :: acc in
357
343
consume_elements ~at_start_of_line: false acc
358
- | `Single_newline ws as blank ->
344
+ | `Single_newline ws ->
359
345
junk input;
360
- if context = In_light_table then
361
- Parse_error. not_allowed ~what: (Token. describe blank)
362
- ~in_what: (Token. describe `Begin_table_light )
363
- next_token.location
364
- |> add_warning input;
365
346
let element = Loc. same next_token (`Space ws) in
366
347
consume_elements ~at_start_of_line: true (element :: acc)
367
348
| `Blank_line ws as blank ->
@@ -374,9 +355,7 @@ and delimited_inline_element_list :
374
355
let element = Loc. same next_token (`Space ws) in
375
356
consume_elements ~at_start_of_line: true (element :: acc)
376
357
| `Bar as token ->
377
- let acc =
378
- inline_element input next_token.location ~context token :: acc
379
- in
358
+ let acc = inline_element input next_token.location token :: acc in
380
359
consume_elements ~at_start_of_line: false acc
381
360
| (`Minus | `Plus ) as bullet ->
382
361
(if at_start_of_line then
@@ -389,9 +368,7 @@ and delimited_inline_element_list :
389
368
~suggestion next_token.location
390
369
|> add_warning input);
391
370
392
- let acc =
393
- inline_element input next_token.location ~context bullet :: acc
394
- in
371
+ let acc = inline_element input next_token.location bullet :: acc in
395
372
consume_elements ~at_start_of_line: false acc
396
373
| other_token ->
397
374
Parse_error. not_allowed
@@ -473,10 +450,7 @@ let paragraph : input -> Ast.nestable_block_element with_location =
473
450
match next_token.value with
474
451
| ( `Space _ | `Minus | `Plus | `Bar
475
452
| #token_that_always_begins_an_inline_element ) as token ->
476
- let element =
477
- inline_element input next_token.location ~context: Outside_light_table
478
- token
479
- in
453
+ let element = inline_element input next_token.location token in
480
454
paragraph_line (element :: acc)
481
455
| _ -> acc
482
456
in
@@ -1023,7 +997,7 @@ let rec block_element_list :
1023
997
let content, brace_location =
1024
998
delimited_inline_element_list ~parent_markup: token
1025
999
~parent_markup_location: location ~requires_leading_whitespace: true
1026
- ~context: Outside_light_table input
1000
+ input
1027
1001
in
1028
1002
let location = Loc. span [ location; brace_location ] in
1029
1003
let paragraph =
@@ -1063,8 +1037,7 @@ let rec block_element_list :
1063
1037
let content, brace_location =
1064
1038
delimited_inline_element_list ~parent_markup: token
1065
1039
~parent_markup_location: location
1066
- ~requires_leading_whitespace: true ~context: Outside_light_table
1067
- input
1040
+ ~requires_leading_whitespace: true input
1068
1041
in
1069
1042
if content = [] then
1070
1043
Parse_error. should_not_be_empty ~what: (Token. describe token)
@@ -1081,7 +1054,7 @@ let rec block_element_list :
1081
1054
let content, brace_location =
1082
1055
delimited_inline_element_list ~parent_markup: token
1083
1056
~parent_markup_location: location ~requires_leading_whitespace: true
1084
- ~context: Outside_light_table input
1057
+ input
1085
1058
in
1086
1059
let location = Loc. span [ location; brace_location ] in
1087
1060
@@ -1307,9 +1280,13 @@ and light_table_row ~parent_markup ~last_loc input =
1307
1280
let acc_row = if new_line then [] else List. rev acc_cell :: acc_row in
1308
1281
consume_row acc_row [] ~new_line: false ~last_loc
1309
1282
| #token_that_always_begins_an_inline_element as token ->
1310
- let i =
1311
- inline_element input next_token.location ~context: In_light_table token
1312
- in
1283
+ let i = inline_element input next_token.location token in
1284
+ if Loc. spans_multiple_lines i then
1285
+ Parse_error. not_allowed
1286
+ ~what: (Token. describe (`Single_newline " " ))
1287
+ ~in_what: (Token. describe `Begin_table_light )
1288
+ i.location
1289
+ |> add_warning input;
1313
1290
consume_row acc_row (i :: acc_cell) ~new_line: false
1314
1291
~last_loc: next_token.location
1315
1292
| other_token ->
0 commit comments