@@ -3,18 +3,21 @@ package dottydoc
33package staticsite
44
55import com .vladsch .flexmark .ast ._
6- import com .vladsch .flexmark .util .sequence .CharSubSequence
7- import model .{ Package , NonEntity , Val , Def , TypeAlias }
6+ import com .vladsch .flexmark .util .sequence .{ BasedSequence , CharSubSequence }
7+ import model .{Def , NonEntity , Package , TypeAlias , Val }
88import dottydoc .util .MemberLookup
99
1010object MarkdownLinkVisitor {
1111 private val EntityLink = """ ([^\.]+)(\.[^\.]+)*""" .r
1212 def apply (node : Node , docs : Map [String , Package ], params : Map [String , AnyRef ]): Unit =
13- ( new NodeVisitor (
13+ new NodeVisitor (
1414 new VisitHandler (classOf [Link ], new Visitor [Link ] with MemberLookup {
1515 override def visit (node : Link ): Unit = {
16+ def isExternal (url : BasedSequence ) =
17+ url.startsWith(" http" ) || url.startsWith(" https" )
18+
1619 val url = node.getUrl
17- if (url.endsWith(" .md" )) node.setUrl {
20+ if (url.endsWith(" .md" ) && ! isExternal(url) ) node.setUrl {
1821 url.subSequence(0 , url.lastIndexOf('.' )).append(" .html" )
1922 }
2023 else if (EntityLink .unapplySeq(url.toString).isDefined) {
@@ -37,6 +40,6 @@ object MarkdownLinkVisitor {
3740 }
3841 }
3942 })
40- ))
43+ )
4144 .visit(node)
4245}
0 commit comments