Documentation ¶
Overview ¶
Package markdown parses and HTML-renders Markdown documents.
Index ¶
- Variables
- func EvalMarkdownFuncs(ctx context.Context, htmlFragment []byte, opt Options) ([]byte, error)
- func GetTitle(doc *blackfriday.Node) string
- func IsDocumentTopTitleHeadingNode(node *blackfriday.Node) bool
- func NewBfRenderer() blackfriday.Renderer
- func NewParser(renderer blackfriday.Renderer) *blackfriday.Markdown
- func RenderText(node *blackfriday.Node) []byte
- func SetHeadingIDs(node *blackfriday.Node)
- type CodeStyleRenderer
- type Document
- type FuncInfo
- type FuncMap
- type Metadata
- type Options
- type SectionNode
Constants ¶
This section is empty.
Variables ¶
var SGQuery = lexers.Register(chroma.MustNewLexer( &Config{ Name: "Sourcegraph Query", Aliases: []string{"sgquery", "query"}, CaseInsensitive: true, }, sgqueryRules(), ))
Sourcegraph query lexer.
Functions ¶
func EvalMarkdownFuncs ¶ added in v1.3.0
func IsDocumentTopTitleHeadingNode ¶ added in v1.4.0
func IsDocumentTopTitleHeadingNode(node *blackfriday.Node) bool
IsDocumentTopTitleHeadingNode reports whether node is an h1-heading at the top of the document.
func NewBfRenderer ¶
func NewBfRenderer() blackfriday.Renderer
NewBfRenderer creates the default blackfriday renderer to be passed to NewParser()
func NewParser ¶
func NewParser(renderer blackfriday.Renderer) *blackfriday.Markdown
NewParser creates a new Markdown parser (the same one used by Run).
func RenderText ¶ added in v1.0.5
func RenderText(node *blackfriday.Node) []byte
func SetHeadingIDs ¶ added in v1.0.5
func SetHeadingIDs(node *blackfriday.Node)
SetHeadingIDs sets the HeadingID for each heading node.
Types ¶
type CodeStyleRenderer ¶ added in v1.8.0
type CodeStyleRenderer struct {
blackfriday.Renderer
}
func (CodeStyleRenderer) RenderNode ¶ added in v1.8.0
func (c CodeStyleRenderer) RenderNode(w io.Writer, node *blackfriday.Node, entering bool) blackfriday.WalkStatus
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.