diff --git a/src/common.rs b/src/common.rs index 52525eb..e886b32 100644 --- a/src/common.rs +++ b/src/common.rs @@ -20,16 +20,16 @@ pub fn indent>(s: S, level: usize) -> String { } /// conditionnaly encode HTML -pub fn encode_html<'a>(s: &'a str, encode: bool) -> Cow<'a, str> { - if encode { - html_escape::encode_text(s) - } else { - Cow::Borrowed(s) - } +pub fn encode_html(s: &str, encode: bool) -> Cow<'_, str> { + if encode { + html_escape::encode_text(s) + } else { + Cow::Borrowed(s) + } } #[test] -#[allow(clippy::blacklisted_name)] +#[allow(clippy::disallowed_names)] fn test_indent() { let foo = "Some string with only one line"; assert_eq!(indent(foo, 3), " Some string with only one line"); diff --git a/src/epub.rs b/src/epub.rs index ca7882e..c74a14b 100644 --- a/src/epub.rs +++ b/src/epub.rs @@ -763,9 +763,9 @@ impl EpubBuilder { // Ordering to to look as similar as possible to the W3 Recommendation ruleset // Slightly more permissive, there are some that are invalid start chars, but this is ok. fn is_id_char(c: char) -> bool { - ('A'..='Z').contains(&c) + c.is_ascii_uppercase() || c == '_' - || ('a'..='z').contains(&c) + || c.is_ascii_lowercase() || ('\u{C0}'..='\u{D6}').contains(&c) || ('\u{D8}'..='\u{F6}').contains(&c) || ('\u{F8}'..='\u{2FF}').contains(&c) @@ -780,7 +780,7 @@ fn is_id_char(c: char) -> bool { || ('\u{10000}'..='\u{EFFFF}').contains(&c) || c == '-' || c == '.' - || ('0'..='9').contains(&c) + || c.is_ascii_digit() || c == '\u{B7}' || ('\u{0300}'..='\u{036F}').contains(&c) || ('\u{203F}'..='\u{2040}').contains(&c) diff --git a/src/templates.rs b/src/templates.rs index 905a6d3..d8d48ea 100644 --- a/src/templates.rs +++ b/src/templates.rs @@ -8,14 +8,14 @@ pub static IBOOKS: &[u8] = include_bytes!("../templates/ibooks.xml"); pub static CONTAINER: &[u8] = include_bytes!("../templates/container.xml"); static ENGINE: Lazy<::upon::Engine> = Lazy::new(|| { - let mut engine = ::upon::Engine::new(); - engine.add_filter("eq", str::eq); - engine - } -); + let mut engine = ::upon::Engine::new(); + engine.add_filter("eq", str::eq); + engine +}); pub static TOC_NCX: Lazy<::upon::Template> = Lazy::new(|| { - ENGINE.compile(include_str!("../templates/toc.ncx")) + ENGINE + .compile(include_str!("../templates/toc.ncx")) .expect("error compiling 'toc.ncx' template'") }); @@ -24,11 +24,13 @@ pub mod v2 { use once_cell::sync::Lazy; pub static CONTENT_OPF: Lazy<::upon::Template> = Lazy::new(|| { - ENGINE.compile(include_str!("../templates/v2/content.opf")) + ENGINE + .compile(include_str!("../templates/v2/content.opf")) .expect("error compiling 'content.opf' (for EPUB 2.0) template") }); pub static NAV_XHTML: Lazy<::upon::Template> = Lazy::new(|| { - ENGINE.compile(include_str!("../templates/v2/nav.xhtml")) + ENGINE + .compile(include_str!("../templates/v2/nav.xhtml")) .expect("error compiling 'nav.xhtml' (for EPUB 2.0) template") }); } @@ -37,11 +39,13 @@ pub mod v3 { use once_cell::sync::Lazy; pub static CONTENT_OPF: Lazy<::upon::Template> = Lazy::new(|| { - ENGINE.compile(include_str!("../templates/v3/content.opf")) + ENGINE + .compile(include_str!("../templates/v3/content.opf")) .expect("error compiling 'content.opf' (for EPUB 3.0) template") }); pub static NAV_XHTML: Lazy<::upon::Template> = Lazy::new(|| { - ENGINE.compile(include_str!("../templates/v3/nav.xhtml")) + ENGINE + .compile(include_str!("../templates/v3/nav.xhtml")) .expect("error compiling 'nav.xhtml' (for EPUB 3.0) template") }); }