Skip to content

skunkie/goldmark-tg

Repository files navigation

goldmark-tg

goldmark-tg is a collection of extensions for the goldmark that adds Telegram Markdown and MarkdownV2 functionalities.

Examples

Markdown:

package main

import (
	"github.com/yuin/goldmark"

	tg "github.com/skunkie/goldmark-tg"
)

func main() {
	md := goldmark.New(tg.Markdown()...)
	...
}

MarkdownV2:

package main

import (
	"github.com/yuin/goldmark"

	tg "github.com/skunkie/goldmark-tg"
)

func main() {
	md := goldmark.New(tg.MarkdownV2()...)
	...
}

MarkdownV2 with Go Template extension:

package main

import (
	"fmt"
	"strings"

	"github.com/yuin/goldmark"

	tg "github.com/skunkie/goldmark-tg"
	"github.com/skunkie/goldmark-tg/extension"
)

var template = []byte(`*{{ if eq .Status "firing" }}2{{ else }}0{{ end }}*`)

func main() {
	var buf strings.Builder
	md := goldmark.New(append(tg.MarkdownV2(), goldmark.WithExtensions(extension.Template))...)
	if err := md.Convert(template, &buf); err != nil {
		panic(err)
	}
	fmt.Printf("%q\n", buf.String())
}

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages