@@ -3,18 +3,21 @@ package dottydoc
3
3
package staticsite
4
4
5
5
import 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 }
8
8
import dottydoc .util .MemberLookup
9
9
10
10
object MarkdownLinkVisitor {
11
11
private val EntityLink = """ ([^\.]+)(\.[^\.]+)*""" .r
12
12
def apply (node : Node , docs : Map [String , Package ], params : Map [String , AnyRef ]): Unit =
13
- ( new NodeVisitor (
13
+ new NodeVisitor (
14
14
new VisitHandler (classOf [Link ], new Visitor [Link ] with MemberLookup {
15
15
override def visit (node : Link ): Unit = {
16
+ def isExternal (url : BasedSequence ) =
17
+ url.startsWith(" http" ) || url.startsWith(" https" )
18
+
16
19
val url = node.getUrl
17
- if (url.endsWith(" .md" )) node.setUrl {
20
+ if (url.endsWith(" .md" ) && ! isExternal(url) ) node.setUrl {
18
21
url.subSequence(0 , url.lastIndexOf('.' )).append(" .html" )
19
22
}
20
23
else if (EntityLink .unapplySeq(url.toString).isDefined) {
@@ -37,6 +40,6 @@ object MarkdownLinkVisitor {
37
40
}
38
41
}
39
42
})
40
- ))
43
+ )
41
44
.visit(node)
42
45
}
0 commit comments