-
Notifications
You must be signed in to change notification settings - Fork 30
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
how do you deal with string interpolations? #488
Comments
Hej, thanks for this issue! The team is currently on holiday, but I will discuss with them when they return tomorrow! |
Hi @BrianHicks, thanks for the issue indeed! echo '"1 plus 1 is #{2}, 1+1=#{2}"' | RUST_LOG=debug topiary --language rust -sf /dev/stdin Also, as a side note about your query file, the rule (
(string) @append_hardline
.
(comment)? @do_nothing
)
This query will match on any |
I get an error when I run that: "error: invalid value 'rust' for '--language '". Same if I try with As I've shown above with another tree-sitter tool, the whitespace is included in the |
@BrianHicks I did mean I managed to track down the source of your issue to #492, we'll work on that. |
How do you get that Thanks for finding #492! |
The |
As I mentioned in #481, I'm making a toy formatter for Ruby just to learn how this all works. I have a question about how you'd preserve spaces in interpolated strings.
The Ruby grammar has
string
s withstring_content
andinterpolation
nodes that can live inside them. Thestring_content
frequently has whitespace at either end. How do I preserve that? For example, here's an input string:"1 plus 1 is #{2}, 1+1=#{2}"
If I have these rules:
Then it's formatted like so, when I would want it to be left exactly as it was:
"1 plus 1 is#{2}, 1+1=#{2}"
(Doing
(string_content) @leaf
does the same thing, by the way.)Is there a way to turn off formatting within some node, but only for its immediate children? Or to declare that some child gets a pass and that space within the text content of that node should be included? (Examining the nodes with
tree-grepper
shows that this is the case; I've attached it below.) Maybe something with a name like@append_preserve_whitespace
/@prepend_preserve_whitespace
?The text was updated successfully, but these errors were encountered: