@@ -253,31 +253,15 @@ class ScalaHtmlRenderer(ctx: DokkaContext) extends HtmlRenderer(ctx) {
253
253
page.getContent match
254
254
case prc : PartiallyRenderedContent =>
255
255
def processLocalLink (str : String ): String =
256
+ Try (URL (str)).map(_ => str).getOrElse{
256
257
// 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)
281
265
case content =>
282
266
build(content, context, page, /* sourceSetRestriction=*/ null )
283
267
@@ -335,20 +319,20 @@ class ScalaHtmlRenderer(ctx: DokkaContext) extends HtmlRenderer(ctx) {
335
319
private def resolveRoot (page : PageNode , path : String ) =
336
320
getLocationProvider.pathToRoot(page) + path
337
321
322
+ private def resolveLink (page : PageNode )(url : String ): String =
323
+ if URI (url).isAbsolute then url else resolveRoot(page, url)
324
+
338
325
private def linkResources (page : PageNode , resources : Iterable [String ]): Iterable [AppliedTag ] =
339
326
def fileExtension (url : String ): String =
340
327
val param = url.indexOf('?' )
341
328
val end = if param < 0 then url.length else param
342
329
val point = url.lastIndexOf('.' , end)
343
330
url.substring(point+ 1 , end)
344
331
345
- def resolveLink (url : String ): String =
346
- if URI (url).isAbsolute then url else resolveRoot(page, url)
347
-
348
332
for res <- resources yield
349
333
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" )
352
336
case _ => raw(res)
353
337
354
338
private def buildWithKotlinx (node : ContentNode , pageContext : ContentPage , sourceSetRestriction : JSet [DisplaySourceSet ]): String =
0 commit comments