Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 11 additions & 10 deletions aoc-client/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -368,9 +368,10 @@ impl AocClient {
// Remove 2019 shadows
r#"|(<span style="color[^>]*position:absolute"#,
r#"[^>]*>\.</span>)"#,
// Remove 2019 "sunbeam"
r#"|(<span class="sunbeam"[^>]*>"#,
r#"<span style="animation-delay[^>]*>\*</span></span>)"#,
// Remove 2019 and 2023 animations
r#"|(<span [^>]*>"#,
r#"(<span [^>]*style="[^>]*animation-delay[^>]*>[^>]*</span>)+"#,
r#"</span>)"#,
))
.unwrap()
.replace_all(&main, "")
Expand All @@ -384,28 +385,28 @@ impl AocClient {
))
.unwrap();

let all_stars = main.contains("calendar calendar-perfect");

// Remove stars that have not been collected
let mut star_state = "";

let calendar = cleaned_up
.lines()
.map(|line| {
let class = class_regex
.captures(line)
.and_then(|c| c.name("class"))
.map(|c| c.as_str())
.unwrap_or("");
.map(|c| c.as_str());

let stars =
if class.contains("calendar-verycomplete") || all_stars {
if let Some(class) = class {
star_state = if class.contains("calendar-verycomplete") {
"**"
} else if class.contains("calendar-complete") {
"*"
} else {
""
};
}

star_regex.replace(line, stars)
star_regex.replace(line, star_state)
})
.collect::<Vec<_>>()
.join("\n");
Expand Down