Skip to content

Commit

Permalink
Merge pull request #26 from glcraft/fixes
Browse files Browse the repository at this point in the history
Fixes #25 and #10
  • Loading branch information
glcraft authored Sep 21, 2023
2 parents cacfe21 + 21947a9 commit 088d0d2
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 7 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -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 <[email protected]>"]
readme = "README.md"
Expand Down
8 changes: 4 additions & 4 deletions src/formatters/markdown/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ impl<R: Renderer> Parser<R> {
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),
Expand Down Expand Up @@ -116,9 +116,9 @@ impl<R: Renderer> Parser<R> {
}
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;
}
Expand Down
6 changes: 5 additions & 1 deletion src/formatters/markdown/renderer/terminal/mode/code.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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}",
Expand Down

0 comments on commit 088d0d2

Please sign in to comment.