Documentation
¶
Overview ¶
Package markdown provides utilities for parsing and creating Markdown files with optional frontmatter.
Index ¶
Constants ¶
const DefaultDelimiter = "---"
The DefaultDelimiter is used to determine the bounds of frontmatter if no other delimiter is set.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Decoder ¶
type Decoder struct {
// The delimiter used to determine the bounds of frontmatter.
Delimiter []byte
}
Decoder parses markdown content into frontmatter and body components.
func NewDecoder ¶
func NewDecoder() *Decoder
NewDecoder returns a Decoder configured with the default options.
func (*Decoder) Decode ¶
Decode reads the contents of r and extracts them into their respective frontmatter (if any) and body contents. If the delimiter is found at the start of the contents of r, it is assumed that the file contains YAML frontmatter and it MUST have a corresponding closing delimiter or the method will return an error.
If fm is provided but no frontmatter is present in r, nothing will be written to fm. Likewise, if fm is not provided but frontmatter exists, the frontmatter will be ignored.
Similarly, if body is not provided, it will be skipped.