Go module to add emoji support to go-markdown.
go-markdown-emoji
is a standard Go module which can be installed with:
go get github.com/mcdee/go-markdown-emoji
go-markdown-emoji
provides parser and renderer hooks to the markdown engine. The parser hook is Parser
and the renderer Renderer
.
Emojis are signified in Markdown as names between colons, for example :smile:
. A full list of the emojis supported can be seen in emoji.go.
package main
import (
"github.com/gomarkdown/markdown"
"github.com/gomarkdown/markdown/html"
"github.com/gomarkdown/markdown/parser"
emoji "github.com/mcdee/go-markdown-emoji"
)
func main() {
p := parser.New()
p.Opts = parser.Options{ParserHook: emoji.Parser}
r := html.NewRenderer(html.RendererOptions{
Flags: html.CommonFlags,
RenderNodeHook: emoji.Renderer,
})
html := markdown.ToHTML([]byte(":smile:"), p, r)
fmt.Printf("%s\n", string(html))
}
Jim McDonald: @mcdee.
Contributions welcome. Please check out the issues.