Skip to content

Commit

Permalink
Fix: fix a problem in which the second and subsequent lines are ignor…
Browse files Browse the repository at this point in the history
…ed in standard input
  • Loading branch information
gw31415 committed Oct 31, 2023
1 parent e7177e0 commit b0d7b27
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "math2img"
version = "0.1.0"
version = "0.1.2"
edition = "2021"
authors = ["gw31415 <git@amas.dev>"]
description = "Convert mathematical expressions into images"
Expand Down
17 changes: 16 additions & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ use usvg::{fontdb, TreeParsing, TreeTextToPath};
mod args {
use clap::Parser;
use clap_complete::Shell;
use rustyline::error::ReadlineError;
use std::{borrow::Cow, path::PathBuf};

/// Convert mathematical expressions into images
Expand Down Expand Up @@ -66,7 +67,21 @@ mod args {
Cow::Borrowed(unsafe { self.math.as_ref().unwrap_unchecked() })
} else {
let Ok(mut rl) = rustyline::DefaultEditor::new() else { return None; };
let Ok(string) = rl.readline("> ") else { return None; };
let mut string = String::new();
loop {
match rl.readline("> ") {
Ok(line) => {
string.push_str(&line);
string.push('\n');
}
Err(ReadlineError::Eof) => {
break;
}
Err(_) => {
return None;
}
}
}
Cow::Owned(string)
})
}
Expand Down

0 comments on commit b0d7b27

Please sign in to comment.