🚀 Replace "http" -> "https" for all Markdown links

* "http://" -> "https://"
* Show link in brackets: text (link)
This commit is contained in:
Acclorite 2025-01-05 11:02:02 +02:00
parent 18f42afba1
commit ee81d6e7e3
2 changed files with 8 additions and 2 deletions

View file

@ -43,10 +43,15 @@ class DocumentParser @Inject constructor(
select("strong").append("**").prepend("**")
select("em").append("_").prepend("_")
select("a").forEach { element ->
val link = element.attr("href")
var link = element.attr("href")
if (!link.startsWith("http") || element.wholeText().isBlank()) return@forEach
element.prepend("[")/* text in between */.append("](${element.attr("href")})")
if (link.startsWith("http://")) {
link = link.replace("http://", "https://")
}
element.prepend("[")
element.append("]($link)")
}
}.wholeText().lines().forEachIndexed { index, line ->
yield()

View file

@ -68,6 +68,7 @@ class MarkdownParser @Inject constructor(
)
) {
parseChildren(node)
append(" (${node.destination})")
}
}