commonmark package - github.com/rhinoman/go-commonmark - Go Packages (original) (raw)
Package commonmark provides a Go wrapper for the CommonMark C Library
- Constants
- func CMarkVersion() int
- func Md2Html(mdtext string, options int) string
- type CMarkEvent
- type CMarkIter
- type CMarkNode
- func (node *CMarkNode) AppendChild(child *CMarkNode) bool
- func (node *CMarkNode) ConsolidateTextNodes()
- func (node *CMarkNode) FirstChild() *CMarkNode
- func (node *CMarkNode) Free()
- func (node *CMarkNode) GetEndColumn() int
- func (node *CMarkNode) GetEndLine() int
- func (node *CMarkNode) GetFenceInfo() string
- func (node *CMarkNode) GetHeaderLevel() int
- func (node *CMarkNode) GetListDelim() DelimType
- func (node *CMarkNode) GetListStart() int
- func (node *CMarkNode) GetListTight() bool
- func (node *CMarkNode) GetListType() ListType
- func (node *CMarkNode) GetLiteral() string
- func (node *CMarkNode) GetNodeType() NodeType
- func (node *CMarkNode) GetNodeTypeString() string
- func (node *CMarkNode) GetNodeUserData() string
- func (node *CMarkNode) GetOnEnter() string
- func (node *CMarkNode) GetOnExit() string
- func (node *CMarkNode) GetStartColumn() int
- func (node *CMarkNode) GetStartLine() int
- func (node *CMarkNode) GetTitle() string
- func (node *CMarkNode) GetUrl() string
- func (node *CMarkNode) InsertAfter(sibling *CMarkNode) bool
- func (node *CMarkNode) InsertBefore(sibling *CMarkNode) bool
- func (node *CMarkNode) LastChild() *CMarkNode
- func (node *CMarkNode) Next() *CMarkNode
- func (node *CMarkNode) Parent() *CMarkNode
- func (node *CMarkNode) PrependChild(child *CMarkNode) bool
- func (node *CMarkNode) Previous() *CMarkNode
- func (node *CMarkNode) RenderCMark(options int, width int) string
- func (node *CMarkNode) RenderHtml(options int) string
- func (node *CMarkNode) RenderLatex(options int, width int) string
- func (node *CMarkNode) RenderMan(options int, width int) string
- func (node *CMarkNode) RenderXML(options int) string
- func (newNode *CMarkNode) Replace(oldNode *CMarkNode) bool
- func (node *CMarkNode) SetFenceInfo(fenceInfo string) bool
- func (node *CMarkNode) SetHeaderLevel(level int) bool
- func (node *CMarkNode) SetListDelim(dt DelimType) bool
- func (node *CMarkNode) SetListStart(start int) bool
- func (node *CMarkNode) SetListTight(isTight bool) bool
- func (node *CMarkNode) SetListType(lt ListType) bool
- func (node *CMarkNode) SetLiteral(content string) bool
- func (node *CMarkNode) SetNodeUserData(userData string) bool
- func (node *CMarkNode) SetOnEnter(onEnter string) bool
- func (node *CMarkNode) SetOnExit(onExit string) bool
- func (node *CMarkNode) SetTitle(title string) bool
- func (node *CMarkNode) SetUrl(url string) bool
- func (node *CMarkNode) Unlink()
- type CMarkParser
- type DelimType
- type ListType
- type NodeType
const ( CMARK_NO_DELIM = iota CMARK_PERIOD_DELIM CMARK_PAREN_DELIM )
CMark writer options for render functions
This section is empty.
Converts Markdo--, er, CommonMark text to Html. Parameter mdtext contains CommonMark text. The return value is the HTML string
const ( CMARK_EVENT_NONE CMarkEvent = iota CMARK_EVENT_DONE CMARK_EVENT_ENTER CMARK_EVENT_EXIT )
type CMarkIter struct {
}
Wraps a cmark_iter
func NewCMarkIter(node *CMarkNode) *CMarkIter
Creates a new iterator starting with the given node.
func (iter *CMarkIter) Free()
Frees an iterator
func (iter *CMarkIter) GetNode() *CMarkNode
Returns the next node in the sequence
func (iter *CMarkIter) Next() CMarkEvent
Returns the event type for the next node
func (iter *CMarkIter) Reset(current *CMarkNode, event CMarkEvent)
Reset the iterator so the current node is 'current' and the event type is 'event'. Use this to resume after desctructively modifying the tree structure
type CMarkNode struct {
}
Wraps the cmark_node. CommonMark nodes are represented as Trees in memory.
func NewCMarkNode(nt NodeType) *CMarkNode
Creates a new node of the specified type
Generates a document directly from a string
Parses a file and returns a CMarkNode Returns an error if the file can't be opened
func (node *CMarkNode) AppendChild(child *CMarkNode) bool
Append a child node
func (node *CMarkNode) ConsolidateTextNodes()
Consolidates adjacent text nodes.
func (node *CMarkNode) FirstChild() *CMarkNode
Get first child node
func (node *CMarkNode) Free()
Cleanup a node, including any children. Unlinks a node from the tree and frees it.
func (*CMarkNode) GetEndColumn ¶
func (node *CMarkNode) GetEndColumn() int
Returns the column at which 'node' ends
func (node *CMarkNode) GetEndLine() int
Returns the line on which 'node' ends
func (node *CMarkNode) GetFenceInfo() string
Get Fence info
func (node *CMarkNode) GetHeaderLevel() int
Get a Header node's level
func (node *CMarkNode) GetListDelim() DelimType
Returns the list delimiter type of node, or CMARK_NO_DELIM if node is not a list
func (node *CMarkNode) GetListStart() int
Get a list's start
func (node *CMarkNode) GetListTight() bool
Get list 'tight'
func (node *CMarkNode) GetListType() ListType
Get a List node's list type
Get the node's string content
func (node *CMarkNode) GetNodeType() NodeType
Get the node type
func (node *CMarkNode) GetNodeTypeString() string
Get the node type as a string
func (node *CMarkNode) GetNodeUserData() string
Returns the user data of the node as an unsafe.Pointer. Hope you know what you're doing.
Returns the literal "on enter" text for a custom node, or an empty string if no on_enter is set
Returns the literal "on exit" text for a custom node, or an empty string if no on_exit is set
func (*CMarkNode) GetStartColumn ¶
func (node *CMarkNode) GetStartColumn() int
Returns the column at which 'node' begins
func (node *CMarkNode) GetStartLine() int
Returns the line on which 'node' begins
func (node *CMarkNode) InsertAfter(sibling *CMarkNode) bool
InsertAfter can cause a panic quite readily :) Hint: Both nodes had better already be in the 'tree' Insert a node after another 'sibling' node
func (node *CMarkNode) InsertBefore(sibling *CMarkNode) bool
InsertBefore can cause a panic quite readily :) Hint: Both nodes had better already be in the 'tree' Insert a node before another 'sibling' node
func (node *CMarkNode) LastChild() *CMarkNode
Get last child node
func (node *CMarkNode) Next() *CMarkNode
Get next node
func (node *CMarkNode) Parent() *CMarkNode
Get parent node
func (node *CMarkNode) PrependChild(child *CMarkNode) bool
Prepend a child node
func (node *CMarkNode) Previous() *CMarkNode
Get previous node
Renders node tree as commonmark text.
Renders the document as HTML. Returns an HTML string.
Renders node tree as a LaTeX document
Renders the document as a groff man page, without the header
func (newNode *CMarkNode) Replace(oldNode *CMarkNode) bool
Replaces 'oldNode' with 'newNode' and unlinks 'oldnode' (but does not free its memory). Returns true on success, false on failure.
func (node *CMarkNode) SetHeaderLevel(level int) bool
Set a Header node's level (1,2, etc.)
func (node *CMarkNode) SetListDelim(dt DelimType) bool
Sets the list delimeter type of the node, returns true on success
func (node *CMarkNode) SetListStart(start int) bool
Set a list's start
func (node *CMarkNode) SetListTight(isTight bool) bool
Set list 'tight'
func (node *CMarkNode) SetListType(lt ListType) bool
Set a List node's list type
Set the node's string content
Sets arbitrary user data for node
Sets the literal text to render "on enter" for a custom node. Any children of the node will be rendered after this text. Returns true on success and false on failure
Sets the literal text to render "on exit" for a custom node. Any children of the node will be rendered before this text. Returns true on success and false on failure
func (node *CMarkNode) Unlink()
Unlink a node from the tree
type CMarkParser struct {
}
Wraps the cmark_doc_parser
func NewCmarkParser(options int) *CMarkParser
Retruns a new CMark Parser. You must call Free() on this thing when you're done with it! Please.
func (cmp *CMarkParser) Finish() *CMarkNode
Finish parsing and generate a document You must call Free() on the document when you're done with it!
func (cmp *CMarkParser) Free()
Cleanup the parser Once you call Free on this, you can't use it anymore
Maps to a cmark_list_type in cmark.h
const ( CMARK_NO_LIST ListType = iota CMARK_BULLET_LIST CMARK_ORDERED_LIST )
Maps to a cmark_node_type enum in cmark.h
const (
CMARK_NODE_NONE [NodeType](#NodeType) = [iota](/builtin#iota)
CMARK_NODE_DOCUMENT
CMARK_NODE_BLOCK_QUOTE
CMARK_NODE_LIST
CMARK_NODE_ITEM
CMARK_NODE_CODE_BLOCK
CMARK_NODE_HTML_BLOCK
CMARK_NODE_CUSTOM_BLOCK
CMARK_NODE_PARAGRAPH
CMARK_NODE_HEADING
CMARK_NODE_THEMATIC_BREAK
CMARK_NODE_TEXT
CMARK_NODE_SOFTBREAK
CMARK_NODE_LINEBREAK
CMARK_NODE_CODE
CMARK_NODE_HTML_INLINE
CMARK_NODE_CUSTOM_INLINE
CMARK_NODE_EMPH
CMARK_NODE_STRONG
CMARK_NODE_LINK
CMARK_NODE_IMAGE
CMARK_NODE_FIRST_BLOCK = [CMARK_NODE_DOCUMENT](#CMARK%5FNODE%5FDOCUMENT)
CMARK_NODE_LAST_BLOCK = [CMARK_NODE_THEMATIC_BREAK](#CMARK%5FNODE%5FTHEMATIC%5FBREAK)
CMARK_NODE_FIRST_INLINE = [CMARK_NODE_TEXT](#CMARK%5FNODE%5FTEXT)
CMARK_NODE_LAST_INLINE = [CMARK_NODE_IMAGE](#CMARK%5FNODE%5FIMAGE)
)