mirror of
https://github.com/crate-ci/typos.git
synced 2024-12-22 15:42:23 -05:00
refactor(varcon): Pull out entry parser
This commit is contained in:
parent
1e9d9813a0
commit
0068450bf1
1 changed files with 16 additions and 7 deletions
|
@ -1001,13 +1001,11 @@ impl Entry {
|
|||
))
|
||||
.parse_next(input)?;
|
||||
let archaic =
|
||||
winnow::combinator::opt((winnow::ascii::space1, "(-)")).parse_next(input)?;
|
||||
let note = winnow::combinator::opt((winnow::ascii::space1, "--")).parse_next(input)?;
|
||||
let description = winnow::combinator::opt((
|
||||
winnow::ascii::space1,
|
||||
winnow::token::take_till(0.., ('\n', '\r', '#')),
|
||||
))
|
||||
.parse_next(input)?;
|
||||
winnow::combinator::opt((winnow::ascii::space1, archaic)).parse_next(input)?;
|
||||
let note =
|
||||
winnow::combinator::opt((winnow::ascii::space1, NOTE_PREFIX)).parse_next(input)?;
|
||||
let description =
|
||||
winnow::combinator::opt((winnow::ascii::space1, description)).parse_next(input)?;
|
||||
|
||||
let variants = Vec::new();
|
||||
let pos = pos.map(|(_, p)| p);
|
||||
|
@ -1028,6 +1026,17 @@ impl Entry {
|
|||
}
|
||||
}
|
||||
|
||||
const NOTE_PREFIX: &str = "--";
|
||||
|
||||
fn archaic(input: &mut &str) -> PResult<(), ()> {
|
||||
"(-)".void().parse_next(input)
|
||||
}
|
||||
|
||||
fn description(input: &mut &str) -> PResult<String, ()> {
|
||||
let description = winnow::token::take_till(0.., ('\n', '\r', '#')).parse_next(input)?;
|
||||
Ok(description.to_owned())
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod test_entry {
|
||||
#![allow(clippy::bool_assert_comparison)]
|
||||
|
|
Loading…
Reference in a new issue