Fix embarrassing point counting bug

This commit is contained in:
Maxime Augier 2024-05-23 09:40:04 +02:00
parent b475e4bb8d
commit 2a2d6cd88a

View File

@ -6,14 +6,14 @@
#let solution_mode = { sys.inputs.at("mode", default: "") == "solution" }; #let solution_mode = { sys.inputs.at("mode", default: "") == "solution" };
#let points_counter(h) = { #let points_counter(h) = {
// Find the first heading at a level equal or higher than this one // Find the first heading at a level equal or lower (more important) than this one
let headings_after = query(selector(heading) let headings_after = query(selector(heading)
.after(h.location()) .after(h.location(), inclusive: false)
).filter(nh => nh.level <= h.level); ).filter(nh => nh.level <= h.level);
let start_value = pctr.at(h.location()) let start_value = pctr.at(h.location())
let stop_value = if headings_after.len() == 0 { pctr.final() } let stop_value = if headings_after.len() == 0 { pctr.final() }
else { pctr.at(headings_after.last().location()) } else { pctr.at(headings_after.first().location()) }
stop_value.at(0) - start_value.at(0) stop_value.at(0) - start_value.at(0)
} }