From 33cc485f1208067a5618f8f4226837541ce2763e Mon Sep 17 00:00:00 2001 From: Gly Date: Thu, 21 Sep 2023 18:26:49 +0200 Subject: [PATCH 1/3] Fix [BUG] - Extra newline in markdown tables #10 --- src/formatters/markdown/renderer/terminal/mode/code.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/formatters/markdown/renderer/terminal/mode/code.rs b/src/formatters/markdown/renderer/terminal/mode/code.rs index 9c5b5d0..0a3960d 100644 --- a/src/formatters/markdown/renderer/terminal/mode/code.rs +++ b/src/formatters/markdown/renderer/terminal/mode/code.rs @@ -60,7 +60,11 @@ impl Code { crossterm::cursor::MoveTo(Self::counter_space() as _, current_line_pos), crossterm::style::Print(utils::CODE_BLOCK_LINE_CHAR[2+sens as usize]), crossterm::cursor::MoveDown(1), - ) + )?; + if crossterm::cursor::position()?.0 > 0 { + queue!(std::io::stdout(), crossterm::cursor::MoveDown(1))?; + } + Ok(()) } fn draw_newline(&self) -> Result<(), Error> { let line = format!("{3}{0:0>1$}{3}{2}{3}", From 265b5546ba365f56f082222288e5329a402f05e0 Mon Sep 17 00:00:00 2001 From: Gly Date: Thu, 21 Sep 2023 18:36:39 +0200 Subject: [PATCH 2/3] Fix Markdown not parsed well #25 --- src/formatters/markdown/parser.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/formatters/markdown/parser.rs b/src/formatters/markdown/parser.rs index c8b9e35..9b9b06e 100644 --- a/src/formatters/markdown/parser.rs +++ b/src/formatters/markdown/parser.rs @@ -54,7 +54,7 @@ impl Parser { self.renderer.push_token(token::Token::Newline)?; self.previous_char = None; } - '*' | '_' | '`' => { + '*' | '_' | '`' if self.current_token.contains(c) || self.current_token.is_empty() => { self.current_token.push(c); } '-' | '#' if self.previous_char.is_none() => self.current_token.push(c), @@ -116,9 +116,9 @@ impl Parser { } self.previous_char = self.current_token.chars().last(); } - - let is_begin = self.previous_char.map(|c| !c.is_alphanumeric()) == Some(true) || self.previous_char == None; - let is_end = !current_char.is_alphanumeric(); // note: newline MUST resets state, so no need to check + let check_char = |c: char| !(c.is_alphanumeric() || ['*', '_', '`'].contains(&c)); + let is_begin = matches!(self.previous_char.map(check_char), Some(true) | None); + let is_end = check_char(current_char); // note: newline MUST resets state, so no need to check if is_begin == is_end && is_begin == false { break 'skip; } From 21947a9ce4bef5100f769728a65c24ef49dad489 Mon Sep 17 00:00:00 2001 From: Gly Date: Thu, 21 Sep 2023 18:37:46 +0200 Subject: [PATCH 3/3] update aio version --- Cargo.lock | 2 +- Cargo.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 3c080cf..baa3800 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -30,7 +30,7 @@ dependencies = [ [[package]] name = "aio-cli" -version = "0.7.0" +version = "0.7.1" dependencies = [ "aio-cargo-info", "anyhow", diff --git a/Cargo.toml b/Cargo.toml index f6f95c9..04fe39a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "aio-cli" description = "Streamlined AI Terminal Interactions" -version = "0.7.0" +version = "0.7.1" edition = "2021" authors = ["Gabin Lefranc "] readme = "README.md"