Include punctuation in regex.
This commit is contained in:
@@ -16,15 +16,6 @@ enum Error {
|
||||
Xml(#[from] quick_xml::Error),
|
||||
}
|
||||
|
||||
fn title(s: &str) -> String {
|
||||
let mut c = s.chars();
|
||||
|
||||
match c.next() {
|
||||
None => String::new(),
|
||||
Some(f) => f.to_uppercase().chain(c).collect(),
|
||||
}
|
||||
}
|
||||
|
||||
fn main() -> Result<()> {
|
||||
let inputs = env::args().skip(1);
|
||||
|
||||
@@ -112,6 +103,9 @@ fn main() -> Result<()> {
|
||||
let stdout = io::stdout();
|
||||
let mut lock = stdout.lock();
|
||||
|
||||
let mut entries = entries.into_iter().collect::<Vec<_>>();
|
||||
entries.sort_unstable_by_key(|(lang, _)| lang.to_639_3());
|
||||
|
||||
for (language, mut results) in entries.into_iter() {
|
||||
results.sort_unstable();
|
||||
results.dedup();
|
||||
@@ -138,7 +132,13 @@ fn main() -> Result<()> {
|
||||
|
||||
for kind in ranges {
|
||||
match kind {
|
||||
Kind::Single(ch) => regex.push(ch),
|
||||
Kind::Single(ch) => match ch {
|
||||
'[' => regex.push_str(r"\["),
|
||||
']' => regex.push_str(r"\]"),
|
||||
'{' => regex.push_str(r"\{"),
|
||||
'}' => regex.push_str(r"\}"),
|
||||
_ => regex.push(ch),
|
||||
},
|
||||
Kind::Range(from, to) => {
|
||||
regex.push(from);
|
||||
regex.push('-');
|
||||
@@ -198,6 +198,8 @@ impl PartialOrd for Kind {
|
||||
impl Ord for Kind {
|
||||
fn cmp(&self, other: &Kind) -> Ordering {
|
||||
match (self, other) {
|
||||
(Kind::Single('-'), Kind::Single(_)) => Ordering::Less,
|
||||
(Kind::Single(_), Kind::Single('-')) => Ordering::Greater,
|
||||
(Kind::Single(a), Kind::Single(b)) => a.cmp(&b),
|
||||
(Kind::Single(a), Kind::Range(b, _)) => a.cmp(&b),
|
||||
(Kind::Range(a, _), Kind::Single(b)) => a.cmp(&b),
|
||||
@@ -266,9 +268,11 @@ mod parse {
|
||||
}
|
||||
Ok(Event::Start(ref e)) if e.name() == b"exemplarCharacters" => {
|
||||
parse = e.attributes().count() == 0
|
||||
|| e.attributes()
|
||||
.filter_map(Result::ok)
|
||||
.any(|a| a.key == b"type" && a.value.as_ref() == b"auxiliary");
|
||||
|| e.attributes().filter_map(Result::ok).any(|a| {
|
||||
a.key == b"type"
|
||||
&& (a.value.as_ref() == b"auxiliary"
|
||||
|| a.value.as_ref() == b"punctuation")
|
||||
});
|
||||
}
|
||||
Ok(Event::End(ref e)) if e.name() == b"exemplarCharacters" && parse => {
|
||||
parse = false;
|
||||
|
||||
Reference in New Issue
Block a user