mirror of
https://github.com/crate-ci/typos.git
synced 2024-11-21 16:41:01 -05:00
Merge pull request #1085 from epage/header
fix(varcon)!: Parse verified/level
This commit is contained in:
commit
e872ab859f
5 changed files with 21532 additions and 7186 deletions
|
@ -1,6 +1,8 @@
|
||||||
#[derive(Copy, Clone, PartialEq, Eq, Hash, Debug)]
|
#[derive(Copy, Clone, PartialEq, Eq, Hash, Debug)]
|
||||||
pub struct Cluster {
|
pub struct Cluster {
|
||||||
pub header: Option<&'static str>,
|
pub header: &'static str,
|
||||||
|
pub verified: bool,
|
||||||
|
pub level: usize,
|
||||||
pub entries: &'static [Entry],
|
pub entries: &'static [Entry],
|
||||||
pub notes: &'static [&'static str],
|
pub notes: &'static [&'static str],
|
||||||
}
|
}
|
||||||
|
@ -8,7 +10,9 @@ pub struct Cluster {
|
||||||
impl Cluster {
|
impl Cluster {
|
||||||
pub fn into_owned(self) -> crate::Cluster {
|
pub fn into_owned(self) -> crate::Cluster {
|
||||||
crate::Cluster {
|
crate::Cluster {
|
||||||
header: self.header.map(|s| s.to_owned()),
|
header: self.header.to_owned(),
|
||||||
|
verified: self.verified,
|
||||||
|
level: self.level,
|
||||||
entries: self.entries.iter().map(|s| s.into_owned()).collect(),
|
entries: self.entries.iter().map(|s| s.into_owned()).collect(),
|
||||||
notes: self.notes.iter().map(|s| (*s).to_owned()).collect(),
|
notes: self.notes.iter().map(|s| (*s).to_owned()).collect(),
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,7 +12,9 @@ pub use crate::parser::ClusterIter;
|
||||||
|
|
||||||
#[derive(Clone, PartialEq, Eq, Hash, Debug)]
|
#[derive(Clone, PartialEq, Eq, Hash, Debug)]
|
||||||
pub struct Cluster {
|
pub struct Cluster {
|
||||||
pub header: Option<String>,
|
pub header: String,
|
||||||
|
pub verified: bool,
|
||||||
|
pub level: usize,
|
||||||
pub entries: Vec<Entry>,
|
pub entries: Vec<Entry>,
|
||||||
pub notes: Vec<String>,
|
pub notes: Vec<String>,
|
||||||
}
|
}
|
||||||
|
|
|
@ -54,9 +54,9 @@ A Cv: acknowledgment's / Av B C: acknowledgement's
|
||||||
str![[r#"
|
str![[r#"
|
||||||
[
|
[
|
||||||
Cluster {
|
Cluster {
|
||||||
header: Some(
|
header: "acknowledgment ",
|
||||||
"acknowledgment <verified> (level 35)",
|
verified: true,
|
||||||
),
|
level: 35,
|
||||||
entries: [
|
entries: [
|
||||||
Entry {
|
Entry {
|
||||||
variants: [
|
variants: [
|
||||||
|
@ -231,9 +231,9 @@ A Cv: acknowledgment's / Av B C: acknowledgement's
|
||||||
str![[r#"
|
str![[r#"
|
||||||
[
|
[
|
||||||
Cluster {
|
Cluster {
|
||||||
header: Some(
|
header: "acknowledgment ",
|
||||||
"acknowledgment <verified> (level 35)",
|
verified: true,
|
||||||
),
|
level: 35,
|
||||||
entries: [
|
entries: [
|
||||||
Entry {
|
Entry {
|
||||||
variants: [
|
variants: [
|
||||||
|
@ -383,9 +383,9 @@ A Cv: acknowledgment's / Av B C: acknowledgement's
|
||||||
notes: [],
|
notes: [],
|
||||||
},
|
},
|
||||||
Cluster {
|
Cluster {
|
||||||
header: Some(
|
header: "acknowledgment ",
|
||||||
"acknowledgment <verified> (level 35)",
|
verified: true,
|
||||||
),
|
level: 35,
|
||||||
entries: [
|
entries: [
|
||||||
Entry {
|
Entry {
|
||||||
variants: [
|
variants: [
|
||||||
|
@ -551,7 +551,11 @@ impl Cluster {
|
||||||
let header = (
|
let header = (
|
||||||
"#",
|
"#",
|
||||||
winnow::ascii::space0,
|
winnow::ascii::space0,
|
||||||
winnow::ascii::till_line_ending,
|
winnow::token::take_till(1.., ('\r', '\n', '<', '(')),
|
||||||
|
winnow::ascii::space0,
|
||||||
|
opt(("<verified>", winnow::ascii::space0)),
|
||||||
|
delimited("(level ", winnow::ascii::digit1, ')').parse_to::<usize>(),
|
||||||
|
winnow::ascii::space0,
|
||||||
winnow::ascii::line_ending,
|
winnow::ascii::line_ending,
|
||||||
);
|
);
|
||||||
let note = preceded(
|
let note = preceded(
|
||||||
|
@ -559,7 +563,7 @@ impl Cluster {
|
||||||
terminated(winnow::ascii::till_line_ending, winnow::ascii::line_ending),
|
terminated(winnow::ascii::till_line_ending, winnow::ascii::line_ending),
|
||||||
);
|
);
|
||||||
let mut cluster = (
|
let mut cluster = (
|
||||||
opt(header),
|
header,
|
||||||
winnow::combinator::repeat(
|
winnow::combinator::repeat(
|
||||||
1..,
|
1..,
|
||||||
terminated(Entry::parse_, winnow::ascii::line_ending),
|
terminated(Entry::parse_, winnow::ascii::line_ending),
|
||||||
|
@ -568,10 +572,14 @@ impl Cluster {
|
||||||
);
|
);
|
||||||
let (header, entries, notes): (_, _, Vec<_>) = cluster.parse_next(input)?;
|
let (header, entries, notes): (_, _, Vec<_>) = cluster.parse_next(input)?;
|
||||||
|
|
||||||
let header = header.map(|s| s.2.to_owned());
|
let verified = header.4.is_some();
|
||||||
|
let level = header.5;
|
||||||
|
let header = header.2.to_owned();
|
||||||
let notes = notes.into_iter().map(|s| s.to_owned()).collect();
|
let notes = notes.into_iter().map(|s| s.to_owned()).collect();
|
||||||
let c = Self {
|
let c = Self {
|
||||||
header,
|
header,
|
||||||
|
verified,
|
||||||
|
level,
|
||||||
entries,
|
entries,
|
||||||
notes,
|
notes,
|
||||||
};
|
};
|
||||||
|
@ -612,9 +620,9 @@ A Cv: acknowledgment's / Av B C: acknowledgement's
|
||||||
actual.to_debug(),
|
actual.to_debug(),
|
||||||
str![[r#"
|
str![[r#"
|
||||||
Cluster {
|
Cluster {
|
||||||
header: Some(
|
header: "acknowledgment ",
|
||||||
"acknowledgment <verified> (level 35)",
|
verified: true,
|
||||||
),
|
level: 35,
|
||||||
entries: [
|
entries: [
|
||||||
Entry {
|
Entry {
|
||||||
variants: [
|
variants: [
|
||||||
|
@ -793,9 +801,9 @@ A B C: coloration's / B. Cv: colouration's
|
||||||
actual.to_debug(),
|
actual.to_debug(),
|
||||||
str![[r#"
|
str![[r#"
|
||||||
Cluster {
|
Cluster {
|
||||||
header: Some(
|
header: "coloration ",
|
||||||
"coloration <verified> (level 50)",
|
verified: true,
|
||||||
),
|
level: 50,
|
||||||
entries: [
|
entries: [
|
||||||
Entry {
|
Entry {
|
||||||
variants: [
|
variants: [
|
||||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -36,6 +36,8 @@ fn generate<W: std::io::Write>(file: &mut W) {
|
||||||
cluster.infer();
|
cluster.infer();
|
||||||
writeln!(file, "Cluster {{").unwrap();
|
writeln!(file, "Cluster {{").unwrap();
|
||||||
writeln!(file, " header: {:?},", cluster.header).unwrap();
|
writeln!(file, " header: {:?},", cluster.header).unwrap();
|
||||||
|
writeln!(file, " verified: {:?},", cluster.verified).unwrap();
|
||||||
|
writeln!(file, " level: {:?},", cluster.level).unwrap();
|
||||||
writeln!(file, " entries: &[").unwrap();
|
writeln!(file, " entries: &[").unwrap();
|
||||||
for entry in &cluster.entries {
|
for entry in &cluster.entries {
|
||||||
writeln!(file, " Entry {{").unwrap();
|
writeln!(file, " Entry {{").unwrap();
|
||||||
|
|
Loading…
Reference in a new issue