Documentation ¶
Overview ¶
This package provides a utility to parse markdown files in lexical order as a single document or individual pages, with no additional requirements.
It includes default templates that are embedded, but can be directed to a separate file granting better control for more complex use-cases.
Template parameters are simple, and include Title, Content, and Version; both the Version and Title can be changed. If in web mode, an additional property called Name will be set to the basename of the file.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Asset ¶
Asset loads and returns the asset for the given name. It returns an error if the asset could not be found or could not be loaded.
func AssetDir ¶
AssetDir returns the file names below a certain directory embedded in the file by go-bindata. For example if you run go-bindata on data/... and data contains the following hierarchy:
data/ foo.txt img/ a.png b.png
then AssetDir("data") would return []string{"foo.txt", "img"} AssetDir("data/img") would return []string{"a.png", "b.png"} AssetDir("foo.txt") and AssetDir("notexist") would return an error AssetDir("") will return []string{"data"}.
func AssetInfo ¶
AssetInfo loads and returns the asset info for the given name. It returns an error if the asset could not be found or could not be loaded.
func MustAsset ¶
MustAsset is like Asset but panics when Asset would return an error. It simplifies safe initialization of global variables.
func RestoreAsset ¶
RestoreAsset restores an asset under the given directory
func RestoreAssets ¶
RestoreAssets restores an asset under the given directory recursively
Types ¶
type Markdown ¶
type Markdown struct { Title string `json:"title,omitempty"` Input string `json:"input,omitempty"` Output string `json:"output,omitempty"` Web bool `json:"web,omitempty"` Template string `json:"template,omitempty"` Version string `json:"version,omitempty"` L logger `json:"-"` // contains filtered or unexported fields }
This is the compiler that collects the list markdown files, a title, the input and output paths, and whether to produce multiple files (web mode) or to produce a single file (default, book mode).
All public properties are not thread safe, so concurrent execution may yield errors if those properties are being modified or accessed in parallel.
func (*Markdown) Run ¶
The primary function, which accepts the operation used to convert markdown into html. Unfortunately there are currently no markdown parsers that operate on a stream, but in the future I would like to switch to an io.Reader interface.
The operation begins by capturing the input path so that we can translate the output path when creating files from the input path, including matching directories.
If no title has been supplied it will default to the parent directories name, but this might be better placed in package main.
The default output for web is `public/`, otherwise when in book mode the default is the title.
We walk the input path, which assembles the list of markdown files and then we gather any errors returned.
Finally we process the files according to the desired output mode.