mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2024-11-18 07:12:20 +00:00
086a46994a
* Rewrite markdown rendering to blackfriday v2.0 * Fix style * Fix go mod with golang 1.13 * Fix blackfriday v2 import * Inital orgmode renderer migration to go-org * Vendor go-org dependency * Ignore errors :/ * Update go-org to latest version * Update test * Fix go-org test * Remove unneeded code * Fix comments * Fix markdown test * Fix blackfriday regression rendering HTML block
34 lines
569 B
Go
34 lines
569 B
Go
package blackfriday
|
|
|
|
import (
|
|
"html"
|
|
"io"
|
|
)
|
|
|
|
var htmlEscaper = [256][]byte{
|
|
'&': []byte("&"),
|
|
'<': []byte("<"),
|
|
'>': []byte(">"),
|
|
'"': []byte("""),
|
|
}
|
|
|
|
func escapeHTML(w io.Writer, s []byte) {
|
|
var start, end int
|
|
for end < len(s) {
|
|
escSeq := htmlEscaper[s[end]]
|
|
if escSeq != nil {
|
|
w.Write(s[start:end])
|
|
w.Write(escSeq)
|
|
start = end + 1
|
|
}
|
|
end++
|
|
}
|
|
if start < len(s) && end <= len(s) {
|
|
w.Write(s[start:end])
|
|
}
|
|
}
|
|
|
|
func escLink(w io.Writer, text []byte) {
|
|
unesc := html.UnescapeString(string(text))
|
|
escapeHTML(w, []byte(unesc))
|
|
}
|