BareRTC/pkg/markdown.go
Noah Petherbridge 1ecff195ac JWT Token-based Authentication
* Add support for JWT tokens to authenticate users from your external app.
* JWT backed users can have profile pictures, profile URLs, and operator
  status (admin). Note that no operator features exist yet.
* Add WelcomeMessages to settings.toml for default ChatServer messages to
  write to each public channel directed at a new user logging in.
* Markdown support for chat messages!
2023-02-05 17:42:09 -08:00

20 lines
448 B
Go

package barertc
import (
"strings"
"github.com/microcosm-cc/bluemonday"
"github.com/shurcooL/github_flavored_markdown"
)
// Rendermarkdown from untrusted sources.
func RenderMarkdown(input string) string {
// Render Markdown to HTML.
html := github_flavored_markdown.Markdown([]byte(input))
// Sanitize the HTML from any nasties.
p := bluemonday.UGCPolicy()
safened := p.SanitizeBytes(html)
return strings.TrimSpace(string(safened))
}