-
Notifications
You must be signed in to change notification settings - Fork 64
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
Comment inside {} suppresses output #224
Comments
This seems to be a case that is not properly handled, the code assumes comment lines will always end with a newline. e.g. this works glue::glue("pre {1+5 # never mind me
} post")
#> pre 6 post Created on 2021-09-13 by the reprex package (v2.0.0) |
That makes sense. Doe you think it would make sense to "fix" this for the case without a newline? Would you review a PR for this? |
yeah |
Now I am not sure anymore how to "fix" this. E.g. this seems fine, and we probably don't want to look for closing delims eagerly: ❯ glue::glue("pre {1 + 5 + # never mind the }\n 4} post")
pre 10 post OTOH the original example surely does not make sense, so maybe that should be an error? I.e. if the string ends in |
Instead of generating an empty string. Closes #224.
Yeah, I think if we end in a comment state making that an error makes sense to me |
The URI template spec supports [fragment identifiers](https://datatracker.ietf.org/doc/html/rfc6570#section-3.2.4) by expanding a template like `{#var}`. Glue interprets the hash char as a comment as it's inside curly braces. [A recent change to glue](tidyverse/glue#224) flushed this out. This patch rewrites the template as `#{var}`. This has the desired effect when the value is present but doesn't conform with the spec properly as the whole fragment (including the `#`) should be omitted. This is raised in #4.
I realize this is an edge case, and you probably would not write code like this, but it may happen if the code within
{}
is machine-generated:It is not entirely straightforward what the output should be, maybe the interpolation should end at
}
, and it then it would be"pre 6 post"
?The text was updated successfully, but these errors were encountered: