mirror of
https://github.com/helix-editor/helix.git
synced 2025-01-19 05:27:07 +04:00
Do not add extra line breaks in markdown lists (#2689)
This commit is contained in:
parent
4a27e2d938
commit
e0532771cc
@ -171,6 +171,8 @@ fn parse(&self, theme: Option<&Theme>) -> tui::text::Text<'_> {
|
|||||||
Event::Start(Tag::List(list)) => list_stack.push(list),
|
Event::Start(Tag::List(list)) => list_stack.push(list),
|
||||||
Event::End(Tag::List(_)) => {
|
Event::End(Tag::List(_)) => {
|
||||||
list_stack.pop();
|
list_stack.pop();
|
||||||
|
// whenever list closes, new line
|
||||||
|
lines.push(Spans::default());
|
||||||
}
|
}
|
||||||
Event::Start(Tag::Item) => {
|
Event::Start(Tag::Item) => {
|
||||||
tags.push(Tag::Item);
|
tags.push(Tag::Item);
|
||||||
@ -186,11 +188,19 @@ fn parse(&self, theme: Option<&Theme>) -> tui::text::Text<'_> {
|
|||||||
| Tag::Paragraph
|
| Tag::Paragraph
|
||||||
| Tag::CodeBlock(CodeBlockKind::Fenced(_))
|
| Tag::CodeBlock(CodeBlockKind::Fenced(_))
|
||||||
| Tag::Item => {
|
| Tag::Item => {
|
||||||
// whenever code block or paragraph closes, new line
|
|
||||||
let spans = std::mem::take(&mut spans);
|
let spans = std::mem::take(&mut spans);
|
||||||
if !spans.is_empty() {
|
if !spans.is_empty() {
|
||||||
lines.push(Spans::from(spans));
|
lines.push(Spans::from(spans));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
_ => (),
|
||||||
|
}
|
||||||
|
|
||||||
|
// whenever heading, code block or paragraph closes, new line
|
||||||
|
match tag {
|
||||||
|
Tag::Heading(_, _, _)
|
||||||
|
| Tag::Paragraph
|
||||||
|
| Tag::CodeBlock(CodeBlockKind::Fenced(_)) => {
|
||||||
lines.push(Spans::default());
|
lines.push(Spans::default());
|
||||||
}
|
}
|
||||||
_ => (),
|
_ => (),
|
||||||
|
Loading…
Reference in New Issue
Block a user