markdown

package
v0.0.0-...-d78814b Latest Latest
Warning

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

Go to latest
Published: Oct 22, 2019 License: GPL-2.0 Imports: 12 Imported by: 0

Documentation

Overview

Package markdown implements a GitHub Flavored Markdown renderer.

Index

Constants

This section is empty.

Variables

View Source
var (
	// Plug your own Redis cacher in.
	Cache caches.Cacher
)

Regexps for Markdown use cases.

Functions

func Pygmentize

func Pygmentize(language, source string) (string, error)

Pygmentize searches for fenced code blocks in rendered Markdown HTML and runs Pygments to syntax highlight it.

On error the original given source is returned back.

The rendered result is cached in Redis if available, because the CLI call takes ~0.6s which is slow if you're rendering a lot of code blocks.

func RenderMarkdown

func RenderMarkdown(input string) string

RenderMarkdown renders markdown to HTML, safely. It uses blackfriday to render Markdown to HTML and then Bluemonday to sanitize the resulting HTML.

func RenderTrustedMarkdown

func RenderTrustedMarkdown(input string) string

RenderTrustedMarkdown renders markdown to HTML, but without applying bluemonday filtering afterward. This is for blog posts and website Markdown pages, not for user-submitted comments or things.

func TitleFromMarkdown

func TitleFromMarkdown(body string) (string, error)

TitleFromMarkdown tries to find a title from the source of a Markdown file.

On error, returns "Untitled" along with the error. So if you're lazy and want a suitable default, you can safely ignore the error.

Types

This section is empty.

Jump to

Keyboard shortcuts

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