tree-sitter-grammars / tree-sitter-markdown

Markdown grammar for tree-sitter
MIT License
427 stars 56 forks source link

bug: Using environment variables for conditional compilation breaks use as a Rust library #172

Open tv42 opened 2 weeks ago

tv42 commented 2 weeks ago

Did you check existing issues?

Tree-Sitter CLI Version, if relevant (output of tree-sitter --version)

No response

Describe the bug

Using tree-sitter-md crate directly as a Rust library is pleasant and enables binaries that don't depend on global system state like installed helper binaries. That's promising and great.

However, enabling extensions via compile-time environment variables is just not viable; cargo build && EXTENSION_TAGS=1 cargo build does not magically trigger a rebuild of dependencies with the feature enabled.

How should I use the tree-sitter-md crate if I need to parse tags?

Steps To Reproduce/Bad Parse Tree

n/a

Expected Behavior/Parse Tree

n/a

Repro

No response

tv42 commented 2 weeks ago

I think it should be possible to define Cargo features for the crate, and then get build.rs to set env variables for the C compilation based on the enabled features.

ObserverOfTime commented 2 weeks ago

Building with different extensions requires the Tree-sitter CLI and Node.js.