emoji

package module
v1.0.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 30, 2024 License: Apache-2.0 Imports: 3 Imported by: 0

README

go-markdown-emoji

Tag License Travis CI codecov.io

Go module to add emoji support to go-markdown.

Table of Contents

Install

go-markdown-emoji is a standard Go module which can be installed with:

go get github.com/4strodev/go-markdown-emoji

Usage

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.

Example
package main

import (
    "github.com/gomarkdown/markdown"
    "github.com/gomarkdown/markdown/html"
    "github.com/gomarkdown/markdown/parser"
    emoji "github.com/4strodev/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))
}

Maintainers

Jim McDonald: @4strodev.

Contribute

Contributions welcome. Please check out the issues.

License

Apache-2.0.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Parser

func Parser(data []byte) (ast.Node, []byte, int)

Parser is a Markdown parser hook to parse emojis. This operates as a pre-parser, because gomarkdown does not allow inline parser extensions.

func Renderer

func Renderer(w io.Writer, node ast.Node, entering bool) (ast.WalkStatus, bool)

Renderer is a renderer hook to show emojis

Types

type Node

type Node struct {
	ast.Leaf
}

Node is a node containing an emoji

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL