Skip to content

Commit

Permalink
Filter candidates defined after the current page (#21)
Browse files Browse the repository at this point in the history
Previously when both prev and last candidates were none hydra would show
candidates defined on later pages. I believe that candidates defined on
pages after the current page should never be displayed.
  • Loading branch information
freundTech authored Jul 11, 2024
1 parent a505b39 commit b33fb6d
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 0 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@

## Changed

## Fixed
- hydra no longer considers candidates on pages after the current page (https://github.com/tingerrr/hydra/pull/21)

---

# [v0.5.0](https://github.com/tingerrr/hydra/releases/tags/v0.5.0)
Expand Down
1 change: 1 addition & 0 deletions src/core.typ
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@
next-targets = next-targets.filter(x => (ctx.primary.filter)(ctx, x))
last-targets = last-targets.filter(x => (ctx.primary.filter)(ctx, x))
}
next-targets = next-targets.filter(x => x.location().page() == ctx.anchor-loc.page())
last-targets = last-targets.filter(x => x.location().page() == ctx.anchor-loc.page())

let prev = if prev-targets != () { prev-targets.last() }
Expand Down
Binary file added tests/regressions/fallback-to-future/ref/1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added tests/regressions/fallback-to-future/ref/2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added tests/regressions/fallback-to-future/ref/3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added tests/regressions/fallback-to-future/ref/4.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
19 changes: 19 additions & 0 deletions tests/regressions/fallback-to-future/test.typ
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// Synopsis:
// - When both last and prev candidates where none hydra would fall back to a heading defined on a future page.
// Headings defined after the current page should never be displayed.

#import "/src/lib.typ": hydra

#set page(
paper: "a7",
header: context hydra(),
)
#set heading(numbering: "1.1")
#show heading.where(level: 1): it => pagebreak(weak: true) + it
#set par(justify: true)

#lorem(100)

= Introduction
#lorem(100)

0 comments on commit b33fb6d

Please sign in to comment.