Skip to content

Commit

Permalink
Backport "Fix NoSuchElementException in scaladoc" to LTS (#19067)
Browse files Browse the repository at this point in the history
Backports #18184 to the LTS branch.

PR submitted by the release tooling.
[skip ci]
  • Loading branch information
Kordyjan authored Dec 8, 2023
2 parents b100d2b + 09e59f1 commit 7058a8e
Showing 1 changed file with 5 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,15 @@ object SectionRenderingExtension extends HtmlRenderer.HtmlRendererExtension:

case class AnchorLink(link: String) extends BlankLine(BasedSequence.EmptyBasedSequence())
object SectionHandler extends CustomNodeRenderer[Section]:
val repeatedIds: mutable.Map[(NodeRendererContext, BasedSequence), Int] = mutable.Map()
val repeatedIds: mutable.Map[(NodeRendererContext, String), Int] = mutable.Map()
val idGenerator = new HeaderIdGenerator.Factory().create()
override def render(node: Section, c: NodeRendererContext, html: HtmlWriter): Unit =
val Section(header, body) = node
val idSuffix = repeatedIds.getOrElseUpdate((c, header.getText), 0)
val headerText = header.getText.toString
val idSuffix = repeatedIds.getOrElseUpdate((c, headerText), 0)
val ifSuffixStr = if(idSuffix == 0) then "" else idSuffix.toString
repeatedIds.update((c, header.getText), repeatedIds((c, header.getText)) + 1)
val id = idGenerator.getId(header.getText.append(ifSuffixStr))
repeatedIds.update((c, headerText), idSuffix + 1)
val id = idGenerator.getId(headerText + ifSuffixStr)
val anchor = AnchorLink(s"#$id")
val headerClass: String = header.getLevel match
case 1 => "h500"
Expand Down

0 comments on commit 7058a8e

Please sign in to comment.