diff --git a/src/lib.rs b/src/lib.rs index 018ee92..b2771fc 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -17,4 +17,4 @@ pub use event::Event; #[doc(inline)] pub use mathml::{push_mathml, write_mathml}; #[doc(inline)] -pub use parser::{Parser, error::ParserError, storage::Storage}; +pub use parser::{error::ParserError, storage::Storage, Parser}; diff --git a/src/parser.rs b/src/parser.rs index 53542e8..01378a4 100644 --- a/src/parser.rs +++ b/src/parser.rs @@ -711,7 +711,10 @@ mod tests { #[test] fn error() { let store = Storage::new(); - let parser = Parser::new(r"\def\blah#1#2{\fra#1#2} \def\abc#1{\blah{a}#1} \abc{b}", &store); + let parser = Parser::new( + r"\def\blah#1#2{\fra#1#2} \def\abc#1{\blah{a}#1} \abc{b}", + &store, + ); let events = parser.collect::>(); assert!(events[0].is_err()); diff --git a/src/parser/error.rs b/src/parser/error.rs index 268be0c..0505e95 100644 --- a/src/parser/error.rs +++ b/src/parser/error.rs @@ -49,14 +49,14 @@ impl ParserError { .map(|index| span_stack.expansions[index].full_expansion) .unwrap_or(span_stack.input); - if lower_bound > expansion.expansion_length { lower_bound += expansion.call_site_in_origin.start; - upper_bound = (expansion.call_site_in_origin.end + upper_bound).min(next_string.len()); - + upper_bound = + (expansion.call_site_in_origin.end + upper_bound).min(next_string.len()); + continue; } - + let context_str = &expansion.full_expansion[lower_bound..upper_bound]; context.push_str(context_str); context.push('\n'); diff --git a/src/parser/lex.rs b/src/parser/lex.rs index b2443c2..1b6470e 100644 --- a/src/parser/lex.rs +++ b/src/parser/lex.rs @@ -19,9 +19,9 @@ pub fn definition<'a>(input: &mut &'a str) -> InnerResult<(&'a str, &'a str, &'a ErrorKind::CommentInParamText } else { ErrorKind::BracesInParamText - }) + }); } - + *input = rest; let replacement_text = group_content(input, "{", "}")?; @@ -148,9 +148,7 @@ pub fn delimiter(input: &mut &str) -> InnerResult<(char, DelimiterType)> { /// /// Returns the control sequence, the token it should be assigned to, and the rest of the input /// with both tokens not consumed. -pub fn futurelet_assignment<'a>( - input: &mut &'a str, -) -> InnerResult<(&'a str, Token<'a>, &'a str)> { +pub fn futurelet_assignment<'a>(input: &mut &'a str) -> InnerResult<(&'a str, Token<'a>, &'a str)> { let control_sequence = control_sequence(input)?; let input_with_tokens = *input; diff --git a/src/parser/storage.rs b/src/parser/storage.rs index 962e08a..df58bc2 100644 --- a/src/parser/storage.rs +++ b/src/parser/storage.rs @@ -22,4 +22,3 @@ impl Storage { self.0.reset(); } } - diff --git a/tests/common/mod.rs b/tests/common/mod.rs index c981655..52a94bf 100644 --- a/tests/common/mod.rs +++ b/tests/common/mod.rs @@ -6,7 +6,7 @@ use fantoccini::{Client, ClientBuilder, Locator}; use heck::ToTitleCase; use inventory::collect; use libtest_mimic::{Arguments, Conclusion, Failed, Trial}; -use pulldown_latex::{config::RenderConfig, mathml::push_mathml, Storage, Parser}; +use pulldown_latex::{config::RenderConfig, mathml::push_mathml, Parser, Storage}; use tokio::process::Command; #[allow(clippy::type_complexity)]