tree-sitter-templ
tree-sitter-templ copied to clipboard
bug/feat?: script_element_text range
HTML raw_text vs Templ script_element_text AST
It seems the scanner for SCRIPT_ELEMENT_TEXT
doesn't include the leading whitespace on the first element's line. I'm trying to use conform.nvim's injected language formatting, and this is seemingly what's causing issues for me. The first line doesn't get indented properly.
I can work around this by wrapping the text with brackets like so:
<script>{
console.log("Test");
console.log("Test");
console.log("Test");
console.log("Test");
}</script>
Not sure if a fix for this is entirely necessary, but I figured I'd ask about it. The grammer.js file is making sense to me, it's just been a while since I've written c, so figuring out exactly what would need to change in the scanner is tough.
Hi.
sorry for not responding earlier, personal stuff has been getting in the way lately.
I'll try to look into this sometime this or next week.
Hi. Super late but I took a quick look.
The scanner removes leading whitespaces here.
If I comment ou this code it looks like the node script_element_text
does contain the whitespaces, so this could fix your issue, however doing this breaks a lot of tests so it's not that simple.
I don't know or use conform.nvim
so I'm not going to investigate further, sorry.
I'm not against modifying the behaviour regarding whitespaces but someone else will have to submit a PR for this.