tg

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Feb 29, 2024 License: MIT Imports: 6 Imported by: 0

README

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())
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Markdown

func Markdown() []goldmark.Option

A collection of goldmark options to parse and render Telegram Markdown.

func MarkdownV2

func MarkdownV2() []goldmark.Option

A collection of goldmark options to parse and render Telegram MarkdownV2.

Types

This section is empty.

Directories

Path Synopsis
examples
ast
renderer
html
Package html implements renderer that outputs HTMLs.
Package html implements renderer that outputs HTMLs.

Jump to

Keyboard shortcuts

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