Documentation
¶
Overview ¶
Package bonsaimarkdowninline provides a tree-sitter parser for the inline portion of Markdown, built on the bonsai snapshot runtime.
The companion block grammar (bonsai-markdown) parses document structure and emits opaque `inline` leaves for the text inside paragraphs, headings, and list items. Feeding such a leaf's text to this parser yields tokens for emphasis, strong emphasis, code spans, links, images, and the rest of the inline vocabulary.
Typical use:
p := bonsaimarkdowninline.NewParser()
root, err := p.Parse([]byte("A *paragraph* with `code` and a [link](http://x)."))
if err != nil { ... }
for n := range root.Find("link") { ... }
The Parser, Node, and Point types are aliases for the corresponding bonsai runtime types, so values flow naturally between bonsai-aware code and this package.
The wasm module + grammar are generated. See Dockerfile.builder at the repo root. `go generate ./bonsai-markdown-inline` regenerates module_gen.{go,dat}, libc_gen.go, and meta_gen.go in this directory.
Grammar source: https://github.com/tree-sitter-grammars/tree-sitter-markdown (tree-sitter-markdown-inline/ subdirectory)
Index ¶
- Constants
- Variables
- type Memory
- type Module
- func (m *Module) X__indirect_function_table() *[]any
- func (m *Module) X_initialize()
- func (m *Module) Xfree(v0 int32)
- func (m *Module) Xmalloc(v0 int32) int32
- func (m *Module) Xtree_sitter_markdown_inline() int32
- func (m *Module) Xts_node_end_byte(v0 int32) int32
- func (m *Module) Xts_node_end_point(v0, v1 int32)
- func (m *Module) Xts_node_has_error(v0 int32) int32
- func (m *Module) Xts_node_is_error(v0 int32) int32
- func (m *Module) Xts_node_is_missing(v0 int32) int32
- func (m *Module) Xts_node_is_named(v0 int32) int32
- func (m *Module) Xts_node_is_null(v0 int32) int32
- func (m *Module) Xts_node_start_byte(v0 int32) int32
- func (m *Module) Xts_node_start_point(v0, v1 int32)
- func (m *Module) Xts_node_string(v0 int32) int32
- func (m *Module) Xts_node_type(v0 int32) int32
- func (m *Module) Xts_parser_delete(v0 int32)
- func (m *Module) Xts_parser_new() int32
- func (m *Module) Xts_parser_parse_string(v0, v1, v2, v3 int32) int32
- func (m *Module) Xts_parser_set_language(v0, v1 int32) int32
- func (m *Module) Xts_tree_cursor_current_field_name(v0 int32) int32
- func (m *Module) Xts_tree_cursor_current_node(v0, v1 int32)
- func (m *Module) Xts_tree_cursor_delete(v0 int32)
- func (m *Module) Xts_tree_cursor_goto_first_child(v0 int32) int32
- func (m *Module) Xts_tree_cursor_goto_next_sibling(v0 int32) int32
- func (m *Module) Xts_tree_cursor_goto_parent(v0 int32) int32
- func (m *Module) Xts_tree_cursor_new(v0, v1 int32)
- func (m *Module) Xts_tree_delete(v0 int32)
- func (m *Module) Xts_tree_root_node(v0, v1 int32)
- type Node
- type Parser
- type Point
- type Xenv
Constants ¶
const ( KindBackslashEscape = "backslash_escape" KindCodeSpan = "code_span" KindCodeSpanDelimiter = "code_span_delimiter" KindCollapsedReferenceLink = "collapsed_reference_link" KindEmailAutolink = "email_autolink" KindEmphasis = "emphasis" KindEmphasisDelimiter = "emphasis_delimiter" KindEntityReference = "entity_reference" KindFullReferenceLink = "full_reference_link" KindHardLineBreak = "hard_line_break" KindHtmlTag = "html_tag" KindImage = "image" KindImageDescription = "image_description" KindInline = "inline" KindInlineLink = "inline_link" KindLatexBlock = "latex_block" KindLatexSpanDelimiter = "latex_span_delimiter" KindLinkDestination = "link_destination" KindLinkLabel = "link_label" KindLinkText = "link_text" KindLinkTitle = "link_title" KindNumericCharacterReference = "numeric_character_reference" KindShortcutLink = "shortcut_link" KindStrikethrough = "strikethrough" KindStrongEmphasis = "strong_emphasis" KindUriAutolink = "uri_autolink" )
KindX constants name every named, visible node type this grammar can produce as Node.Kind. Values are the raw tree-sitter kind strings, so they work anywhere a node kind string is expected, like Node.Find. Anonymous tokens (keywords, punctuation) and supertypes have no constants.
const GrammarVersion = "v0.5.3"
GrammarVersion is the upstream grammar ref (tag or branch) this module's parser was generated from. The exact commit is in the header above.
const InitialPages = 5
InitialPages is the wasm module's declared initial linear-memory size, in 64 KiB WebAssembly pages. Memory passed to New must already be sized to at least InitialPages * 65536 bytes before the call.
const TreeSitterVersion = "v0.25.10"
TreeSitterVersion is the tree-sitter runtime ref whose compiled form this module embeds.
Variables ¶
var LicenseGrammar string
LicenseGrammar is the license of the grammar (https://github.com/tree-sitter-grammars/tree-sitter-markdown.git @ v0.5.3) whose compiled form this package embeds.
var LicenseTreeSitter string
LicenseTreeSitter is the license of the tree-sitter runtime (v0.25.10) whose compiled form this package embeds.
Functions ¶
This section is empty.
Types ¶
type Module ¶
type Module struct {
// contains filtered or unexported fields
}
func (*Module) X__indirect_function_table ¶
func (*Module) X_initialize ¶
func (m *Module) X_initialize()