mirror of
https://github.com/crate-ci/typos.git
synced 2024-11-21 16:41:01 -05:00
refactor(varcon): Consolidate description start with description
This commit is contained in:
parent
c1644d8876
commit
ffcca9ff99
1 changed files with 17 additions and 24 deletions
|
@ -964,24 +964,12 @@ impl Entry {
|
||||||
let variants =
|
let variants =
|
||||||
winnow::combinator::separated(1.., Variant::parse_, var_sep).parse_next(input)?;
|
winnow::combinator::separated(1.., Variant::parse_, var_sep).parse_next(input)?;
|
||||||
|
|
||||||
let desc_sep = (winnow::ascii::space0, '|');
|
let mut e = Self::parse_description.parse_next(input)?;
|
||||||
let description = opt((desc_sep, Self::parse_description)).parse_next(input)?;
|
|
||||||
|
|
||||||
let comment_sep = (winnow::ascii::space0, '#');
|
let comment_sep = (winnow::ascii::space0, '#');
|
||||||
let comment =
|
let comment =
|
||||||
opt((comment_sep, space1, winnow::ascii::till_line_ending)).parse_next(input)?;
|
opt((comment_sep, space1, winnow::ascii::till_line_ending)).parse_next(input)?;
|
||||||
|
|
||||||
let mut e = match description {
|
|
||||||
Some((_, description)) => description,
|
|
||||||
None => Self {
|
|
||||||
variants: Vec::new(),
|
|
||||||
pos: None,
|
|
||||||
archaic: false,
|
|
||||||
note: false,
|
|
||||||
description: None,
|
|
||||||
comment: None,
|
|
||||||
},
|
|
||||||
};
|
|
||||||
e.variants = variants;
|
e.variants = variants;
|
||||||
e.comment = comment.map(|c| c.2.to_owned());
|
e.comment = comment.map(|c| c.2.to_owned());
|
||||||
Ok(e)
|
Ok(e)
|
||||||
|
@ -1000,18 +988,23 @@ impl Entry {
|
||||||
comment: None,
|
comment: None,
|
||||||
};
|
};
|
||||||
|
|
||||||
let _ = opt((space1, "<abbr>")).parse_next(input)?;
|
if opt((winnow::ascii::space0, '|'))
|
||||||
let _ = opt((space1, "<pl>")).parse_next(input)?;
|
.parse_next(input)?
|
||||||
let pos = opt((space1, delimited('<', cut_err(Pos::parse_), cut_err('>'))))
|
.is_some()
|
||||||
.parse_next(input)?;
|
{
|
||||||
let archaic = opt((space1, archaic)).parse_next(input)?;
|
let _ = opt((space1, "<abbr>")).parse_next(input)?;
|
||||||
let note = opt((space1, NOTE_PREFIX)).parse_next(input)?;
|
let _ = opt((space1, "<pl>")).parse_next(input)?;
|
||||||
let description = opt((space1, description)).parse_next(input)?;
|
let pos = opt((space1, delimited('<', cut_err(Pos::parse_), cut_err('>'))))
|
||||||
|
.parse_next(input)?;
|
||||||
|
let archaic = opt((space1, archaic)).parse_next(input)?;
|
||||||
|
let note = opt((space1, NOTE_PREFIX)).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.is_some();
|
entry.note = note.is_some();
|
||||||
entry.description = description.map(|(_, d)| d.to_owned());
|
entry.description = description.map(|(_, d)| d.to_owned());
|
||||||
|
}
|
||||||
Ok(entry)
|
Ok(entry)
|
||||||
})
|
})
|
||||||
.parse_next(input)
|
.parse_next(input)
|
||||||
|
|
Loading…
Reference in a new issue