-
Notifications
You must be signed in to change notification settings - Fork 185
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 in glue() range causes parse failure in object_usage_linter #1919
Comments
The trouble is here: Line 191 in c69f792
What we'd ideally do is exclude any @jimhester could you offer some guidance/ Related again to r-lib/xml2#341 (comment) :) |
I would use something like this to get just the text in the STR_CONST nodes, rather than any node type. xml2::xml_text(xml2::xml_find_first(glue_calls, "//STR_CONST/text()")) |
This will break glue calls with multiple fragments, e.g. glue::glue(
"This is the first glued line with 1 + 1 = {1 + 1}\n",
"This is the second line with pi = {pi}"
) |
and a find_all approach will also have to ignore keyword arguments. I think it's doable but feels like a workaround /much messier than |
Do you think it might be feasible to instead develop a |
not a bad idea, this thing with comments definitely comes up here & there |
paste0(collapse = "", xml2::xml_text(xml2::xml_find_all(glue_calls, "./*[not(self::COMMENT)]"))) |
ah, great minds :) xml <- parse(text = "glue(\n'{x}' # comment\n)") |>
xml_parse_data() |>
read_xml()
xml_node2lang <- function(x) {
x |>
xml_find_all(".//*[not(self::COMMENT or self::expr)]") |>
xml_text() |>
paste(collapse = "") |>
str2lang()
}
if (inherits(xml, "xml_document")) {
# not xml_children, since xml_node2lang() will fail for comments: str2lang("")
lapply(xml_find_all(xml, "*[not(self::COMMENT)]"), xml_node2lang)
} else {
xml_node2lang(xml)
}
glue(
format(
Sys.Date(),
"%F {x}" # YYYY-MM-DD, then 'x'
)
) |
The text was updated successfully, but these errors were encountered: