mirror of
https://github.com/typst/typst
synced 2025-05-14 04:56:26 +08:00
Support syntactically directly nested list, enum, and term list (#5728)
Co-authored-by: Laurenz <laurmaedje@gmail.com>
This commit is contained in:
parent
58dbbd48fe
commit
ce299d5832
@ -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);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
BIN
tests/ref/issue-5719-enum-nested.png
Normal file
BIN
tests/ref/issue-5719-enum-nested.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 800 B |
BIN
tests/ref/issue-5719-heading-nested.png
Normal file
BIN
tests/ref/issue-5719-heading-nested.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 217 B |
BIN
tests/ref/issue-5719-list-nested.png
Normal file
BIN
tests/ref/issue-5719-list-nested.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 506 B |
BIN
tests/ref/issue-5719-terms-nested.png
Normal file
BIN
tests/ref/issue-5719-terms-nested.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 921 B |
@ -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
|
||||||
|
@ -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
|
||||||
|
@ -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
|
||||||
|
@ -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
|
||||||
|
Loading…
x
Reference in New Issue
Block a user