package vendor:commonmark

Overview

Bindings against CMark (https://github.com/commonmark/cmark)

Original authors: John MacFarlane, Vicent Marti, Kārlis Gaņģis, Nick Wellnhofer.
See LICENSE for license details.

Bindings against CMark (https://github.com/commonmark/cmark)

Original authors: John MacFarlane, Vicent Marti, Kārlis Gaņģis, Nick Wellnhofer.
See LICENSE for license details.

Index

Variables (0)

This section is empty.

Procedures (73)
Procedure Groups (1)

Types

Allocator ¶

Allocator :: struct {
	calloc:  proc "cdecl" (nmemb, size: uint) -> rawptr,
	realloc: proc "cdecl" (ptr: rawptr, size: uint) -> rawptr,
	free:    proc "cdecl" (_: rawptr),
}
 

Custom allocator - Defines the memory allocation functions to be used by CMark when parsing and allocating a document tree

Code ¶

Code :: struct {
	info:         cstring,
	fence_length: u8,
	fence_offset: u8,
	fence_char:   u8,
	fenced:       b8,
}

Custom ¶

Custom :: struct {
	on_enter: cstring,
	on_exit:  cstring,
}

Delim_Type ¶

Delim_Type :: enum i32 {
	None, 
	Period, 
	Paren, 
}

Event_Type ¶

Event_Type :: enum i32 {
	None, 
	Done, 
	Enter, 
	Exit, 
}

Heading ¶

Heading :: struct {
	internal_offset: i32,
	level:           i8,
	setext:          bool,
}

Iter ¶

Iter :: distinct rawptr
Link :: struct {
	url:   cstring,
	title: cstring,
}

List ¶

List :: struct {
	marker_offset: i32,
	padding:       i32,
	start:         i32,
	list_type:     u8,
	delimiter:     u8,
	bullet_char:   u8,
	tight:         bool,
}

List_Type ¶

List_Type :: enum i32 {
	None, 
	Bullet, 
	Ordered, 
}

Node ¶

Node :: struct {
	mem:          ^Allocator,
	next:         ^Node,
	prev:         ^Node,
	parent:       ^Node,
	first_child:  ^Node,
	last_child:   ^Node,
	user_data:    rawptr,
	data:         [^]u8,
	len:          bufsize_t,
	start_line:   i32,
	start_column: i32,
	end_line:     i32,
	end_column:   i32,
	type:         Node_Type,
	flags:        bit_set[Node_Flag; u16],
	as:           struct #raw_union {
		list:            List,
		code:            Code,
		heading:         Heading,
		link:            Link,
		custom:          Custom,
		html_block_type: i32,
	},
}
 

Node creation, destruction, and tree traversal

Node_Flag ¶

Node_Flag :: enum u16 {
	Open              = 0, 
	Last_Line_Blank   = 1, 
	Last_Line_Checked = 2, 
}

Node_Flags ¶

Node_Flags :: bit_set[Node_Flag; u16]

Node_Type ¶

Node_Type :: enum u16 {
	// Error status
	None           = 0, 
	// Block 
	Document, 
	Block_Quote, 
	List, 
	Item, 
	Code_Block, 
	HTML_Block, 
	Custom_Block, 
	Paragraph, 
	Heading, 
	Thematic_Break, 
	// Inline 
	Text, 
	Soft_Break, 
	Line_Break, 
	Code, 
	HTML_Inline, 
	Custom_Inline, 
	Emph, 
	Strong, 
	Link, 
	Image, 
	First_Block    = 1, 
	Last_Block     = 10, 
	First_Inline   = 11, 
	Last_Inline    = 20, 
}

Option ¶

Option :: enum i32 {
	Source_Position = 1,  // Include a `data-sourcepos` attribute on all block elements.
	Hard_Breaks     = 2,  // Render `softbreak` as hard line breaks.
	Safe            = 3,  // Defined for API compatibility, now enabled by default.
	Unsafe          = 17, // Render raw HTML and unsafe links (`javascript:`, `vbscript:`,
	// `file:`, and `data:`, except for `image/png`, `image/gif`,
	// `image/jpeg`, or `image/webp` mime types).  By default,
	// raw HTML is replaced by a placeholder HTML comment. Unsafe
	// links are replaced by empty strings.
	No_Breaks       = 4,  // Render `softbreak` elements as spaces.
	Normalize       = 8,  // Legacy option, no effect.
	Validate_UTF8   = 9,  // Validate UTF-8 input before parsing, replacing illegal
	// sequences with the replacement character U+FFFD.
	Smart           = 10, // Convert straight quotes to curly, --- to em dashes, -- to en dashes.
}

Options ¶

Options :: bit_set[Option; i32]

Parser ¶

Parser :: distinct rawptr

Version_Info ¶

Version_Info :: struct {
	patch: u8,
	minor: u8,
	major: u8,
	_:     u8,
}
 

Version information

bufsize_t ¶

bufsize_t :: distinct i32

Constants

BINDING_VERSION ¶

BINDING_VERSION :: Version_Info{major = 0, minor = 30, patch = 2}

DEFAULT_OPTIONS ¶

DEFAULT_OPTIONS: bit_set[Option; i32] : Options{}

Variables

This section is empty.

Procedures

consolidate_text_nodes ¶

consolidate_text_nodes :: proc "cdecl" (node: ^Node) ---
 

Consolidates adjacent text nodes.

free_cstring ¶

free_cstring :: proc "cdecl" (s: cstring) {…}

free_rawptr ¶

free_rawptr :: proc "cdecl" (_: rawptr) {…}
 

Helpers to free results from render_*.

free_string ¶

free_string :: proc "cdecl" (s: string) {…}

get_default_mem_allocator ¶

get_default_mem_allocator :: proc "cdecl" () -> (mem: ^Allocator) ---
 

Returns a pointer to the default memory allocator.

get_default_mem_allocator_as_odin ¶

get_default_mem_allocator_as_odin :: proc "odin" () -> runtime.Allocator {…}

get_fence_info ¶

get_fence_info :: proc "cdecl" (node: ^Node) -> (node_type: cstring) ---
 

Returns the info string from a fenced code block.

iter_free ¶

iter_free :: proc "cdecl" (iter: ^Iter) ---
 

Frees the memory allocated for an iterator.

iter_get_event_type ¶

iter_get_event_type :: proc "cdecl" (iter: ^Iter) -> (event_type: Event_Type) ---
 

Returns the current event type.

iter_get_node ¶

iter_get_node :: proc "cdecl" (iter: ^Iter) -> (node: ^Node) ---
 

Returns the current node.

iter_get_root ¶

iter_get_root :: proc "cdecl" (iter: ^Iter) -> (node: ^Node) ---
 

Returns the root node.

iter_new ¶

iter_new :: proc "cdecl" (root: ^Node) -> (iter: ^Iter) ---
 

Creates a new iterator starting at 'root'. The current node and event type are undefined until iter_next is called for the first time. The memory allocated for the iterator should be released using 'iter_free' when it is no longer needed.

iter_next ¶

iter_next :: proc "cdecl" (iter: ^Iter) -> (event_type: Event_Type) ---
 

Advances to the next node and returns the event type (.Enter, .Exit, .Done)

iter_reset ¶

iter_reset :: proc "cdecl" (iter: ^Iter, current: ^Node, event_type: Event_Type) ---
 

Resets the iterator so that the current node is current and the event type is event_type. The new current node must be a descendant of the root node or the root node itself.

markdown_to_html ¶

markdown_to_html :: proc "cdecl" (text: cstring, length: uint, options: bit_set[Option; i32]) -> (html: cstring) ---
 

Convert 'text' (assumed to be a UTF-8 encoded string with length len) from CommonMark Markdown to HTML returning a null-terminated, UTF-8-encoded string. It is the caller's responsibility to free the returned buffer.

markdown_to_html_from_string ¶

markdown_to_html_from_string :: proc "odin" (text: string, options: bit_set[Option; i32]) -> (html: string) {…}

node_append_child ¶

node_append_child :: proc "cdecl" (node: ^Node, sibling: ^Node) -> (success: b32) ---
 

Adds 'child' to the end of the children of node. Returns true on success, false on failure.

node_first_child ¶

node_first_child :: proc "cdecl" (node: ^Node) -> (next: ^Node) ---
 

Returns the first child of node, or nil if node has no children.

node_free ¶

node_free :: proc "cdecl" (node: ^Node) ---
 

Frees the memory allocated for a node and any children.

node_get_end_column ¶

node_get_end_column :: proc "cdecl" (node: ^Node) -> (level: i32) ---
 

Returns the column at which node ends.

node_get_end_line ¶

node_get_end_line :: proc "cdecl" (node: ^Node) -> (level: i32) ---
 

Returns the line on which node ends.

node_get_heading_level ¶

node_get_heading_level :: proc "cdecl" (node: ^Node) -> (level: i32) ---
 

Returns the heading level of node, or 0 if node is not a heading.

node_get_list_delim ¶

node_get_list_delim :: proc "cdecl" (node: ^Node) -> (delim_type: Delim_Type) ---
 

Returns the list delimiter type of node, or .No_Delim if not a list.

node_get_list_start ¶

node_get_list_start :: proc "cdecl" (node: ^Node) -> (level: i32) ---
 

Returns starting number of node, if it is an ordered list, otherwise 0.

node_get_list_tight ¶

node_get_list_tight :: proc "cdecl" (node: ^Node) -> (tight: b32) ---
 

Returns true if node is a tight list, false otherwise.

node_get_list_type ¶

node_get_list_type :: proc "cdecl" (node: ^Node) -> (list_type: List_Type) ---
 

Returns the list type of node, or .No_List if not a list.

node_get_literal ¶

node_get_literal :: proc "cdecl" (node: ^Node) -> (node_type: cstring) ---
 

Returns the string contents of node, or an empty string if none is set. Returns nil if called on a node that does not have string content.

node_get_on_enter ¶

node_get_on_enter :: proc "cdecl" (node: ^Node) -> (node_type: cstring) ---
 

Returns the literal "on enter" text for a custom node, or an empty string if no on_enter is set. Returns nil if called on a non-custom node.

node_get_start_column ¶

node_get_start_column :: proc "cdecl" (node: ^Node) -> (level: i32) ---
 

Returns the column at which node begins.

node_get_start_line ¶

node_get_start_line :: proc "cdecl" (node: ^Node) -> (level: i32) ---
 

Returns the line on which node begins.

node_get_title ¶

node_get_title :: proc "cdecl" (node: ^Node) -> (node_type: cstring) ---
 

Returns the title of a link or image node, or an empty string if no title is set. Returns nil if called on a node that is not a link or image.

node_get_type ¶

node_get_type :: proc "cdecl" (node: ^Node) -> (node_type: Node_Type) ---
 

Returns the type of node, or .None on error.

node_get_type_string ¶

node_get_type_string :: proc "cdecl" (node: ^Node) -> (node_type: cstring) ---
 

Like node_get_type, but returns a string representation of the type, or "".

node_get_url ¶

node_get_url :: proc "cdecl" (node: ^Node) -> (node_type: cstring) ---
 

Returns the URL of a link or image node, or an empty string if no URL is set. Returns nil if called on a node that is not a link or image.

node_get_user_data ¶

node_get_user_data :: proc "cdecl" (node: ^Node) -> (user_data: rawptr) ---
 

Returns the user data of node.

node_insert_after ¶

node_insert_after :: proc "cdecl" (node: ^Node, sibling: ^Node) -> (success: b32) ---
 

Inserts 'sibling' after node. Returns true on success, false on failure.

node_insert_before ¶

node_insert_before :: proc "cdecl" (node: ^Node, sibling: ^Node) -> (success: b32) ---
 

Inserts 'sibling' before node. Returns true on success, false on failure.

node_last_child ¶

node_last_child :: proc "cdecl" (node: ^Node) -> (next: ^Node) ---
 

Returns the last child of node, or nil if node has no children.

node_new ¶

node_new :: proc "cdecl" (type: Node_Type) -> (node: ^Node) ---
 

Creates a new node of type 'type'. Note that the node may have other required properties, which it is the caller's responsibility to assign.

node_new_with_mem ¶

node_new_with_mem :: proc "cdecl" (type: Node_Type, mem: ^Allocator) -> (node: ^Node) ---
 

Same as node_new, but explicitly listing the memory allocator used to allocate the node. Note: be sure to use the same allocator for every node in a tree, or bad things can happen.

node_next ¶

node_next :: proc "cdecl" (node: ^Node) -> (next: ^Node) ---
 

Tree Traversal

Returns the next node in the sequence after node, or nil if there is none.

node_parent ¶

node_parent :: proc "cdecl" (node: ^Node) -> (next: ^Node) ---
 

Returns the parent of node, or nil if there is none.

node_prepend_child ¶

node_prepend_child :: proc "cdecl" (node: ^Node, sibling: ^Node) -> (success: b32) ---
 

Adds 'child' to the beginning of the children of node. Returns true on success, false on failure.

node_previous ¶

node_previous :: proc "cdecl" (node: ^Node) -> (next: ^Node) ---
 

Returns the previous node in the sequence after node, or nil if there is none.

node_replace ¶

node_replace :: proc "cdecl" (node: ^Node, sibling: ^Node) -> (success: b32) ---
 

Replaces 'oldnode' with 'newnode' and unlinks 'oldnode' (but does not free its memory). Returns true on success, false on failure.

node_set_fence_info ¶

node_set_fence_info :: proc "cdecl" (node: ^Node, content: cstring) -> (success: b32) ---
 

Sets the info string in a fenced code block, returning true on success and false on failure.

node_set_heading_level ¶

node_set_heading_level :: proc "cdecl" (node: ^Node, level: i32) -> (success: b32) ---
 

Sets the heading level of node. Returns true on success, false on failure.

node_set_list_delim ¶

node_set_list_delim :: proc "cdecl" (node: ^Node, delim_type: Delim_Type) -> (success: b32) ---
 

Sets the delimiter type of node. Returns true on success, false on failure.

node_set_list_start ¶

node_set_list_start :: proc "cdecl" (node: ^Node, level: i32) -> (success: b32) ---
 

Sets starting number of node, if it is an ordered list. Returns true on success, false on failure.

node_set_list_tight ¶

node_set_list_tight :: proc "cdecl" (node: ^Node, tight: b32) -> (success: b32) ---
 

Sets the "tightness" of a list. Returns true on success, false on failure.

node_set_list_type ¶

node_set_list_type :: proc "cdecl" (node: ^Node, list_type: List_Type) -> (success: b32) ---
 

Sets the list type of node. Returns true on success, false on failure.

node_set_literal ¶

node_set_literal :: proc "cdecl" (node: ^Node, content: cstring) -> (success: b32) ---
 

Sets the string contents of node. Returns true on success, false on failure.

node_set_on_enter ¶

node_set_on_enter :: proc "cdecl" (node: ^Node, content: cstring) -> (success: b32) ---
 

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, falseon failure.

node_set_title ¶

node_set_title :: proc "cdecl" (node: ^Node, content: cstring) -> (success: b32) ---
 

Sets the title of a link or image node. Returns true on success, false on failure.

node_set_url ¶

node_set_url :: proc "cdecl" (node: ^Node, content: cstring) -> (success: b32) ---
 

Sets the URL of a link or image node. Returns true on success, false on failure.

node_set_user_data ¶

node_set_user_data :: proc "cdecl" (node: ^Node, user_data: rawptr) -> (success: b32) ---
 

Sets arbitrary user data for node. Returns true on success, false on failure.

node_unlink :: proc "cdecl" (node: ^Node) ---
 

Unlinks a node, removing it from the tree, but not freeing its memory. (Use node_free for that.)

parse_document ¶

parse_document :: proc "cdecl" (buffer: [^]u8, len: uint, options: bit_set[Option; i32]) -> (root: ^Node) ---
 

Parse a CommonMark document in 'buffer' of length 'len'. Returns a pointer to a tree of nodes. The memory allocated for the node tree should be released using 'node_free' when it is no longer needed.

parse_document_from_string ¶

parse_document_from_string :: proc "cdecl" (s: string, options: bit_set[Option; i32]) -> (root: ^Node) {…}

parse_from_libc_file ¶

parse_from_libc_file :: proc "cdecl" (file: ^libc.FILE, options: bit_set[Option; i32]) -> (root: ^Node) ---

parser_feed ¶

parser_feed :: proc "cdecl" (parser: ^Parser, buffer: [^]u8, len: uint) ---
 

Feeds a string of length 'len' to 'parser'.

parser_feed_from_string ¶

parser_feed_from_string :: proc "cdecl" (parser: ^Parser, s: string) {…}

parser_finish ¶

parser_finish :: proc "cdecl" (parser: ^Parser) -> (root: ^Node) ---
 

Finish parsing and return a pointer to a tree of nodes.

parser_free ¶

parser_free :: proc "cdecl" (parser: ^Parser) ---
 

Frees memory allocated for a parser object.

parser_new ¶

parser_new :: proc "cdecl" (options: bit_set[Option; i32]) -> (parser: ^Parser) ---
 

Creates a new parser object.

parser_new_with_mem ¶

parser_new_with_mem :: proc "cdecl" (options: bit_set[Option; i32], mem: ^Allocator) -> (parser: ^Parser) ---
 

Creates a new parser object with the given memory allocator.

render_commonmark ¶

render_commonmark :: proc "cdecl" (root: ^Node, options: bit_set[Option; i32], width: i32) -> (groff: cstring) ---
 

Render a node tree as a commonmark document. It is the caller's responsibility to free the returned buffer.

render_html ¶

render_html :: proc "cdecl" (root: ^Node, options: bit_set[Option; i32]) -> (xml: cstring) ---
 

Render a node tree as an HTML fragment. It is up to the user to add an appropriate header and footer. It is the caller's responsibility to free the returned buffer.

render_latex ¶

render_latex :: proc "cdecl" (root: ^Node, options: bit_set[Option; i32], width: i32) -> (groff: cstring) ---
 

Render a node tree as a LaTeX document. It is the caller's responsibility to free the returned buffer.

render_man ¶

render_man :: proc "cdecl" (root: ^Node, options: bit_set[Option; i32], width: i32) -> (groff: cstring) ---
 

Render a node tree as a groff man page, without the header. It is the caller's responsibility to free the returned buffer.

render_xml ¶

render_xml :: proc "cdecl" (root: ^Node, options: bit_set[Option; i32]) -> (xml: cstring) ---
 

Render a node tree as XML. It is the caller's responsibilityto free the returned buffer.

version ¶

version :: proc "cdecl" () -> (res: Version_Info) ---

version_string ¶

version_string :: proc "cdecl" () -> cstring ---

Procedure Groups

Source Files

Generation Information

Generated with odin version dev-2022-10 (vendor "odin") Windows_amd64 @ 2022-10-05 21:11:47.822436300 +0000 UTC