tree-sitter-razor-modern
v0.1.0
Published
Tree-sitter grammar for ASP.NET Core Razor markup (.cshtml and .razor)
Maintainers
Readme
tree-sitter-razor-modern
A tree-sitter grammar for ASP.NET Core Razor markup (.cshtml and .razor).
This project is a maintained fork of
tris203/tree-sitter-razor, licensed under MIT. Embedded C# is
parsed by the C# grammar's own rules, so node kinds inside code blocks match tree-sitter-c-sharp.
Using it
cargo add tree-sitter tree-sitter-razor-modernlet mut parser = tree_sitter::Parser::new();
let language = tree_sitter_razor::LANGUAGE;
parser
.set_language(&language.into())
.expect("Error loading ASP.NET Core Razor markup (`.cshtml` and `.razor`) parser");npm install tree-sitter-razor-modernimport Parser from 'tree-sitter';
import Language from 'tree-sitter-razor-modern';
const parser = new Parser();
parser.setLanguage(Language);A GitHub Packages copy is also published as @meloncholera/tree-sitter-razor-modern.
Building
npm install --ignore-scripts
npx --yes [email protected] -- tree-sitter generate
cargo buildThe generated parser (src/parser.c, src/grammar.json, and src/node-types.json) is committed.
Regenerate and commit the diff after every grammar.js change.
Testing
CC=gcc CXX=g++ npx --yes [email protected] -- tree-sitter test
cargo testOn Windows without MSVC, set CC and CXX to an installed GCC-compatible toolchain.
