Documentation ¶
Overview ¶
Package commonmark provides a Go wrapper for the CommonMark C Library
Index ¶
- 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
Constants ¶
const ( CMARK_NO_DELIM = iota CMARK_PERIOD_DELIM CMARK_PAREN_DELIM )
const CMARK_OPT_DEFAULT = 0
CMark writer options for render functions
const CMARK_OPT_HARDBREAKS = 2
const CMARK_OPT_NORMALIZE = 4
const CMARK_OPT_SAFE = 32
const CMARK_OPT_SMART = 8
const CMARK_OPT_SOURCEPOS = 1
const CMARK_OPT_VALIDATE_UTF8 = 16
Variables ¶
This section is empty.
Functions ¶
Types ¶
type CMarkEvent ¶
type CMarkEvent int
const ( CMARK_EVENT_NONE CMarkEvent = iota CMARK_EVENT_DONE CMARK_EVENT_ENTER CMARK_EVENT_EXIT )
type CMarkIter ¶
type CMarkIter struct {
// contains filtered or unexported fields
}
Wraps a cmark_iter
func NewCMarkIter ¶
Creates a new iterator starting with the given node.
func (*CMarkIter) Next ¶
func (iter *CMarkIter) Next() CMarkEvent
Returns the event type for the next node
func (*CMarkIter) Reset ¶
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 ¶
type CMarkNode struct {
// contains filtered or unexported fields
}
Wraps the cmark_node. CommonMark nodes are represented as Trees in memory.
func NewCMarkNode ¶
Creates a new node of the specified type
func ParseDocument ¶
Generates a document directly from a string
func (*CMarkNode) AppendChild ¶
Append a child node
func (*CMarkNode) ConsolidateTextNodes ¶
func (node *CMarkNode) ConsolidateTextNodes()
Consolidates adjacent text nodes.
func (*CMarkNode) Free ¶
func (node *CMarkNode) Free()
Cleanup a node, including any children. Unlinks a node from the tree and frees it.
func (*CMarkNode) GetEndColumn ¶
Returns the column at which 'node' ends
func (*CMarkNode) GetEndLine ¶
Returns the line on which 'node' ends
func (*CMarkNode) GetHeaderLevel ¶
Get a Header node's level
func (*CMarkNode) GetListDelim ¶
Returns the list delimiter type of node, or CMARK_NO_DELIM if node is not a list
func (*CMarkNode) GetListType ¶
Get a List node's list type
func (*CMarkNode) GetLiteral ¶
Get the node's string content
func (*CMarkNode) GetNodeTypeString ¶
Get the node type as a string
func (*CMarkNode) GetNodeUserData ¶
Returns the user data of the node as an unsafe.Pointer. Hope you know what you're doing.
func (*CMarkNode) GetOnEnter ¶
Returns the literal "on enter" text for a custom node, or an empty string if no on_enter is set
func (*CMarkNode) GetOnExit ¶
Returns the literal "on exit" text for a custom node, or an empty string if no on_exit is set
func (*CMarkNode) GetStartColumn ¶
Returns the column at which 'node' begins
func (*CMarkNode) GetStartLine ¶
Returns the line on which 'node' begins
func (*CMarkNode) InsertAfter ¶
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 (*CMarkNode) InsertBefore ¶
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 (*CMarkNode) PrependChild ¶
Prepend a child node
func (*CMarkNode) RenderCMark ¶
Renders node tree as commonmark text.
func (*CMarkNode) RenderHtml ¶
Renders the document as HTML. Returns an HTML string.
func (*CMarkNode) RenderLatex ¶
Renders node tree as a LaTeX document
func (*CMarkNode) Replace ¶
Replaces 'oldNode' with 'newNode' and unlinks 'oldnode' (but does not free its memory). Returns true on success, false on failure.
func (*CMarkNode) SetFenceInfo ¶
Set Fence info
func (*CMarkNode) SetHeaderLevel ¶
Set a Header node's level (1,2, etc.)
func (*CMarkNode) SetListDelim ¶
Sets the list delimeter type of the node, returns true on success
func (*CMarkNode) SetListStart ¶
Set a list's start
func (*CMarkNode) SetListTight ¶
Set list 'tight'
func (*CMarkNode) SetListType ¶
Set a List node's list type
func (*CMarkNode) SetLiteral ¶
Set the node's string content
func (*CMarkNode) SetNodeUserData ¶
Sets arbitrary user data for node
func (*CMarkNode) SetOnEnter ¶
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
type CMarkParser ¶
type CMarkParser struct {
// contains filtered or unexported fields
}
Wraps the cmark_doc_parser
func NewCmarkParser ¶
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 (*CMarkParser) Finish ¶
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 (*CMarkParser) Free ¶
func (cmp *CMarkParser) Free()
Cleanup the parser Once you call Free on this, you can't use it anymore
type NodeType ¶
type NodeType int
Maps to a cmark_node_type enum in cmark.h
const ( //Error Status CMARK_NODE_NONE NodeType = iota //Block 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 //Inline 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 //Block CMARK_NODE_FIRST_BLOCK = CMARK_NODE_DOCUMENT CMARK_NODE_LAST_BLOCK = CMARK_NODE_THEMATIC_BREAK //Inline CMARK_NODE_FIRST_INLINE = CMARK_NODE_TEXT CMARK_NODE_LAST_INLINE = CMARK_NODE_IMAGE )