2020-02-14 21:46:02 +01:00
|
|
|
package markdown
|
|
|
|
|
|
|
|
import (
|
2020-05-07 03:09:31 +02:00
|
|
|
"strings"
|
|
|
|
|
2020-02-14 21:46:02 +01:00
|
|
|
"github.com/charmbracelet/glamour"
|
2020-02-14 22:18:13 +01:00
|
|
|
"github.com/kyokomi/emoji"
|
2020-02-14 21:46:02 +01:00
|
|
|
)
|
|
|
|
|
|
|
|
func normalizeNewlines(s string) string {
|
|
|
|
s = strings.ReplaceAll(s, "\r\n", "\n")
|
|
|
|
s = strings.ReplaceAll(s, "\r", "\n")
|
|
|
|
return s
|
|
|
|
}
|
|
|
|
|
|
|
|
func Render(text string) (string, error) {
|
2020-02-14 22:18:13 +01:00
|
|
|
return glamour.Render(emoji.Sprint(normalizeNewlines(text)), "dark")
|
2020-02-14 21:46:02 +01:00
|
|
|
}
|