This repository has been archived by the owner on Oct 1, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathspec.txt
3740 lines (2571 loc) · 110 KB
/
spec.txt
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
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
# CMSM
> 🪦 **Archived**: this document is not maintained.
> This document was made jointly with `micromark`,
> which was later also turned into `markdown-rs`.
> At present,
> I don’t have the bandwidth to maintain 2 reference parsers
> *and* a spec.
***
> Common markup state machine.
Together, the parsing rules described below define what is referred to as a
Common Markup parser.
> This document is currently in progress.
> It is developed jointly with a reference parser:
> [`micromark`](https://github.com/micromark/micromark).
> Contributions are welcome.
>
> Some parts that are still in progress:
>
> * Adapters
> * Define the regular constructs
> * Adapter for rich text to check whether emphasis, strong, resource, or
> reference sequences make up syntax or text
> * Tokenizing the input stream in reverse (GFM allows `asd@asd.com`, so it
> seems we need to somehow allow to match the `@` and parse backwards)
> * Add an appendix of extensions
## Table of contents
## Background
The common markup parser parses a markup language that is commonly known as
*Markdown*.
The first definition of this format gave several examples of how it worked,
showing input Markdown and output HTML, and came with a reference implementation
(known as Markdown.pl).
When new implementations followed, they mostly followed the first definition,
but deviated from the first implementation, thus making the format a family of
formats.
Some years later, an attempt was made to standardize the differences between
implementations, by specifying how several edge cases should be handled, through
more input and output examples.
This attempt is known as CommonMark, and many implementations now follow it.
This document defines a more formal format, based on CommonMark, by documenting
how to parse it, instead of documenting input and output examples.
This format is:
* **strict**, as it defines a state machine, which leaves significantly less
room for interpretation
* **agnostic** of HTML, as it does not show examples of output, which lets
the format be used in new ways
* **streaming**, because coupling with HTML is what requires a whole stream to
be buffered as references can resolve to later definitions
* **complete**, as it defines different types of tokens and how they are
grouped, which allows the format to be represented as a concrete syntax tree
* **extensible**, because the format is often used in combination with new
and custom constructs
The origin story of Markdown is similar to that of HTML, which at a time was
also a family of formats.
Through incredible efforts of the WHATWG, a Living Standard was created on how
to parse the format, by defining a state machine.
## Overview
The common markup parser receives input, typically coming over the network or
from the local file system.
This input is represented as characters in the input stream.
Depending on a character, certain effects occur, such as that a new token is
created, one state is switched to another, or something is labelled.
Each line is made up of tokens, such as whitespace, markers, sequences, and
content, and labels, that are both enqueued.
At a certain point, it is known what to do with the queue, whether to discard it
or to use it, in which case it is adapted.
The parser parses in three stages: flow, content, and text, respectively coming
with their own state machines ([flow state machine][], [content state machine][],
[text state machine][]), and their own adapters.
## Infra
> *This section defines the fundamental concepts upon which this document is
> built.*
A variable is declared in the shared state with `let`, cleared with `unset`, or
changed with `set`, `increment`, `decrement`, `append` or `prepend`.
## Characters
A character is a Unicode code point and is represented as a four to six digit
hexadecimal number, prefixed with `U+` (**\[UNICODE]**).
### Character groups
An [ASCII digit](#) is a character in the inclusive range c:0 to c:9.
An [ASCII upper hex digit](#) a character in the inclusive range c:A to c:F.
An [ASCII lower hex digit](#) a character in the inclusive range c:a to c:f.
An [ASCII hex digit](#) is an [ASCII digit][], [ASCII upper hex digit][], or an
[ASCII lower hex digit][]
An [ASCII upper alpha](#) is a character in the inclusive range c:A to c:Z.
An [ASCII lower alpha](#) is a character in the inclusive range c:a to c:z.
An [ASCII alpha](#) is an [ASCII upper alpha][] or [ASCII lower alpha][].
An [ASCII alphanumeric](#) is an [ASCII digit][] or [ASCII alpha][].
An [ASCII punctuation](#) is a character in the inclusive ranges c:! to c:/, c::
to c:@, c:[ to c:`, or c:{ to c:~.
An [ASCII control](#) is a character in the inclusive range c:NUL to c:US, or
c:DEL.
A [Unicode whitespace](#) is a character in the Unicode `Zs` (Separator, Space)
category, or c:HT, c:LF, c:FF, or c:CR (**\[UNICODE]**).
A [Unicode punctuation](#) is a character in the Unicode `Pc` (Punctuation,
Connector), `Pd` (Punctuation, Dash), `Pe` (Punctuation, Close), `Pf`
(Punctuation, Final quote), `Pi` (Punctuation, Initial quote), `Po`
(Punctuation, Other), or `Ps` (Punctuation, Open) categories, or an [ASCII
punctuation][] (**\[UNICODE]**).
An [atext](#) is an [ASCII alphanumeric][], or a character in the inclusive
ranges c:# to c:', c:*, c:+, c:-, c:/, c:=, c:?, c:^ to c:`, or c:{ to c:~
(**\[RFC5322]**).
To [ASCII-lowercase](#) a character, is to increase it by `0x20`, if it an
[ASCII upper alpha][].
To [digitize](#) a character, is to decrease it by `0x30`, `0x37`, or `0x57`,
if it is an [ASCII digit][], [ASCII upper hex digit][], or
[ASCII lower hex digit][], respectively.
### Conceptual characters
A [c:VS](#) character is a conceptual character representing an expanded column
size of a c:HT.
An [c:EOL](#) character is a conceptual character representing a break between
two lines.
An [c:EOF](#) character is a conceptual character representing the end of the
input.
c:VS, c:EOL, and c:EOF are not real characters, but rather represent a character
increase the size of a character, a break between characters, or the lack of any
further characters.
### Tabs
Tabs (c:HT) are typically not expanded into spaces, but do behave as if they
were replaced by spaces with a tab stop of 4 characters.
These character increments are represented by [c:VS] characters.
For the following markup (where `␉` represent a tab):
```markdown
>␉␉a
```
We have the characters: c:>, c:HT, c:VS, c:VS, c:HT, c:VS, c:VS, c:VS, and c:a.
When transforming to an output format, tab characters that are not part of
syntax should be present in the output format.
When the tab itself (and zero or more c:VS characters) are part of syntax, but
some c:VS characters are not, the remaining c:VS characters should be considered
a prefix of the content.
## Input stream
The [input stream](#) consists of the characters pushed into it.
The [input character](#) is the first character in the [input stream][] that has
not yet been consumed.
Initially, the input character is the first character in the input.
When the last character in a line is consumed, the input character is an
[c:EOL][].
Finally, when all character are consumed, the input character is an [c:EOF][].
Any occurrences of c:HT in the [input stream][] is represented by that
character and 0-3 [c:VS][] characters.
### Preprocessing the input stream
The [input stream][] consists of the characters pushed into it as the input is
decoded.
The input, when decoded, is preprocessed and pushed into the input stream as
described in the following algorithm:
* Let `tabSize` be `4`
* Let `line` be `1`
* Let `column` be `1`
* Let `offset` be `0`
* *Check*:
If `offset` is equal to the length of the document, push an c:EOF into the
[input stream][] representing the lack of any further characters, and return
Otherwise, if the current character is:
* ↪ **c:NUL**
Increment `offset` by `1`, increment `column` by `1`, push a c:� into
the [input stream][], and go to the step labelled *check*
* ↪ **c:HT**
Set `count` to the result of calculating `(tabSize - 1) - (column %
tabSize)`.
Increment `offset` by `1`, increment `column` by `1`, and push the
character into the [input stream][].
Perform the following steps `count` times: increment `column` by `1` and
push a c:VS into the [input stream][] representing the size increase.
Finally, go to the step labelled *check*
* ↪ **c:LF**
Increment `offset` by `1`, increment `line` by `1`, and set `column` to
`1`, push an c:EOL into the [input stream][] representing the character,
and go to the step labelled *check*
* ↪ **c:CR**
Increment `offset` by `1`, increment `line` by `1`, set `column` to `1`,
and go to the step labelled *carriage return check*
* ↪ **Anything else**
Increment `offset` by `1`, increment `column` by `1`, push the character
into the [input stream][], and go to the step labelled *check*
* *Carriage return check*: if the current character is:
* ↪ **c:LF**
Increment `offset` by `1` and push an c:EOL into the [input stream][]
representing the previous and current characters
* ↪ **Anything else**
Push an c:EOL into the [input stream][] representing the previous
character and perform the step labelled *check* on the current character
## Parsing
The states of state machines have certain effects, such as that they create
items in the [queue][] (tokens and labels).
The queue is used by tree adapters, in case a valid construct is found.
After using the queue, or when in a bogus construct is found, the queue is
discarded.
The [shared space][] is accessed and mutated by both the tree adapter and the
states of the state machine.
[Construct][]s are registered by hooking a case (one or more characters or
character groups) into certain states.
Upon registration, they define the states used to parse a construct, and the
adapter used to handle the construct.
### Tokenization
Implementations must act as if they use several state machines to tokenize
common markup.
The [flow state machine][] is used to tokenize the line constructs that make up
the structure of the document.
The [content state machine][] is used to tokenize the inline constructs part of
content blocks.
The [text state machine][] is used to tokenize the inline constructs part of
rich or plain text.
Most states [consume][] the [input character][], and either remain in the state
to consume the next character, [reconsume][] the input character in a different
state, or [switch][] to a different state to consume the next character.
States [enqueue][] tokens and labels.
### State
The [shared space](#) is a map of key/value pairs.
The [queue](#) is a list of tokens and labels that are enqueued.
The [current token](#) is the last token in the [queue][].
### Constructs
Markup is parsed per [construct](#).
Some constructs are considered regular (those from CommonMark, such as ATX
headings) and other constructs are extensions (such as YAML frontmatter or MDX).
> ❗️ Define constructs.
### Effects
#### Switch
To [switch](#) to a state is to wait for the next character in the given state.
#### Consume
To [consume](#) the [input character][] affects the [current token][].
Due to the nature of the state machine, it is not possible to consume if there
is no current token.
#### Reconsume
To [reconsume](#) is to [switch][] to the given state, and [consume][] the
[input character][] there.
#### Enqueue
To [enqueue](#) a label is to mark a point between two tokens with a semantic
name, at which point there is no [current token][].
To enqueue a token is to add a new token of the given type to the [queue][],
making it the new [current token][].
#### Ensure
To ensure a token is to enqueue that token if the [current token][] is not of
the given type, and otherwise do nothing.
## Flow state machine
The [flow state machine](#) is used to tokenize the line constructs that make up
the structure of the document (such as headings or thematic breaks) and must
start in the s:flow-prefix-start.
### Flow prefix start state
* ↪ **[c:VS][]**\
↪ **c:HT**\
↪ **c:SP**
Ensure a t:whitespace and consume
* ↪ **Anything else**
Reconsume in the s:flow-start
### Flow start state
> **Hookable**, there are no regular hooks
* ↪ **Anything else**
Reconsume in the s:flow-initial
### Flow prefix initial state
* ↪ **[c:VS][]**\
↪ **c:HT**\
↪ **c:SP**
Ensure a t:whitespace and consume
* ↪ **Anything else**
Reconsume in the s:flow-initial
### Flow initial state
> ❗️ Todo: Indented code v.s. content
> **Hookable**, the regular hooks are:
>
> * [x] **[c:EOL][]**: s:blank-line
> * [x] **c:#**: s:atx-heading-start
> * [x] **c:***: s:thematic-break-asterisk-start
> * [ ] **c:***: <!-- s:list-item-asterisk-start -->
> * [ ] **c:+**: <!-- s:list-item-plus-start -->
> * [x] **c:-**: s:setext-heading-underline-dash-start
> * [x] **c:-**: s:thematic-break-dash-start
> * [ ] **c:-**: <!-- s:list-item-dash-start -->
> * [x] **c:<**: s:flow-html-start
> * [x] **c:=**: s:setext-heading-underline-equals-to-start
> * [ ] **c:>**: <!-- s:blockquote-start -->
> * [x] **c:_**: s:thematic-break-underscore-start
> * [x] **c:`**: s:fenced-code-grave-accent-start
> * [x] **c:~**: s:fenced-code-tilde-start
> * [ ] **[ASCII digit][]**: <!-- s:list-item-digit-start -->
> ❗️ Todo, continuation:
> * [x] s:flow-html-continuation
> * [x] s:fenced-code-grave-accent-continuation
> * [x] s:fenced-code-tilde-continuation
* ↪ **[c:EOF][]**
Enqueue an t:end-of-file
* ↪ **Anything else**
Reconsume in the s:flow-content
### Blank line state
* ↪ **[c:EOL][]**
Enqueue a l:blank-line-end, enqueue an t:end-of-line, and consume
* ↪ **Anything else**
Enqueue a l:nok
### ATX heading start state
* ↪ **c:#**
Let `sizeFence` be `1`, enqueue an l:atx-heading-start, enqueue an
l:atx-heading-fence-start, enqueue a t:sequence, consume, and switch to the
s:atx-heading-fence-open-inside
* ↪ **Anything else**
Enqueue a l:nok
### ATX heading fence open inside state
* ↪ **[c:EOF][]**\
↪ **[c:EOL][]**\
↪ **[c:VS][]**\
↪ **c:HT**\
↪ **c:SP**
Unset `sizeFence`, enqueue an l:atx-heading-fence-end and reconsume in the
s:atx-heading-inside
* ↪ **c:#**
If `sizeFence` is not `6`, increment `sizeScheme` by `1` and consume
Otherwise, treat it as per the “anything else” entry below
* ↪ **Anything else**
Unset `sizeFence` and enqueue a l:nok
### ATX heading inside state
* ↪ **[c:EOF][]**
Enqueue an l:atx-heading-end and enqueue an t:end-of-file
* ↪ **[c:EOL][]**
Enqueue an l:atx-heading-end, enqueue an t:end-of-line, consume, and switch
to the s:flow-prefix-initial
* ↪ **[c:VS][]**\
↪ **c:HT**\
↪ **c:SP**
Ensure a t:whitespace and consume
* ↪ **c:#**
Ensure a t:sequence and consume
* ↪ **Anything else**
Ensure a t:content and consume
### Thematic break asterisk start state
* ↪ **c:***
Let `sizeTotalSequence` be `1`, enqueue a l:thematic-break-start, enqueue a
t:sequence, consume, and switch to the s:thematic-break-asterisk-inside
* ↪ **Anything else**
Enqueue a l:nok
### Thematic break asterisk inside state
* ↪ **[c:EOF][]**
If `sizeTotalSequence` is greater than or equal to `3`, unset
`sizeTotalSequence`, enqueue a l:thematic-break-end, and enqueue an
t:end-of-file
Otherwise, treat it as per the “anything else” entry below
* ↪ **[c:EOL][]**
If `sizeTotalSequence` is greater than or equal to `3`, unset
`sizeTotalSequence`, enqueue a l:thematic-break-end, enqueue an
t:end-of-line, consume, and switch to the s:flow-prefix-initial
Otherwise, treat it as per the “anything else” entry below
* ↪ **[c:VS][]**\
↪ **c:HT**\
↪ **c:SP**
Ensure a t:whitespace and consume
* ↪ **c:***
Increment `sizeTotalSequence` by `1`, ensure a t:sequence, and consume
* ↪ **Anything else**
Unset `sizeTotalSequence` and enqueue a l:nok
### Setext heading underline dash start state
> ❗️ Todo: exit if not preceded by content
* ↪ **c:-**
Enqueue a l:setext-heading-underline-start, enqueue a t:sequence, consume,
and switch to the s:setext-heading-underline-dash-inside
* ↪ **Anything else**
Enqueue a l:nok
### Setext heading underline dash inside state
* ↪ **[c:EOF][]**\
↪ **[c:EOL][]**\
↪ **[c:VS][]**\
↪ **c:HT**\
↪ **c:SP**
Reconsume in the s:setext-heading-underline-dash-after
* ↪ **c:-**
Consume
* ↪ **Anything else**
Enqueue a l:nok
### Setext heading underline dash after state
> ❗️ Todo: Close content if ok, create a new content if nok
* ↪ **[c:EOF][]**
Enqueue a l:setext-heading-underline-end and enqueue an t:end-of-file
* ↪ **[c:EOL][]**
Enqueue a l:setext-heading-underline-end, enqueue an t:end-of-line, consume,
and switch to the s:flow-prefix-initial
* ↪ **[c:VS][]**\
↪ **c:HT**\
↪ **c:SP**
Ensure a t:whitespace and consume
* ↪ **Anything else**
Enqueue a l:nok
### Thematic break dash start state
* ↪ **c:-**
Let `sizeTotalSequence` be `1`, enqueue a l:thematic-break-start, enqueue a
t:sequence, consume, and switch to the s:thematic-break-dash-inside
* ↪ **Anything else**
Enqueue a l:nok
### Thematic break dash inside state
* ↪ **[c:EOF][]**
If `sizeTotalSequence` is greater than or equal to `3`, unset
`sizeTotalSequence`, enqueue a l:thematic-break-end, and enqueue an
t:end-of-file
Otherwise, treat it as per the “anything else” entry below
* ↪ **[c:EOL][]**
If `sizeTotalSequence` is greater than or equal to `3`, unset
`sizeTotalSequence`, enqueue a l:thematic-break-end, enqueue an
t:end-of-line, consume, and switch to the s:flow-prefix-initial
Otherwise, treat it as per the “anything else” entry below
* ↪ **[c:VS][]**\
↪ **c:HT**\
↪ **c:SP**
Ensure a t:whitespace and consume
* ↪ **c:-**
Increment `sizeTotalSequence` by `1`, ensure a t:sequence, and consume
* ↪ **Anything else**
Unset `sizeTotalSequence` and enqueue a l:nok
### Flow HTML start state
* ↪ **c:<**
Let `kind` be `0`, let `endTag` be `null`, let `tagName` be the empty
string, enqueue a t:content, consume, and switch to the s:flow-html-tag-open
* ↪ **Anything else**
Enqueue a l:nok
### Flow HTML tag open state
* ↪ **c:!**
Consume and switch to the s:flow-html-markup-declaration-open
* ↪ **c:/**
Set `endTag` to `true`, consume, and switch to the s:flow-html-end-tag-open
* ↪ **c:?**
Set `kind` to `3`, unset `endTag`, consume, and switch to the
s:flow-html-continuation-declaration-before
* ↪ **[ASCII alpha][]**
Append the [ASCII-lowercase][]d character to `tagName`, consume, and switch
to the s:flow-html-tag-name
* ↪ **Anything else**
Unset `kind`, `endTag`, and `tagName`, and enqueue a l:nok
### Flow HTML markup declaration open state
* ↪ **`--` (two c:- characters)**
Set `kind` to `2`, unset `endTag`, consume, and switch to the
s:flow-html-continuation-declaration-before
* ↪ **`[CDATA[` (the five upper letters “CDATA” with a c:[ before and
after)**
Set `kind` to `5`, unset `endTag`, consume, and switch to the
s:flow-html-continuation
* ↪ **[ASCII alpha][]**
Set `kind` to `4`, unset `endTag`, consume, and switch to the
s:flow-html-continuation
* ↪ **Anything else**
Unset `kind`, `endTag`, and `tagName`, and enqueue a l:nok
### Flow HTML end tag open state
* ↪ **[ASCII alpha][]**
Append the [ASCII-lowercase][]d character to `tagName`, consume, and switch
to the s:flow-html-tag-name
* ↪ **Anything else**
Unset `kind`, `endTag`, and `tagName`, and enqueue a l:nok
### Flow HTML tag name state
* ↪ **[c:EOF][]**\
↪ **[c:EOL][]**
If `tagName` is a [raw tag][] and `endTag` is not `true`, set `kind` to `1`,
unset `tagName`, unset `endTag`, and reconsume in the
s:flow-html-continuation
Otherwise, if `tagName` is a [basic tag][], set `kind` to `6`, unset
`tagName`, unset `endTag`, and reconsume in the s:flow-html-continuation
Otherwise, treat it as per the “anything else” entry below
* ↪ **[c:VS][]**\
↪ **c:HT**\
↪ **c:SP**
If `tagName` is a [raw tag][] and `endTag` is not `true`, set `kind` to `1`,
unset `tagName`, unset `endTag`, and switch to the s:flow-html-continuation
> ❗️ Todo: ignore this check if interrupting content.
Otherwise, if `tagName` is not a [raw tag][], unset `tagName`, consume, and
switch to the s:flow-html-complete-attribute-name-before
Otherwise, treat it as per the “anything else” entry below
* ↪ **c:-**
Append the character to `tagName` and consume
* ↪ **c:/**
If `tagName` is a [basic tag][], unset `tagName`, consume, and switch to the
s:flow-html-basic-self-closing
> ❗️ Todo: ignore this check if interrupting content.
Otherwise, if `tagName` is not a [raw tag][] and `endTag` is not `true`,
unset `tagName`, consume, and switch to the
s:flow-html-complete-self-closing
Otherwise, treat it as per the “anything else” entry below
* ↪ **c:>**
If `tagName` is a [raw tag][] and `endTag` is not `true`, set `kind` to `1`,
unset `tagName`, unset `endTag`, consume, and switch to the
s:flow-html-continuation
Otherwise, if `tagName` is a [basic tag][], set `kind` to `6`, unset
`tagName`, unset `endTag`, and reconsume in the s:flow-html-continuation
> ❗️ Todo: ignore this check if interrupting content.
Otherwise, if `tagName` is not a [raw tag][], unset `tagName`, consume, and
switch to the s:flow-html-complete-tag-after
Otherwise, treat it as per the “anything else” entry below
* ↪ **[ASCII alphanumeric][]**
Append the [ASCII-lowercase][]d character to `tagName` and consume
* ↪ **Anything else**
Unset `kind`, `endTag`, and `tagName`, and enqueue a l:nok
### Flow HTML basic self closing state
* ↪ **c:>**
Set `kind` to `6`, unset `endTag`, consume, and switch to the
s:flow-html-continuation
* ↪ **Anything else**
Unset `kind` and `endTag` and enqueue a l:nok
### Flow HTML complete attribute name before state
* ↪ **[c:VS][]**\
↪ **c:HT**\
↪ **c:SP**
Consume
* ↪ **c:/**
If `endTag` is not `true`, consume and switch to the
s:flow-html-complete-self-closing
Otherwise, treat it as per the “anything else” entry below
* ↪ **c::**\
↪ **c:_**\
↪ **[ASCII alpha][]**
If `endTag` is not `true`, consume and switch to the
s:flow-html-complete-attribute-name
Otherwise, treat it as per the “anything else” entry below
* ↪ **c:>**
Consume and switch to the s:flow-html-complete-tag-after
* ↪ **Anything else**
Unset `kind` and `endTag` and enqueue a l:nok
### Flow HTML complete attribute name state
* ↪ **c:-**\
↪ **c:.**\
↪ **c::**\
↪ **c:_**\
↪ **[ASCII alphanumeric][]**
Consume
* ↪ **Anything else**
Reconsume in the s:flow-html-complete-attribute-name-after
### Flow HTML complete attribute name after state
* ↪ **[c:VS][]**\
↪ **c:HT**\
↪ **c:SP**
Consume
* ↪ **c:/**
If `endTag` is not `true`, consume and switch to the
s:flow-html-complete-self-closing
Otherwise, treat it as per the “anything else” entry below
* ↪ **c:=**
Consume and switch to the s:flow-html-complete-attribute-value-before
* ↪ **c:>**
Consume and switch to the s:flow-html-complete-tag-after
* ↪ **Anything else**
Unset `kind` and `endTag` and enqueue a l:nok
### Flow HTML complete attribute value before state
* ↪ **[c:EOF][]**\
↪ **[c:EOL][]**\
↪ **c:<**\
↪ **c:=**\
↪ **c:>**\
↪ **c:`**
Unset `kind` and `endTag` and enqueue a l:nok
* ↪ **[c:VS][]**\
↪ **c:HT**\
↪ **c:SP**
Consume
* ↪ **c:"**
Consume and switch to the s:flow-html-complete-attribute-value-double-quoted
* ↪ **c:'**
Consume and switch to the s:flow-html-complete-attribute-value-single-quoted
* ↪ **Anything else**
Consume and switch to the s:flow-html-complete-attribute-value-unquoted
### Flow HTML complete attribute value double quoted state
* ↪ **[c:EOF][]**\
↪ **[c:EOL][]**
Unset `kind` and `endTag` and enqueue a l:nok
* ↪ **c:"**
Consume and switch to the s:flow-html-complete-attribute-name-before
* ↪ **Anything else**
Consume
### Flow HTML complete attribute value single quoted state
* ↪ **[c:EOF][]**\
↪ **[c:EOL][]**
Unset `kind` and `endTag` and enqueue a l:nok
* ↪ **c:'**
Consume and switch to the s:flow-html-complete-attribute-name-before
* ↪ **Anything else**
Consume
### Flow HTML complete attribute value unquoted state
* ↪ **[c:EOF][]**\
↪ **[c:EOL][]**\
↪ **[c:VS][]**\
↪ **c:HT**\
↪ **c:SP**\
↪ **c:"**\
↪ **c:'**\
↪ **c:<**\
↪ **c:=**\
↪ **c:>**\
↪ **c:`**
Reconsume in the s:flow-html-complete-attribute-name-after
* ↪ **Anything else**
Consume
### Flow HTML complete self closing state
* ↪ **c:>**
Consume and switch to the s:flow-html-complete-tag-after
* ↪ **Anything else**
Unset `kind` and `endTag` and enqueue a l:nok
### Flow HTML complete tag after state
* ↪ **[c:EOF][]**\
↪ **[c:EOL][]**\
↪ **[c:VS][]**\
↪ **c:HT**\
↪ **c:SP**
Set `kind` to `7`, unset `endTag`, and reconsume in the
s:flow-html-continuation
* ↪ **Anything else**
Unset `kind` and `endTag` and enqueue a l:nok
### Flow HTML continuation state
* ↪ **[c:EOF][]**
Unset `kind`, enqueue an l:html-end, and enqueue an t:end-of-file
* ↪ **[c:EOL][]**
Enqueue an t:end-of-line, consume, and switch to the s:flow-prefix-initial
* ↪ **c:-**
If `kind` is `7`, consume and switch to the
s:flow-html-continuation-comment-inside
Otherwise, treat it as per the “anything else” entry below
* ↪ **c:<**
If `kind` is `1`, consume and switch to the
s:flow-html-continuation-raw-tag-open
Otherwise, treat it as per the “anything else” entry below
* ↪ **c:>**
If `kind` is `4`, consume and switch to the s:flow-html-continuation-close
Otherwise, treat it as per the “anything else” entry below
* ↪ **c:?**
If `kind` is `3`, consume and switch to the
s:flow-html-continuation-declaration-before
Otherwise, treat it as per the “anything else” entry below
* ↪ **c:]**
If `kind` is `5`, consume and switch to the
s:flow-html-continuation-character-data-inside.
Otherwise, treat it as per the “anything else” entry below
* ↪ **Anything else**
Consume
### Flow HTML continuation comment inside state
* ↪ **c:-**
Consume and switch to the s:flow-html-continuation-declaration-before
* ↪ **Anything else**
Reconsume in the s:flow-html-continuation
### Flow HTML continuation raw tag open state
* ↪ **c:/**
Let `tagName` be the empty string, consume, and switch to the
s:flow-html-continuation-raw-end-tag
* ↪ **Anything else**
Reconsume in the s:flow-html-continuation
### Flow HTML continuation raw end tag state
> **Note**: This state can be optimized by either imposing a maximum size (the
> size of the longest possible raw tag name) or by using a trie of the possible
> raw tag names.
* ↪ **[ASCII alphanumeric][]**
Append the [ASCII-lowercase][]d character to `tagName` and consume
* ↪ **c:>**
If `tagName` is a [raw tag][], unset `tagName, consume, and switch to the
s:flow-html-continuation-close
Otherwise, treat it as per the “anything else” entry below
* ↪ **Anything else**
Unset `tagName and reconsume in the s:flow-html-continuation
### Flow HTML continuation character data inside state
* ↪ **c:]**
Consume and switch to the s:flow-html-continuation-declaration-before
* ↪ **Anything else**
Reconsume in the s:flow-html-continuation
### Flow HTML continuation declaration before state
* ↪ **c:>**
Consume and switch to the s:flow-html-continuation-close
* ↪ **Anything else**
Reconsume in the s:flow-html-continuation
### Flow HTML continuation close state
* ↪ **[c:EOF][]**
Unset `kind`, enqueue an l:html-end, and enqueue an t:end-of-file
* ↪ **[c:EOL][]**
Unset `kind`, enqueue an l:html-end, and enqueue an t:end-of-line, consume,
and switch to the s:flow-prefix-initial
* ↪ **Anything else**
Consume
### Setext heading underline equals to start state
> ❗️ Todo: exit if not preceded by content
* ↪ **c:=**
Enqueue a l:setext-heading-underline-start, enqueue a t:sequence, consume,
and switch to the s:setext-heading-underline-equals-to-inside
* ↪ **Anything else**
Enqueue a l:nok
### Setext heading underline equals to inside state
* ↪ **[c:EOF][]**\
↪ **[c:EOL][]**\
↪ **[c:VS][]**\
↪ **c:HT**\
↪ **c:SP**