3 ms·
Does tree-sitter support nested languages? E.g. Javascript or CSS within HTML within Javadoc within Java source code?
by layer8 5y ago
Does tree-sitter support nested languages? E.g. Javascript or CSS within HTML within Javadoc within Java source code?
- siraben 5y agoYes, this is possible with language injection[0] [0] https://tree-sitter.github.io/tree-sitter/syntax-highlighting#language-injection https://tree-sitter.github.io/tree-sitter/syntax-highlightin...
- chrismorgan 5y agoDoes this cover things like separating leading /// comment indicators? That’s something Vim’s :syn-include can’t cope with. /// This is Markdown-in-Rust. /// /// ```rust /// // This is Rust-in-Markdown-in-Rust. /// /// This is Markdown-in-Rust-in-Markdown-in-Rust. /// const RUST_IN_MARKDOWN_IN_RUST: &'static str = " /// In this multi-line string (as the most common example of such token-mixing), /// those triple slashes are Comment, not String."; /// // And if Trait and Type get parsed carefully below, the /// must not interrupt that. /// impl /// Trait /// for /// Type {} /// ``` struct ThisIsRust; The remark about injection.include-children in your link suggests it can, but I don’t know enough about it yet to be confident of that preliminary assessment.