mirror of
https://github.com/tulir/gomuks.git
synced 2025-04-20 10:33:41 -05:00
hicli/html: convert plaintext matrix.to links to matrix: URIs
This commit is contained in:
parent
3fdaf8ae4e
commit
c6cdb820ea
1 changed files with 11 additions and 4 deletions
|
@ -179,11 +179,18 @@ func writeURL(w *strings.Builder, addr []byte) {
|
||||||
writeEscapedBytes(w, addr)
|
writeEscapedBytes(w, addr)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
w.WriteString(`<a`)
|
||||||
|
if matrixURI, err := id.ProcessMatrixToURL(parsedURL); err == nil {
|
||||||
|
writeAttribute(w, "href", matrixURI.String())
|
||||||
|
writeAttribute(w, "class", matrixURIClassName(matrixURI)+" hicli-matrix-uri-plaintext")
|
||||||
|
} else {
|
||||||
if parsedURL.Scheme == "" {
|
if parsedURL.Scheme == "" {
|
||||||
parsedURL.Scheme = "https"
|
parsedURL.Scheme = "https"
|
||||||
}
|
}
|
||||||
w.WriteString(`<a target="_blank" rel="noreferrer noopener"`)
|
writeAttribute(w, "target", "_blank")
|
||||||
|
writeAttribute(w, "rel", "noreferrer noopener")
|
||||||
writeAttribute(w, "href", parsedURL.String())
|
writeAttribute(w, "href", parsedURL.String())
|
||||||
|
}
|
||||||
w.WriteByte('>')
|
w.WriteByte('>')
|
||||||
writeEscapedBytes(w, addr)
|
writeEscapedBytes(w, addr)
|
||||||
w.WriteString("</a>")
|
w.WriteString("</a>")
|
||||||
|
|
Loading…
Add table
Reference in a new issue