ropensci / spelling

Tools for Spell Checking in R
https://docs.ropensci.org/spelling
Other
105 stars 27 forks source link

Error in sub(dest, "", xml2::xml_text(node), fixed = TRUE) : zero-length pattern #72

Closed drmowinckels closed 1 year ago

drmowinckels commented 1 year ago

I have a package where spelling has been running spell checks for a while with no problem. I'm working on an update and I'm getting some strange spelling behaviour and I can't seem to find the origin of it.

It fails during builds:

> if(requireNamespace('spelling', quietly = TRUE))
+   spelling::spell_check_test(vignettes = TRUE,
+                              error = FALSE,
+                              skip_on_cran = TRUE)
Error in sub(dest, "", xml2::xml_text(node), fixed = TRUE) : 
  zero-length pattern
Calls: <Anonymous> ... lapply -> FUN -> <Anonymous> -> xml_text<-.xml_node -> sub
Execution halted

But runs just fine interactively, returning NULL.

I thought maybe there was an issue in my wordlist, so I deleted it, but same issue persists. Lastly, I thought i'd re-initiate it in case there was some old-timey setup issue. But even setting it up causes the error. Tried the same with the full path but got the same error.

> spelling::spell_check_setup(".")
Error in sub(dest, "", xml2::xml_text(node), fixed = TRUE) : 
  zero-length pattern

I belive this code is where its erroring: https://github.com/ropensci/spelling/blob/008417f4e77a5e86c8d85e85701c59da4010e11b/R/parse-markdown.R#L31

Though, unsure how/why or why it suddenly started complaining when it did not before.

Suggestions welcome

jeroen commented 1 year ago

Do you have an example that I can use to reproduce the problem?

drmowinckels commented 1 year ago

I know an entire repo is a shit example, but its: https://github.com/LCBC-UiO/nettskjemar/

both master and labels branch have this behaviour.

I can give a go at a minimal reprex tomorrow.

jeroen commented 1 year ago

The problem was triggered by the empty usethis hyperlink in this line in your vignette:

We recommend using a function from the [usethis]() package to edit your `.Renviron` file.

I am not sure if empty hyperlinks are valid markdown (the link has no destination?) but I added a workaround in spelling so it does not trip over this anymore.

Thanks!

drmowinckels commented 1 year ago

thanks! It was a placeholder for me to remember to put it in there at some point (and then forgot...) I was looking at links in all other places than vignettes!!! But if you anyway thought it meaningful enough to make a workaround, I guess that's a good find :P