translate chat to html

This commit is contained in:
Ted Unangst 2020-05-14 23:06:23 -04:00
parent 3b792bbcea
commit b7ec6b50d8
3 changed files with 7 additions and 2 deletions

View File

@ -1287,7 +1287,7 @@ func sendchonk(user *WhatAbout, ch *Chonk) {
jo["published"] = dt jo["published"] = dt
jo["attributedTo"] = user.URL jo["attributedTo"] = user.URL
jo["to"] = aud jo["to"] = aud
jo["content"] = ch.Noise jo["content"] = ch.HTML
j := junk.New() j := junk.New()
j["@context"] = itiswhatitis j["@context"] = itiswhatitis

6
fun.go
View File

@ -182,7 +182,11 @@ func filterchonk(ch *Chonk) {
var htf htfilter.Filter var htf htfilter.Filter
htf.SpanClasses = allowedclasses htf.SpanClasses = allowedclasses
htf.BaseURL, _ = url.Parse(ch.XID) htf.BaseURL, _ = url.Parse(ch.XID)
ch.HTML, _ = htf.String(ch.Noise) noise := ch.Noise
if ch.Format == "markdown" {
noise = markitzero(noise)
}
ch.HTML, _ = htf.String(noise)
n := string(ch.HTML) n := string(ch.HTML)
if strings.HasPrefix(n, "<p>") { if strings.HasPrefix(n, "<p>") {
ch.HTML = template.HTML(n[3:]) ch.HTML = template.HTML(n[3:])

1
web.go
View File

@ -1814,6 +1814,7 @@ func submitchonk(w http.ResponseWriter, r *http.Request) {
Noise: noise, Noise: noise,
Format: format, Format: format,
} }
filterchonk(&ch)
savechonk(&ch) savechonk(&ch)
go sendchonk(user, &ch) go sendchonk(user, &ch)