Documentation
¶
Overview ¶
Package markdown parses and HTML-renders Markdown documents.
Index ¶
- func EvalMarkdownFuncs(ctx context.Context, htmlFragment []byte, opt Options) ([]byte, error)
- func GetAttributeID(node ast.Node) string
- func GetTitle(doc ast.Node, source []byte) string
- func IsDocumentTopTitleHeadingNode(node ast.Node) bool
- func New(opts Options) goldmark.Markdown
- type Document
- type FuncInfo
- type FuncMap
- type Metadata
- type Options
- type SectionNode
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func EvalMarkdownFuncs ¶ added in v1.3.0
func GetAttributeID ¶ added in v1.9.0
func IsDocumentTopTitleHeadingNode ¶ added in v1.4.0
IsDocumentTopTitleHeadingNode reports whether node is an h1-heading at the top of the document.
Types ¶
type Document ¶
type Document struct {
// Meta is the document's metadata in the Markdown "front matter", if any.
Meta Metadata
// Title is taken from the metadata (if it exists) or else from the text content of the first
// heading.
Title string
// HTML is the rendered Markdown content.
HTML []byte
// Tree is the tree of sections (used to show a table of contents).
Tree []*SectionNode
}
Document is a parsed and HTML-rendered Markdown document.
type FuncInfo ¶
type FuncInfo struct {
Version string // the version of the content containing the page to render
}
FuncInfo contains information passed to Markdown functions about the current execution context.
type FuncMap ¶
FuncMap contains named functions that can be invoked within Markdown documents (see (Options).Funcs).
type Metadata ¶
type Metadata struct {
IgnoreDisconnectedPageCheck bool `yaml:"ignoreDisconnectedPageCheck"`
Title string `yaml:"title"`
Description string `yaml:"description"`
Category string `yaml:"category"`
ImageURL string `yaml:"imageURL"`
Type string `yaml:"type"`
Tags []string `yaml:"tags"`
}
Metadata is document metadata in the "front matter" of a Markdown document.
type Options ¶
type Options struct {
// Base is the base URL (typically including only the path, such as "/" or "/help/") to use when
// resolving relative links.
Base *url.URL
// ContentFilePathToLinkPath converts references to file paths of other content files to the URL
// path to use in links. For example, ContentFilePathToLinkPath("a/index.md") == "a".
ContentFilePathToLinkPath func(string) string
// Funcs are custom functions that can be invoked within Markdown documents with
// <markdownfuncjfunction-name arg="val" />.
Funcs FuncMap
// FuncInfo contains information passed to Markdown functions about the current execution
// context.
FuncInfo FuncInfo
}
Options customize how Run parses and HTML-renders the Markdown document.
type SectionNode ¶
type SectionNode struct {
Title string // section title
URL string // section URL (usually an anchor link)
Level int // heading level (1–6)
Children []*SectionNode // subsections
}
SectionNode is a section and its children.
Click to show internal directories.
Click to hide internal directories.