🚀 Replace "http" -> "https" for all Markdown links
* "http://" -> "https://" * Show link in brackets: text (link)
This commit is contained in:
parent
18f42afba1
commit
ee81d6e7e3
2 changed files with 8 additions and 2 deletions
|
|
@ -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()
|
||||
|
|
|
|||
|
|
@ -68,6 +68,7 @@ class MarkdownParser @Inject constructor(
|
|||
)
|
||||
) {
|
||||
parseChildren(node)
|
||||
append(" (${node.destination})")
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue