yuin/goldmark-emoji

An emoji extension for the goldmark markdown parser

28

stars

23

commits

Go

primary language

Aug 27, 2026

updated

README

goldmark-emoji

GoDev

goldmark-emoji is an extension for goldmark v2 that parses :joy: style emojis.

Compatiblity

github.com/yuin/goldmark-emoji/v2 is compatible with goldmark(v2).

use github.com/yuin/goldmark-meta for goldmark(v1).

Installation

go get github.com/yuin/goldmark-emoji/v2

Usage

import (
    "bytes"
    "fmt"

    "github.com/yuin/goldmark-emoji/v2"
    "github.com/yuin/goldmark/v2/parser"
    "github.com/yuin/goldmark/v2/renderer/html"
)

func main() {
    p := parser.New(parser.WithExtensions(emoji.Parser))
    r := html.New(html.WithExtensions(emoji.HTMLRenderer))
    source := []byte(`Joy :joy:`)
    doc := p.Parse(source)
    var buf bytes.Buffer
    if err := r.Render(&buf, source, doc); err != nil {
        panic(err)
    }
    fmt.Print(buf.String())
}

With options:

p := parser.New(parser.WithExtensions(
    emoji.NewParser(emoji.WithEmojis(myEmojis)),
))
r := html.New(html.WithExtensions(
    emoji.NewHTMLRenderer(emoji.WithRenderingMethod(emoji.Twemoji)),
))

See emoji_test.go for detailed usage.

Options

goldmark/v2 separates parser and renderer extensions, so options are split accordingly.

Parser options (passed to NewParser):

OptionDescription
WithEmojisEmoji definitions. Defaults to the GitHub emoji set

Renderer options (passed to NewHTMLRenderer):

OptionDescription
WithRenderingMethodEntity (default): HTML entities, Unicode: raw Unicode characters, Twemoji: <img> tag using twemoji, Func: custom Go function
WithTwemojiTemplateprintf template for the twemoji <img> tag
WithRendererFuncCustom rendering function (used when method is Func)

License

MIT

Author

Yusuke Inuzuka

Contributors

yuin

15 commits

jlelse

4 commits

radeeyate

2 commits

damz

1 commits

yuin/goldmark-emoji

An emoji extension for the goldmark markdown parser

28

stars

23

commits

Go

primary language

Aug 27, 2026

updated

README

goldmark-emoji

GoDev

goldmark-emoji is an extension for goldmark v2 that parses :joy: style emojis.

Compatiblity

github.com/yuin/goldmark-emoji/v2 is compatible with goldmark(v2).

use github.com/yuin/goldmark-meta for goldmark(v1).

Installation

go get github.com/yuin/goldmark-emoji/v2

Usage

import (
    "bytes"
    "fmt"

    "github.com/yuin/goldmark-emoji/v2"
    "github.com/yuin/goldmark/v2/parser"
    "github.com/yuin/goldmark/v2/renderer/html"
)

func main() {
    p := parser.New(parser.WithExtensions(emoji.Parser))
    r := html.New(html.WithExtensions(emoji.HTMLRenderer))
    source := []byte(`Joy :joy:`)
    doc := p.Parse(source)
    var buf bytes.Buffer
    if err := r.Render(&buf, source, doc); err != nil {
        panic(err)
    }
    fmt.Print(buf.String())
}

With options:

p := parser.New(parser.WithExtensions(
    emoji.NewParser(emoji.WithEmojis(myEmojis)),
))
r := html.New(html.WithExtensions(
    emoji.NewHTMLRenderer(emoji.WithRenderingMethod(emoji.Twemoji)),
))

See emoji_test.go for detailed usage.

Options

goldmark/v2 separates parser and renderer extensions, so options are split accordingly.

Parser options (passed to NewParser):

OptionDescription
WithEmojisEmoji definitions. Defaults to the GitHub emoji set

Renderer options (passed to NewHTMLRenderer):

OptionDescription
WithRenderingMethodEntity (default): HTML entities, Unicode: raw Unicode characters, Twemoji: <img> tag using twemoji, Func: custom Go function
WithTwemojiTemplateprintf template for the twemoji <img> tag
WithRendererFuncCustom rendering function (used when method is Func)

License

MIT

Author

Yusuke Inuzuka

Contributors

yuin

15 commits

jlelse

4 commits

radeeyate

2 commits

damz

1 commits

Languages

Go

100.0%