aboutsummaryrefslogtreecommitdiff
path: root/doc-tool/src/dotty/tools/dottydoc/staticsite/MarkdownLinkVisitor.scala
blob: ac2b6fc6d18d18c239485656f8d2d9f6165c0b25 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
package dotty.tools
package dottydoc
package staticsite

import com.vladsch.flexmark.ast._

object MarkdownLinkVisitor {
  def apply(node: Node): Unit =
    (new NodeVisitor(
      new VisitHandler(classOf[Link], new Visitor[Link] {
        override def visit(node: Link): Unit = {
          val url = node.getUrl
          if (url.endsWith(".md")) node.setUrl {
            url.subSequence(0, url.lastIndexOf('.')).append(".html")
          }
        }
      })
    ))
    .visit(node)
}