mirror of
https://github.com/typst/typst
synced 2025-05-14 04:56:26 +08:00
Don't allow empty lists and enums
This commit is contained in:
parent
b865accae6
commit
b8233a9e01
@ -277,6 +277,7 @@ fn heading(p: &mut Parser, at_start: bool) {
|
|||||||
while p.eat_if(&NodeKind::Eq) {}
|
while p.eat_if(&NodeKind::Eq) {}
|
||||||
|
|
||||||
if at_start && p.peek().map_or(true, |kind| kind.is_space()) {
|
if at_start && p.peek().map_or(true, |kind| kind.is_space()) {
|
||||||
|
p.eat_while(|kind| kind.is_space());
|
||||||
markup_line(p);
|
markup_line(p);
|
||||||
marker.end(p, NodeKind::Heading);
|
marker.end(p, NodeKind::Heading);
|
||||||
} else {
|
} else {
|
||||||
@ -291,8 +292,8 @@ fn list_node(p: &mut Parser, at_start: bool) {
|
|||||||
let text: EcoString = p.peek_src().into();
|
let text: EcoString = p.peek_src().into();
|
||||||
p.eat_assert(&NodeKind::Minus);
|
p.eat_assert(&NodeKind::Minus);
|
||||||
|
|
||||||
if at_start && p.peek().map_or(true, |kind| kind.is_space()) {
|
let column = p.column(p.prev_end());
|
||||||
let column = p.column(p.prev_end());
|
if at_start && p.eat_if(&NodeKind::Space(0)) && !p.eof() {
|
||||||
markup_indented(p, column);
|
markup_indented(p, column);
|
||||||
marker.end(p, NodeKind::List);
|
marker.end(p, NodeKind::List);
|
||||||
} else {
|
} else {
|
||||||
@ -306,8 +307,8 @@ fn enum_node(p: &mut Parser, at_start: bool) {
|
|||||||
let text: EcoString = p.peek_src().into();
|
let text: EcoString = p.peek_src().into();
|
||||||
p.eat();
|
p.eat();
|
||||||
|
|
||||||
if at_start && p.peek().map_or(true, |kind| kind.is_space()) {
|
let column = p.column(p.prev_end());
|
||||||
let column = p.column(p.prev_end());
|
if at_start && p.eat_if(&NodeKind::Space(0)) && !p.eof() {
|
||||||
markup_indented(p, column);
|
markup_indented(p, column);
|
||||||
marker.end(p, NodeKind::Enum);
|
marker.end(p, NodeKind::Enum);
|
||||||
} else {
|
} else {
|
||||||
|
Binary file not shown.
Before Width: | Height: | Size: 26 KiB After Width: | Height: | Size: 25 KiB |
Binary file not shown.
Before Width: | Height: | Size: 21 KiB After Width: | Height: | Size: 22 KiB |
@ -46,6 +46,10 @@
|
|||||||
[Red], [Green], [Blue],
|
[Red], [Green], [Blue],
|
||||||
)
|
)
|
||||||
|
|
||||||
|
---
|
||||||
|
// Lone dot is not a list.
|
||||||
|
.
|
||||||
|
|
||||||
---
|
---
|
||||||
// Error: 18-20 invalid pattern
|
// Error: 18-20 invalid pattern
|
||||||
#set enum(label: "")
|
#set enum(label: "")
|
||||||
|
@ -49,3 +49,8 @@ paragraphs.
|
|||||||
// This doesn't work because of mixed tabs and spaces.
|
// This doesn't work because of mixed tabs and spaces.
|
||||||
- A with 2 spaces
|
- A with 2 spaces
|
||||||
- B with 2 tabs
|
- B with 2 tabs
|
||||||
|
|
||||||
|
---
|
||||||
|
#set list(label: [-])
|
||||||
|
- Bare hyphen
|
||||||
|
- is not a list
|
||||||
|
Loading…
x
Reference in New Issue
Block a user