diff --git a/Cargo.lock b/Cargo.lock index fd5b140..6092981 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -732,9 +732,9 @@ dependencies = [ [[package]] name = "html2text" -version = "0.7.1" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ea531de2b97971f4e6eb5c065bb5d8ec4d9260d4935b79d447f4885839ed6a82" +checksum = "c8de1df20581e4fb6df76286ae429b82970db9a2ab97153deceec71204f7e83c" dependencies = [ "html5ever", "lightningcss", diff --git a/aoc-client/Cargo.toml b/aoc-client/Cargo.toml index ab87adf..e9db88e 100644 --- a/aoc-client/Cargo.toml +++ b/aoc-client/Cargo.toml @@ -14,7 +14,7 @@ chrono = { version = "0.4", default-features = false, features = ["clock", "std" colored = "2.0.0" dirs = "4.0" html2md = "0.2" -html2text = { version = "0.7.1", features = ["css"] } +html2text = { version = "0.8.0", features = ["css"] } http = "0.2" log = "0.4" regex = "1.7" diff --git a/aoc-client/src/lib.rs b/aoc-client/src/lib.rs index 64b372a..cba7253 100644 --- a/aoc-client/src/lib.rs +++ b/aoc-client/src/lib.rs @@ -429,23 +429,27 @@ impl AocClient { } pub fn show_calendar(&self) -> AocResult<()> { + const AOC_CALENDAR_CSS_WORKAROUND: &'static str = " + .calendar > * > span > span { display: none; }"; let calendar_html = self.get_calendar_html()?; let calendar_text = if self.show_calendar_colour { html2text::config::rich() // The 2023 calendar has some lava animation using. // position:absolute spans. Hide them here. - .add_css(".lavafall { display: none; }") + .use_doc_css() + .add_css(AOC_CALENDAR_CSS_WORKAROUND) .coloured( calendar_html.as_bytes(), self.output_width, AocClient::colour_map ).unwrap() } else { - from_read_with_decorator( - calendar_html.as_bytes(), - self.output_width, - TrivialDecorator::new(), - ) + html2text::config::with_decorator(TrivialDecorator::new()) + .add_css(AOC_CALENDAR_CSS_WORKAROUND) + .string_from_read( + calendar_html.as_bytes(), + self.output_width + ).unwrap() }; println!("\n{calendar_text}"); Ok(())