Support syntactically directly nested list, enum, and term list (#5728)

Co-authored-by: Laurenz <laurmaedje@gmail.com>
This commit is contained in:
wznmickey 2025-01-23 07:52:20 -05:00 committed by GitHub
parent 58dbbd48fe
commit ce299d5832
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
9 changed files with 31 additions and 3 deletions

View File

@ -160,7 +160,7 @@ fn list_item(p: &mut Parser) {
p.with_nl_mode(AtNewline::RequireColumn(p.current_column()), |p| { p.with_nl_mode(AtNewline::RequireColumn(p.current_column()), |p| {
let m = p.marker(); let m = p.marker();
p.assert(SyntaxKind::ListMarker); p.assert(SyntaxKind::ListMarker);
markup(p, false, false, syntax_set!(RightBracket, End)); markup(p, true, false, syntax_set!(RightBracket, End));
p.wrap(m, SyntaxKind::ListItem); p.wrap(m, SyntaxKind::ListItem);
}); });
} }
@ -170,7 +170,7 @@ fn enum_item(p: &mut Parser) {
p.with_nl_mode(AtNewline::RequireColumn(p.current_column()), |p| { p.with_nl_mode(AtNewline::RequireColumn(p.current_column()), |p| {
let m = p.marker(); let m = p.marker();
p.assert(SyntaxKind::EnumMarker); p.assert(SyntaxKind::EnumMarker);
markup(p, false, false, syntax_set!(RightBracket, End)); markup(p, true, false, syntax_set!(RightBracket, End));
p.wrap(m, SyntaxKind::EnumItem); p.wrap(m, SyntaxKind::EnumItem);
}); });
} }
@ -184,7 +184,7 @@ fn term_item(p: &mut Parser) {
markup(p, false, false, syntax_set!(Colon, RightBracket, End)); markup(p, false, false, syntax_set!(Colon, RightBracket, End));
}); });
p.expect(SyntaxKind::Colon); p.expect(SyntaxKind::Colon);
markup(p, false, false, syntax_set!(RightBracket, End)); markup(p, true, false, syntax_set!(RightBracket, End));
p.wrap(m, SyntaxKind::TermItem); p.wrap(m, SyntaxKind::TermItem);
}); });
} }

Binary file not shown.

After

Width:  |  Height:  |  Size: 800 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 217 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 506 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 921 B

View File

@ -199,3 +199,13 @@ a + 0.
+ f + f
#align(right)[+ align] #align(right)[+ align]
+ h + h
--- issue-5719-enum-nested ---
// Enums can be immediately nested.
1. A
2. 1. B
2. C
+ + D
+ E
+ = F
G

View File

@ -148,3 +148,7 @@ Cannot be used as @intro
// Hint: 1-16 HTML only supports <h1> to <h6>, not <h8> // Hint: 1-16 HTML only supports <h1> to <h6>, not <h8>
// Hint: 1-16 you may want to restructure your document so that it doesn't contain deep headings // Hint: 1-16 you may want to restructure your document so that it doesn't contain deep headings
======= Level 7 ======= Level 7
--- issue-5719-heading-nested ---
// Headings may not be nested like this.
= = A

View File

@ -276,3 +276,11 @@ World
- h - h
#align(right)[- i] #align(right)[- i]
- j - j
--- issue-5719-list-nested ---
// Lists can be immediately nested.
- A
- - B
- C
- = D
E

View File

@ -90,3 +90,9 @@ Not in list
/ h: h / h: h
#align(right)[/ i: i] #align(right)[/ i: i]
/ j: j / j: j
--- issue-5719-terms-nested ---
// Term lists can be immediately nested.
/ Term A: 1
/ Term B: / Term C: 2
/ Term D: 3