markdown

package
v0.5.1 Latest Latest
Warning

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

Go to latest
Published: Oct 22, 2020 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrFrontMatterNotClosed error = errors.New("Missing closing frontmatter `---` found")

ErrFrontMatterNotClosed is raised to signal that the rules for defining a frontmatter element in a markdown document have been violated

Functions

func InsertFrontMatter

func InsertFrontMatter(fm []byte, content []byte) ([]byte, error)

InsertFrontMatter prepends the content bytes with front matter enclosed in the standard marks ---

func StripFrontMatter

func StripFrontMatter(b []byte) ([]byte, []byte, error)

StripFrontMatter splits a provided document into front-matter and content.

func UpdateLinkRefs added in v0.2.0

func UpdateLinkRefs(documentBlob []byte, callback OnLink) ([]byte, error)

UpdateLinkRefs changes document links destinations, consulting with callback on the destination to use on each link or image in document. If a callback returns "" for a destination, this is interpreted as request to remove the link destination and leave only the link text or in case it's an image - to remvoe it completely. TODO: failfast vs fault tolerance support?

Types

type OnLink func(markdownType Type, destination, text, title []byte) ([]byte, []byte, []byte, error)

OnLink is a callback function invoked on each link by mardown#UpdateLinkRefs It is supplied a link and is expected to return destination, text, title or error. A nil destination will yield removing of this link/image markup, leaving only the text component if it's a link Nil text or title returned yield no change. Any other value replaces the original. If a returned title is empty string an originally existing title element will be completely removed

type Type added in v0.4.0

type Type int

Type is an enumeration for markdown types

const (

	// Link is a link markdown type
	Link Type = iota
	// Image is an image markdown type
	Image
)

func NewType added in v0.4.0

func NewType(markdownTypeString string) (Type, error)

NewType creates a markdown Type enum from string

func (Type) String added in v0.4.0

func (m Type) String() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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