in src/commonMain/kotlin/org/intellij/markdown/flavours/gfm/GFMFlavourDescriptor.kt [70:97]
override fun processNode(visitor: HtmlGenerator.HtmlGeneratingVisitor, text: String, node: ASTNode) {
val linkText = node.getTextInNode(text)
// #28: do not render GFM autolinks under link titles
// (though it's "OK" according to CommonMark spec)
if (node.getParentOfType(MarkdownElementTypes.LINK_LABEL,
MarkdownElementTypes.LINK_TEXT) != null) {
visitor.consumeHtml(linkText)
return
}
// according to GFM_AUTOLINK rule in lexer, link either starts with scheme or with 'www.'
val absoluteLink = if (hasSchema(linkText)) linkText else {
if (makeHttpsAutoLinks) {
"https://$linkText"
} else {
"http://$linkText"
}
}
val link = EntityConverter.replaceEntities(linkText, true, false)
val normalizedDestination = LinkMap.normalizeDestination(absoluteLink, false).let {
if (useSafeLinks) makeXssSafeDestination(it) else it
}
visitor.consumeTagOpen(node, "a", "href=\"$normalizedDestination\"")
visitor.consumeHtml(link)
visitor.consumeTagClose("a")
}