Skip to content

Commit

Permalink
Add linter fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Bennett-Petzold committed Jun 26, 2024
1 parent 8cef1f8 commit 17f0fb4
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 20 deletions.
14 changes: 7 additions & 7 deletions src/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,16 @@ pub fn indent<S: AsRef<str>>(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");
Expand Down
6 changes: 3 additions & 3 deletions src/epub.rs
Original file line number Diff line number Diff line change
Expand Up @@ -763,9 +763,9 @@ impl<Z: Zip> EpubBuilder<Z> {
// 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)
Expand All @@ -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)
Expand Down
24 changes: 14 additions & 10 deletions src/templates.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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'")
});

Expand All @@ -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")
});
}
Expand All @@ -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")
});
}

0 comments on commit 17f0fb4

Please sign in to comment.