Skip to content

Commit

Permalink
Filter candidates defined after the the current page
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 committed Jul 10, 2024
1 parent a505b39 commit 4fbcbda
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 0 deletions.
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 4fbcbda

Please sign in to comment.