mirror of
https://github.com/crate-ci/typos.git
synced 2024-11-25 10:31:02 -05:00
refactor(varcon): Pull out note parser
This commit is contained in:
parent
11d6e1d968
commit
187d992ef4
1 changed files with 7 additions and 2 deletions
|
@ -997,12 +997,12 @@ impl Entry {
|
||||||
let pos = opt((space1, delimited('<', cut_err(Pos::parse_), cut_err('>'))))
|
let pos = opt((space1, delimited('<', cut_err(Pos::parse_), cut_err('>'))))
|
||||||
.parse_next(input)?;
|
.parse_next(input)?;
|
||||||
let archaic = opt((space1, archaic)).parse_next(input)?;
|
let archaic = opt((space1, archaic)).parse_next(input)?;
|
||||||
let note = opt((space1, NOTE_PREFIX, space1, description)).parse_next(input)?;
|
let note = opt((space1, note)).parse_next(input)?;
|
||||||
let description = opt((space1, description)).parse_next(input)?;
|
let description = opt((space1, description)).parse_next(input)?;
|
||||||
|
|
||||||
entry.pos = pos.map(|(_, p)| p);
|
entry.pos = pos.map(|(_, p)| p);
|
||||||
entry.archaic = archaic.is_some();
|
entry.archaic = archaic.is_some();
|
||||||
entry.note = note.map(|(_, _, _, d)| d.to_owned());
|
entry.note = note.map(|(_, d)| d.to_owned());
|
||||||
entry.description = description.map(|(_, d)| d.to_owned());
|
entry.description = description.map(|(_, d)| d.to_owned());
|
||||||
}
|
}
|
||||||
Ok(entry)
|
Ok(entry)
|
||||||
|
@ -1011,6 +1011,11 @@ impl Entry {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn note(input: &mut &str) -> PResult<String, ()> {
|
||||||
|
let (_, _, note) = (NOTE_PREFIX, space1, description).parse_next(input)?;
|
||||||
|
Ok(note.to_owned())
|
||||||
|
}
|
||||||
|
|
||||||
const NOTE_PREFIX: &str = "--";
|
const NOTE_PREFIX: &str = "--";
|
||||||
|
|
||||||
fn archaic(input: &mut &str) -> PResult<(), ()> {
|
fn archaic(input: &mut &str) -> PResult<(), ()> {
|
||||||
|
|
Loading…
Reference in a new issue