mirror of
https://codeberg.org/Cyborus/forgejo-cli.git
synced 2024-11-10 03:59:31 +01:00
fix(markdown): trailing paragraph newlines
This commit is contained in:
parent
7a2d622152
commit
d060a73cde
1 changed files with 11 additions and 3 deletions
10
src/main.rs
10
src/main.rs
|
@ -357,15 +357,18 @@ fn markdown(text: &str) -> String {
|
|||
ansi_printer.pause_style();
|
||||
ansi_printer.prefix();
|
||||
ansi_printer.resume_style();
|
||||
for (item, side) in render_queue {
|
||||
let mut iter = render_queue.into_iter().peekable();
|
||||
while let Some((item, side)) = iter.next() {
|
||||
use comrak::nodes::NodeValue;
|
||||
use Side::*;
|
||||
match (&item.data.borrow().value, side) {
|
||||
(NodeValue::Paragraph, Start) => (),
|
||||
(NodeValue::Paragraph, End) => {
|
||||
if iter.peek().is_some_and(|(_, side)| *side == Start) {
|
||||
ansi_printer.newline();
|
||||
ansi_printer.newline();
|
||||
}
|
||||
}
|
||||
(NodeValue::Text(s), Start) => ansi_printer.text(s),
|
||||
(NodeValue::Link(_), Start) => {
|
||||
ansi_printer.start_fg(bright_blue);
|
||||
|
@ -439,6 +442,7 @@ fn markdown(text: &str) -> String {
|
|||
(NodeValue::Heading(_), End) => {
|
||||
ansi_printer.reset();
|
||||
ansi_printer.newline();
|
||||
ansi_printer.newline();
|
||||
}
|
||||
|
||||
(NodeValue::List(list), Start) => {
|
||||
|
@ -450,6 +454,7 @@ fn markdown(text: &str) -> String {
|
|||
if list.list_type == comrak::nodes::ListType::Ordered {
|
||||
list_numbers.pop();
|
||||
}
|
||||
ansi_printer.newline();
|
||||
}
|
||||
(NodeValue::Item(list), Start) => {
|
||||
if list.list_type == comrak::nodes::ListType::Ordered {
|
||||
|
@ -467,6 +472,9 @@ fn markdown(text: &str) -> String {
|
|||
ansi_printer.cur_line_len += 2;
|
||||
}
|
||||
}
|
||||
(NodeValue::Item(_), End) => {
|
||||
ansi_printer.newline();
|
||||
}
|
||||
|
||||
(NodeValue::LineBreak, Start) => ansi_printer.newline(),
|
||||
(NodeValue::SoftBreak, Start) => ansi_printer.newline(),
|
||||
|
|
Loading…
Reference in a new issue