@@ -253,31 +253,15 @@ class ScalaHtmlRenderer(ctx: DokkaContext) extends HtmlRenderer(ctx) {
253253 page.getContent match
254254 case prc : PartiallyRenderedContent =>
255255 def processLocalLink (str : String ): String =
256+ Try (URL (str)).map(_ => str).getOrElse{
256257 // TODO (https://github.com/lampepfl/scala3doc/issues/238) error handling
257- prc.context.driForLink(prc.template.templateFile, str).toOption
258- .flatMap(dri => Option (getLocationProvider.resolve(dri, sourceSets, page)))
259- .getOrElse(str)
260-
261- val childrenContent = page.getChildren.asScala.collect {
262- case p : StaticPageNode => p.getContent.asInstanceOf [PartiallyRenderedContent ]// .resolved.code
263- }
264-
265- val html = prc.procsesHtml(url => Try (URL (url)).fold(_ => processLocalLink(url), _ => url))
266- val htmlAst = Jsoup .parse(html)
267-
268- // childrenContent.foreach { c =>
269- // val code = Jsoup.parse(c.resolved.code)
270- // val brief = code.select("p").first()
271- // try {
272- // val li = htmlAst.select(s"li:contains(${c.template.title})")
273- // val div = li.select(s"div.excerpt")
274- // div.html(brief.toString)
275- // } catch {
276- // _ =>
277- // }
278- // }
279-
280- withHtml(context, htmlAst.toString)
258+ prc.context.driForLink(prc.template.templateFile, str).toOption
259+ .flatMap(dri => Option (getLocationProvider.resolve(dri, sourceSets, page)))
260+ .getOrElse(str)
261+ }
262+
263+ val html = prc.procsesHtml(processLocalLink, resolveLink(page))
264+ withHtml(context, html)
281265 case content =>
282266 build(content, context, page, /* sourceSetRestriction=*/ null )
283267
@@ -335,20 +319,20 @@ class ScalaHtmlRenderer(ctx: DokkaContext) extends HtmlRenderer(ctx) {
335319 private def resolveRoot (page : PageNode , path : String ) =
336320 getLocationProvider.pathToRoot(page) + path
337321
322+ private def resolveLink (page : PageNode )(url : String ): String =
323+ if URI (url).isAbsolute then url else resolveRoot(page, url)
324+
338325 private def linkResources (page : PageNode , resources : Iterable [String ]): Iterable [AppliedTag ] =
339326 def fileExtension (url : String ): String =
340327 val param = url.indexOf('?' )
341328 val end = if param < 0 then url.length else param
342329 val point = url.lastIndexOf('.' , end)
343330 url.substring(point+ 1 , end)
344331
345- def resolveLink (url : String ): String =
346- if URI (url).isAbsolute then url else resolveRoot(page, url)
347-
348332 for res <- resources yield
349333 fileExtension(res) match
350- case " css" => link(rel := " stylesheet" , href := resolveLink(res))
351- case " js" => script(`type` := " text/javascript" , src := resolveLink(res), defer := " true" )
334+ case " css" => link(rel := " stylesheet" , href := resolveLink(page)( res))
335+ case " js" => script(`type` := " text/javascript" , src := resolveLink(page)( res), defer := " true" )
352336 case _ => raw(res)
353337
354338 private def buildWithKotlinx (node : ContentNode , pageContext : ContentPage , sourceSetRestriction : JSet [DisplaySourceSet ]): String =
0 commit comments