tree-sitter-markdown

    Markdown grammar for tree-sitter (tree-sitter-grammars/tree-sitter-markdown v0.5.4), for the MoonBit port of Tree-sitter (moonbit-community/treesitter).

    tree-sitter
    parser
    grammar
    markdown
    markdown_inline
    Download zip
    Version
    0.5.4
    License
    MIT
    Last updated
    21 days ago
    Downloads
    23

    #tree-sitter-markdown for MoonBit

    Markdown grammar for tree-sitter.

    This module packages tree-sitter-grammars/tree-sitter-markdown v0.5.4 for moonbit-community/treesitter, the pure MoonBit port of Tree-sitter. The parse tables are generated from the grammar's src/grammar.json by the port's generator, which produces the same tables as tree-sitter generate 0.28.0. External scanners come from @scanners.scanner_for in moonbit-community/treesitter/scanners, the MoonBit ports of the C scanners.

    #API

    The package mirrors the grammar's Rust binding (bindings/rust/lib.rs):

    MoonBitRust
    language() -> @treesitter.LanguageLANGUAGE
    inline_language() -> @treesitter.LanguageINLINE_LANGUAGE
    highlight_query_block : StringHIGHLIGHT_QUERY_BLOCK (tree-sitter-markdown/queries/highlights.scm)
    injection_query_block : StringINJECTION_QUERY_BLOCK (tree-sitter-markdown/queries/injections.scm)
    highlight_query_inline : StringHIGHLIGHT_QUERY_INLINE (tree-sitter-markdown-inline/queries/highlights.scm)
    injection_query_inline : StringINJECTION_QUERY_INLINE (tree-sitter-markdown-inline/queries/injections.scm)
    node_types_block : StringNODE_TYPES_BLOCK (tree-sitter-markdown/src/node-types.json)
    node_types_inline : StringNODE_TYPES_INLINE (tree-sitter-markdown-inline/src/node-types.json)

    #Usage

    moon add moonbit-community/tree-sitter-markdown

    In moon.pkg:

    import { "moonbit-community/treesitter", "moonbit-community/tree-sitter-markdown" @tree_sitter_markdown, }

    ///|
    test "parse markdown" {
    let language = @tree_sitter_markdown.language()
    let parser = @treesitter.Parser::new()
    parser.set_language(language)
    let source =
    #|| foo | bar |
    #|| --- | --- |
    #|| baz | bim |
    #|
    guard parser.parse(@utf8.encode(source)) is Some(tree) else {
    fail("parse failed")
    }
    let root = tree.root_node()
    assert_false(root.has_error())
    assert_false(root.to_sexp().contains("ERROR"))
    }

    #License

    The grammar and the files copied from it (src/grammar.json, queries, test corpus) are under the license of tree-sitter-grammars/tree-sitter-markdown, in LICENSE.

    highlight_query_block

    let highlight_query_block : String

    The content of tree-sitter-markdown/queries/highlights.scm (HIGHLIGHT_QUERY_BLOCK in the Rust binding).

    highlight_query_inline

    let highlight_query_inline : String

    The content of tree-sitter-markdown-inline/queries/highlights.scm (HIGHLIGHT_QUERY_INLINE in the Rust binding).

    injection_query_block

    let injection_query_block : String

    The content of tree-sitter-markdown/queries/injections.scm (INJECTION_QUERY_BLOCK in the Rust binding).

    injection_query_inline

    let injection_query_inline : String

    The content of tree-sitter-markdown-inline/queries/injections.scm (INJECTION_QUERY_INLINE in the Rust binding).

    inline_language

    The tree-sitter language for markdown_inline (INLINE_LANGUAGE in the Rust binding), generated from tree-sitter-markdown-inline/src/grammar.json. Its external scanner is @scanners.scanner_for("markdown_inline"); without one (a scanner not ported yet) the language is not parseable (@treesitter.Language::is_parseable).

    language

    The tree-sitter language for markdown (LANGUAGE in the Rust binding), generated from tree-sitter-markdown/src/grammar.json. Its external scanner is @scanners.scanner_for("markdown"); without one (a scanner not ported yet) the language is not parseable (@treesitter.Language::is_parseable).

    node_types_block

    let node_types_block : String

    The content of tree-sitter-markdown/src/node-types.json (NODE_TYPES_BLOCK in the Rust binding).

    node_types_inline

    let node_types_inline : String

    The content of tree-sitter-markdown-inline/src/node-types.json (NODE_TYPES_INLINE in the Rust binding).