Documentation ¶
Overview ¶
The markdown package implements filesys.Handler for the Markdown format.
Markdown is parsed and rendered with the goldmark package. As such, it contains implementations of various goldmark interfaces, which may be used for custom parsers and renderers.
Index ¶
- Variables
- func NewHandler(options ...goldmark.Option) filesys.HandlerFunc
- func NewSectionRenderer() renderer.NodeRenderer
- func NewSectionTransformer() parser.ASTTransformer
- type Node
- func (n *Node) Descend(names ...string) drill.Node
- func (n *Node) Fragment() string
- func (n *Node) FragmentReader() (r io.ReadCloser, err error)
- func (n *Node) Len() int
- func (n *Node) Node() ast.Node
- func (n *Node) OrderedChild(i int) drill.Node
- func (n *Node) OrderedChildren() []drill.Node
- func (n *Node) Query(queries ...interface{}) drill.Node
- func (n *Node) Root() *Node
- func (n *Node) UnorderedChild(name string) drill.Node
- func (n *Node) UnorderedChildren() map[string]drill.Node
- func (n *Node) WalkChildSections(walk func(child *Section) bool)
- func (n *Node) WithRenderer(r renderer.Renderer) *Node
- type Section
Constants ¶
This section is empty.
Variables ¶
var KindSection = ast.NewNodeKind("Section")
KindSection is the ast.NodeKind corresponding to Section.
Functions ¶
func NewHandler ¶
func NewHandler(options ...goldmark.Option) filesys.HandlerFunc
NewHandler returns a filesys.HandlerFunc that handles the Markdown format.
The content of a Markdown file is divided into a tree of sections, delimited by headings. A section can be drilled into, with the name corresponding to the content of the section's heading.
A section contains all the content that follows a heading, up to the next heading of the same level. Content that follows the section's heading, and precedes the end of the section or the first sub-heading, is contained within an "orphaned" section. The name of this section is an empty string, and will be the first child section.
func NewSectionRenderer ¶
func NewSectionRenderer() renderer.NodeRenderer
NewSectionRenderer returns a renderer.NodeRenderer that renders a Section node.
func NewSectionTransformer ¶
func NewSectionTransformer() parser.ASTTransformer
NewSectionTransformer returns a parser.ASTTransformer that inserts Sections into the tree.
Types ¶
type Node ¶
type Node struct {
// contains filtered or unexported fields
}
Node implements drill.Node.
func NewNode ¶
NewNode returns a Node that wraps the given ast.Node, source, and renderer. root is assumed to be an ast.Document or a Section.
The node created by NewNode is treated as the root. Nodes that derive from the root will point back to the root.
func (*Node) Descend ¶
Descend recursively descends into the unordered child sections matching each given name. Returns nil if a child could not be found at any point.
func (*Node) Fragment ¶
Fragment renders the wrapped node and returns the result as a string. Returns an empty string if an error occurs, or the node has no renderer.
func (*Node) FragmentReader ¶
func (n *Node) FragmentReader() (r io.ReadCloser, err error)
FragmentReader returns a ReadCloser that renders the wrapped node.
func (*Node) OrderedChild ¶
OrderedChild returns a Node that wraps the ordered child Section at index i. Returns nil if the index is out of bounds.
func (*Node) OrderedChildren ¶
OrderedChildren returns a list of Nodes that wrap each ordered child Section.
func (*Node) Query ¶
Query recursively descends into the child nodes that match the given queries. A query is either a string or an int. If an int, then the next node is acquired using the OrderedChild method of the current node. If a string, then the next node is acquired using the UnorderedChild method of the current node. Returns nil if a child could not be found at any point.
func (*Node) Root ¶ added in v0.3.0
Root returns the original root Node from which the current node derives, or the node itself, if it is the root.
func (*Node) UnorderedChild ¶
UnorderedChild returns a Node that wraps the unordered child Section whose Name is equal to name.
func (*Node) UnorderedChildren ¶
UnorderedChildren returns a map of names to Nodes that wrap each unordered child Section.
func (*Node) WalkChildSections ¶
WalkChildSections traverses each child node that is a Section. Stops if walk returns true.