diff --git a/Cargo.toml b/Cargo.toml index e00cba6..a97f517 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "tree-sitter-md" description = "Markdown grammar for tree-sitter" -version = "0.3.0" +version = "0.3.1" license = "MIT" readme = "README.md" keywords = ["incremental", "parsing", "tree-sitter", "markdown"] diff --git a/README.md b/README.md index cecce85..c1817b3 100644 --- a/README.md +++ b/README.md @@ -5,6 +5,7 @@ [![matrix][matrix]](https://matrix.to/#/#tree-sitter-chat:matrix.org) [![npm][npm]](https://www.npmjs.com/package/@tree-sitter-grammars/tree-sitter-markdown) [![crates][crates]](https://crates.io/crates/tree-sitter-md) +[![pypi][pypi]](https://pypi.org/project/tree-sitter-markdown/) A Markdown parser for [tree-sitter]. @@ -78,3 +79,4 @@ Unfortunately using this parser with WASM/web-tree-sitter does not work out of t [matrix]: https://img.shields.io/matrix/tree-sitter-chat%3Amatrix.org?logo=matrix&label=matrix [npm]: https://img.shields.io/npm/v/%40tree-sitter-grammars%2Ftree-sitter-markdown?logo=npm [crates]: https://img.shields.io/crates/v/tree-sitter-md?logo=rust +[pypi]: https://img.shields.io/pypi/v/tree-sitter-markdown?logo=pypi&logoColor=ffd242 diff --git a/bindings/rust/lib.rs b/bindings/rust/lib.rs index 24f51a5..cf226d4 100644 --- a/bindings/rust/lib.rs +++ b/bindings/rust/lib.rs @@ -1,7 +1,7 @@ //! This crate provides Markdown language support for the [tree-sitter][] parsing library. //! -//! It contains two grammars: [`language`] to parse the block structure of markdown documents and -//! [`inline_language`] to parse inline content. +//! It contains two grammars: [`LANGUAGE`] to parse the block structure of markdown documents and +//! [`INLINE_LANGUAGE`] to parse inline content. //! //! It also supplies [`MarkdownParser`] as a convenience wrapper around the two grammars. //! [`MarkdownParser::parse`] returns a [`MarkdownTree`] instread of a [`Tree`][Tree]. This struct @@ -26,12 +26,19 @@ pub const LANGUAGE: LanguageFn = unsafe { LanguageFn::from_raw(tree_sitter_markd pub const INLINE_LANGUAGE: LanguageFn = unsafe { LanguageFn::from_raw(tree_sitter_markdown_inline) }; +/// The syntax highlighting queries for the block grammar. pub const HIGHLIGHT_QUERY_BLOCK: &str = include_str!("../../tree-sitter-markdown/queries/highlights.scm"); + +/// The language injection queries for the block grammar. pub const INJECTION_QUERY_BLOCK: &str = include_str!("../../tree-sitter-markdown/queries/injections.scm"); + +/// The syntax highlighting queries for the inline grammar. pub const HIGHLIGHT_QUERY_INLINE: &str = include_str!("../../tree-sitter-markdown-inline/queries/highlights.scm"); + +/// The language injection queries for the inline grammar. pub const INJECTION_QUERY_INLINE: &str = include_str!("../../tree-sitter-markdown-inline/queries/injections.scm"); @@ -47,9 +54,11 @@ pub const NODE_TYPES_INLINE: &str = include_str!("../../tree-sitter-markdown-inline/src/node-types.json"); #[cfg(feature = "parser")] +#[cfg_attr(docsrs, doc(cfg(feature = "parser")))] mod parser; #[cfg(feature = "parser")] +#[cfg_attr(docsrs, doc(cfg(feature = "parser")))] pub use parser::*; #[cfg(test)] @@ -57,14 +66,18 @@ mod tests { use super::*; #[test] - fn can_load_grammar() { + fn can_load_block_grammar() { let mut parser = tree_sitter::Parser::new(); parser .set_language(&LANGUAGE.into()) - .expect("Error loading Markdown language"); - let mut inline_parser = tree_sitter::Parser::new(); - inline_parser + .expect("Error loading Markdown block grammar"); + } + + #[test] + fn can_load_inline_grammar() { + let mut parser = tree_sitter::Parser::new(); + parser .set_language(&INLINE_LANGUAGE.into()) - .expect("Error loading Markdown language"); + .expect("Error loading Markdown inline grammar"); } } diff --git a/bindings/rust/parser.rs b/bindings/rust/parser.rs index 126d07a..2fd8d5e 100644 --- a/bindings/rust/parser.rs +++ b/bindings/rust/parser.rs @@ -7,7 +7,7 @@ use crate::{INLINE_LANGUAGE, LANGUAGE}; /// A parser that produces [`MarkdownTree`]s. /// -/// This is a convenience wrapper around [`language`] and [`inline_language`]. +/// This is a convenience wrapper around [`LANGUAGE`] and [`INLINE_LANGUAGE`]. pub struct MarkdownParser { parser: Parser, block_language: Language, @@ -33,7 +33,7 @@ impl<'a> MarkdownCursor<'a> { } } - /// Returns `true` if the current node is from the (inline language)[inline_language] + /// Returns `true` if the current node is from the (inline language)[INLINE_LANGUAGE] /// /// This information is needed to handle "tree-sitter internal" data like /// [`field_id`](Self::field_id) correctly. @@ -180,6 +180,7 @@ impl<'a> MarkdownCursor<'a> { } } +/// An object that holds a combined markdown tree. #[derive(Debug, Clone)] pub struct MarkdownTree { block_tree: Tree, diff --git a/common/common.mak b/common/common.mak index 487ea03..7c33d58 100644 --- a/common/common.mak +++ b/common/common.mak @@ -2,7 +2,7 @@ ifeq ($(OS),Windows_NT) $(error Windows is not supported) endif -VERSION := 0.3.0 +VERSION := 0.3.1 # repository SRC_DIR := src diff --git a/package-lock.json b/package-lock.json index 8c920f8..d6604cb 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,24 +1,24 @@ { "name": "@tree-sitter-grammars/tree-sitter-markdown", - "version": "0.3.0", + "version": "0.3.1", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@tree-sitter-grammars/tree-sitter-markdown", - "version": "0.3.0", + "version": "0.3.1", "hasInstallScript": true, "license": "MIT", "dependencies": { - "node-addon-api": "^8.0.0", - "node-gyp-build": "^4.8.0" + "node-addon-api": "^8.1.0", + "node-gyp-build": "^4.8.1" }, "devDependencies": { - "prebuildify": "^6.0.0", + "prebuildify": "^6.0.1", "tree-sitter-cli": "^0.23.0" }, "peerDependencies": { - "tree-sitter": "^0.21.0" + "tree-sitter": "^0.21.1" }, "peerDependenciesMeta": { "tree_sitter": { @@ -96,15 +96,6 @@ "once": "^1.4.0" } }, - "node_modules/execspawn": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/execspawn/-/execspawn-1.0.1.tgz", - "integrity": "sha512-s2k06Jy9i8CUkYe0+DxRlvtkZoOkwwfhB+Xxo5HGUtrISVW2m98jO2tr67DGRFxZwkjQqloA3v/tNtjhBRBieg==", - "dev": true, - "dependencies": { - "util-extend": "^1.0.1" - } - }, "node_modules/fs-constants": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/fs-constants/-/fs-constants-1.0.0.tgz", @@ -177,17 +168,17 @@ } }, "node_modules/node-addon-api": { - "version": "8.0.0", - "resolved": "https://registry.npmjs.org/node-addon-api/-/node-addon-api-8.0.0.tgz", - "integrity": "sha512-ipO7rsHEBqa9STO5C5T10fj732ml+5kLN1cAG8/jdHd56ldQeGj3Q7+scUS+VHK/qy1zLEwC4wMK5+yM0btPvw==", + "version": "8.1.0", + "resolved": "https://registry.npmjs.org/node-addon-api/-/node-addon-api-8.1.0.tgz", + "integrity": "sha512-yBY+qqWSv3dWKGODD6OGE6GnTX7Q2r+4+DfpqxHSHh8x0B4EKP9+wVGLS6U/AM1vxSNNmUEuIV5EGhYwPpfOwQ==", "engines": { "node": "^18 || ^20 || >= 21" } }, "node_modules/node-gyp-build": { - "version": "4.8.0", - "resolved": "https://registry.npmjs.org/node-gyp-build/-/node-gyp-build-4.8.0.tgz", - "integrity": "sha512-u6fs2AEUljNho3EYTJNBfImO5QTo/J/1Etd+NVdCj7qWKUSN/bSLkZwhDv7I+w/MSC6qJ4cknepkAYykDdK8og==", + "version": "4.8.2", + "resolved": "https://registry.npmjs.org/node-gyp-build/-/node-gyp-build-4.8.2.tgz", + "integrity": "sha512-IRUxE4BVsHWXkV/SFOut4qTlagw2aM8T5/vnTsmrHJvVoKueJHRc/JaFND7QDDc61kLYUJ6qlZM3sqTSyx2dTw==", "bin": { "node-gyp-build": "bin.js", "node-gyp-build-optional": "optional.js", @@ -225,12 +216,11 @@ } }, "node_modules/prebuildify": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/prebuildify/-/prebuildify-6.0.0.tgz", - "integrity": "sha512-DEvK4C3tcimIp7Pzqbs036n9i6CTKGp1XVEpMnr4wV3enKU5sBogPP+lP3KZw7993i42bXnsd5eIxAXQ566Cqw==", + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/prebuildify/-/prebuildify-6.0.1.tgz", + "integrity": "sha512-8Y2oOOateom/s8dNBsGIcnm6AxPmLH4/nanQzL5lQMU+sC0CMhzARZHizwr36pUPLdvBnOkCNQzxg4djuFSgIw==", "dev": true, "dependencies": { - "execspawn": "^1.0.1", "minimist": "^1.2.5", "mkdirp-classic": "^0.5.3", "node-abi": "^3.3.0", @@ -369,12 +359,6 @@ "integrity": "sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw==", "dev": true }, - "node_modules/util-extend": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/util-extend/-/util-extend-1.0.3.tgz", - "integrity": "sha512-mLs5zAK+ctllYBj+iAQvlDCwoxU/WDOUaJkcFudeiAX6OajC6BKXJUa9a+tbtkC11dz2Ufb7h0lyvIOVn4LADA==", - "dev": true - }, "node_modules/wrappy": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", diff --git a/package.json b/package.json index 49c1b31..75cef40 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@tree-sitter-grammars/tree-sitter-markdown", - "version": "0.3.0", + "version": "0.3.1", "description": "Markdown grammar for tree-sitter", "repository": "github:tree-sitter-grammars/tree-sitter-markdown", "author": "MDeiml (https://github.com/MDeiml)", @@ -24,11 +24,11 @@ "common/html_entities.json" ], "dependencies": { - "node-addon-api": "^8.0.0", - "node-gyp-build": "^4.8.0" + "node-addon-api": "^8.1.0", + "node-gyp-build": "^4.8.1" }, "devDependencies": { - "prebuildify": "^6.0.0", + "prebuildify": "^6.0.1", "tree-sitter-cli": "^0.23.0" }, "peerDependencies": { diff --git a/pyproject.toml b/pyproject.toml index a5f3943..aef75b5 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -5,7 +5,7 @@ build-backend = "setuptools.build_meta" [project] name = "tree-sitter-markdown" description = "Markdown grammar for tree-sitter" -version = "0.3.0" +version = "0.3.1" keywords = ["incremental", "parsing", "tree-sitter", "markdown"] classifiers = [ "Intended Audience :: Developers", @@ -17,7 +17,7 @@ classifiers = [ authors = [ {name = "MDeiml"} ] -requires-python = ">=3.8" +requires-python = ">=3.9" license.text = "MIT" readme = "README.md" @@ -28,5 +28,5 @@ Homepage = "https://github.com/tree-sitter-grammars/tree-sitter-markdown" core = ["tree-sitter~=0.23"] [tool.cibuildwheel] -build = "cp38-*" +build = "cp39-*" build-frontend = "build" diff --git a/setup.py b/setup.py index aab1a7a..aac54d7 100644 --- a/setup.py +++ b/setup.py @@ -21,7 +21,7 @@ class BdistWheel(bdist_wheel): def get_tag(self): python, abi, platform = super().get_tag() if python.startswith("cp"): - python, abi = "cp38", "abi3" + python, abi = "cp39", "abi3" return python, abi, platform @@ -47,7 +47,7 @@ def get_tag(self): ["-std=c11"] if system() != "Windows" else [] ), define_macros=[ - ("Py_LIMITED_API", "0x03080000"), + ("Py_LIMITED_API", "0x03090000"), ("PY_SSIZE_T_CLEAN", None) ], include_dirs=["tree-sitter-markdown/src"],