Skip to content

Commit

Permalink
fix: Updated AoC CSS workaround:
Browse files Browse the repository at this point in the history
* Use CSS as suggested by Eric Wastl to ignore the calendar animations.
* Update to html2text 0.8.0 which supports that CSS.
  • Loading branch information
jugglerchris committed Dec 21, 2023
1 parent 866312b commit 1d5467a
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 9 deletions.
4 changes: 2 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion aoc-client/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
16 changes: 10 additions & 6 deletions aoc-client/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(())
Expand Down

0 comments on commit 1d5467a

Please sign in to comment.