Skip to content

Commit

Permalink
Do not miss non-leaf titles. (Ticket: #PP-1954)
Browse files Browse the repository at this point in the history
  • Loading branch information
io7m committed Nov 26, 2024
1 parent a04bc8c commit dd55621
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
10 changes: 8 additions & 2 deletions README-CHANGES.xml
Original file line number Diff line number Diff line change
Expand Up @@ -171,8 +171,14 @@
</c:change>
</c:changes>
</c:release>
<c:release date="2024-11-19T11:43:59+00:00" is-open="true" ticket-system="org.lyrasis.jira" version="6.6.0">
<c:changes/>
<c:release date="2024-11-26T13:22:29+00:00" is-open="true" ticket-system="org.lyrasis.jira" version="6.6.0">
<c:changes>
<c:change date="2024-11-26T13:22:29+00:00" summary="Do not miss non-leaf titles.">
<c:tickets>
<c:ticket id="PP-1954"/>
</c:tickets>
</c:change>
</c:changes>
</c:release>
</c:releases>
<c:ticket-systems>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ object SR2NavigationGraphs {
private fun makeNavigationPoint(publication: Publication, link: Link): SR2NavigationPoint {
val title =
link.title?.takeIf(String::isNotBlank)
?: titleFromTOC(publication.tableOfContents, link)
?: titleFromTOC(null, publication.tableOfContents, link)
?: ""
return SR2NavigationPoint(
title,
Expand All @@ -62,9 +62,9 @@ object SR2NavigationGraphs {
* In case of multiples matches, deeper items have precedence because they're likely to be more specific.
*/

private fun titleFromTOC(toc: List<Link>, link: Link): String? {
private fun titleFromTOC(tocEntryParent: Link?, toc: List<Link>, link: Link): String? {
for (entry in toc) {
this.titleFromTOC(entry.children, link)?.let {
this.titleFromTOC(entry, entry.children, link)?.let {
return it
}
}
Expand All @@ -75,6 +75,9 @@ object SR2NavigationGraphs {
}
}

if (tocEntryParent?.href == link.href && tocEntryParent.title != null) {
return tocEntryParent.title
}
return null
}
}

0 comments on commit dd55621

Please sign in to comment.