diff --git a/README.md b/README.md index e7eaf77..053d9d8 100644 --- a/README.md +++ b/README.md @@ -63,7 +63,7 @@ E = m c^2 -- ⚡ Very good run-time performance +- ⚡ Extremely fast run-time performance - 🔧 No configuration necessary - 📟 Command-line interface - 📜 Handles LaTeX file types `.tex`, `.bib`, `.cls`, and `.sty` diff --git a/notes.org b/notes.org index 442e421..de787f8 100644 --- a/notes.org +++ b/notes.org @@ -7,10 +7,12 @@ ** Ignore source lines ** Documentation ** Find todos +** \item should be on a new line * Bugs ** Handle list items and comments properly ** Handle verbatim and ignores better ** Only print ignore warnings once +** Off by one in linums? * Logging ** Store all logs on the fly in a vector ** Print them all at the end in an intelligent way diff --git a/src/format.rs b/src/format.rs index fcc7744..8b56fa0 100644 --- a/src/format.rs +++ b/src/format.rs @@ -3,7 +3,7 @@ use crate::logging::*; use crate::subs::*; use crate::wrap::*; use crate::Cli; -use log::Level::Error; +use log::Level::{Error, Info}; const MAX_PASS: usize = 10; @@ -51,6 +51,17 @@ pub fn format_file( args: &Cli, logs: &mut Vec, ) -> String { + if args.verbose { + record_log( + logs, + Info, + None, + filename.to_string(), + None, + None, + "Begin indenting.".to_string(), + ); + } let mut new_file = remove_extra_newlines(file); new_file = begin_end_environments_new_line(&new_file); new_file = remove_tabs(&new_file); diff --git a/src/indent.rs b/src/indent.rs index a307ed8..d21d551 100644 --- a/src/indent.rs +++ b/src/indent.rs @@ -129,8 +129,8 @@ pub fn apply_indent( let mut verbatim_count = 0; for (linum, line) in file.lines().enumerate() { - if RE_VERBATIM_BEGIN.is_match(line) { - verbatim_count += 1; + if RE_VERBATIM_END.is_match(line) { + verbatim_count -= 1; } ignore = get_ignore(line, linum, ignore, filename, logs, pass, true); if verbatim_count == 0 && !is_ignored(&ignore) { diff --git a/src/main.rs b/src/main.rs index e148da4..d0033cc 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,5 +1,5 @@ use clap::Parser; -use log::Level::{Error, Info}; +use log::Level::Error; #[allow(unused_imports)] use rstest::rstest; #[allow(unused_imports)] @@ -38,18 +38,6 @@ fn main() { for filename in &args.filenames { let mut logs: Vec = vec![]; - if args.verbose { - record_log( - &mut logs, - Info, - None, - filename.to_string(), - None, - None, - "Begin indenting.".to_string(), - ); - } - let extension_valid = check_extension_valid(filename); if extension_valid { let file = fs::read_to_string(filename).unwrap(); diff --git a/src/regexes.rs b/src/regexes.rs index d50174f..e98664e 100644 --- a/src/regexes.rs +++ b/src/regexes.rs @@ -1,7 +1,13 @@ use lazy_static::lazy_static; use regex::Regex; -const LISTS: [&str; 4] = ["itemize", "enumerate", "description", "inlineroman"]; +const LISTS: [&str; 5] = [ + "itemize", + "enumerate", + "description", + "inlineroman", + "inventory", +]; lazy_static! { pub static ref RE_NEWLINES: Regex = Regex::new(r"\n\n\n+").unwrap(); diff --git a/src/wrap.rs b/src/wrap.rs index 8cdd3c0..bec1cc7 100644 --- a/src/wrap.rs +++ b/src/wrap.rs @@ -108,8 +108,8 @@ pub fn wrap( let mut verbatim_count = 0; let mut ignore = Ignore::new(); for (linum, line) in file.lines().enumerate() { - if RE_VERBATIM_BEGIN.is_match(line) { - verbatim_count += 1; + if RE_VERBATIM_END.is_match(line) { + verbatim_count -= 1; } ignore = get_ignore(line, linum, ignore, filename, logs, pass, false); if line_needs_wrap(line) && verbatim_count == 0 && !is_ignored(&ignore)