Documentation ¶
Overview ¶
package emoji is a extension for the goldmark(http://github.com/yuin/goldmark).
Index ¶
- Constants
- Variables
- func New(opts ...Option) goldmark.Extender
- func NewHTMLRenderer(opts ...RendererOption) renderer.NodeRenderer
- func NewParser(opts ...ParserOption) parser.InlineParser
- type Option
- type ParserConfig
- type ParserOption
- type RendererConfig
- type RendererFunc
- type RendererOption
- type RenderingMethod
Constants ¶
const DefaultTwemojiTemplate = `<img class="emoji" draggable="false" alt="%[1]s" src="https://twemoji.maxcdn.com/v/latest/72x72/%[2]s.png"%[3]s>`
DefaultTwemojiTemplate is a default value for RendererConfig.TwemojiTemplate.
Variables ¶
var Emoji = &emoji{ options: []Option{}, }
Emoji is a goldmark.Extender implementation.
Functions ¶
func NewHTMLRenderer ¶
func NewHTMLRenderer(opts ...RendererOption) renderer.NodeRenderer
NewHTMLRenderer returns a new HTMLRenderer.
func NewParser ¶
func NewParser(opts ...ParserOption) parser.InlineParser
NewParser returns a new parser.InlineParser that can parse emoji expressions.
Types ¶
type Option ¶
type Option interface {
// contains filtered or unexported methods
}
Option interface sets options for this extension.
func WithEmojis ¶
func WithEmojis(value definition.Emojis) Option
WithMaping is a functional option that defines links names to unicode emojis.
func WithRendererFunc ¶
func WithRendererFunc(f RendererFunc) Option
WithRendererFunc is a functional option that changes a renderer func.
func WithRenderingMethod ¶
func WithRenderingMethod(a RenderingMethod) Option
WithRenderingMethod is a functional option that indicates how emojis are rendered.
func WithTwemojiTemplate ¶
WithTwemojiTemplate is a functional option that changes a twemoji img tag.
type ParserConfig ¶
type ParserConfig struct {
Emojis definition.Emojis
}
ParserConfig struct is a data structure that holds configuration of the Emoji extension.
func (*ParserConfig) SetOption ¶
func (c *ParserConfig) SetOption(name parser.OptionName, value interface{})
SetOption implements parser.SetOptioner
type ParserOption ¶
type ParserOption interface { Option parser.Option SetEmojiOption(*ParserConfig) }
A ParserOption interface sets options for the emoji parser.
type RendererConfig ¶
type RendererConfig struct { html.Config // Method indicates how emojis are rendered. Method RenderingMethod // TwemojiTemplate is a printf template for twemoji. This value is valid only when Method is set to Twemoji. // `printf` arguments are: // // 1: name (e.g. "face with tears of joy") // 2: file name without an extension (e.g. 1f646-2642) // 3: '/' if XHTML, otherwise ” // TwemojiTemplate string // RendererFunc is a RendererFunc that renders emojis. This value is valid only when Method is set to Func. RendererFunc RendererFunc }
RendererConfig struct holds options for the emoji renderer.
func (*RendererConfig) SetOption ¶
func (c *RendererConfig) SetOption(name renderer.OptionName, value interface{})
SetOption implements renderer.SetOptioner.
type RendererFunc ¶
RendererFunc will be used for rendering emojis.
type RendererOption ¶
type RendererOption interface { Option renderer.Option SetEmojiOption(*RendererConfig) }
A RendererOption interface sets options for the emoji renderer.
type RenderingMethod ¶
type RenderingMethod int
RenderingMethod indicates how emojis are rendered.
const ( // Entity renders an emoji as an html entity. Entity RenderingMethod = iota // Unicode renders an emoji as unicode character. Unicode // Twemoji renders an emoji as an img tag with [twemoji](https://github.com/twitter/twemoji). Twemoji // Func renders an emoji using RendererFunc. Func )
Directories ¶
Path | Synopsis |
---|---|
Package ast defines AST nodes that represetns emoji extension's elements.
|
Package ast defines AST nodes that represetns emoji extension's elements. |