ropensci / spelling

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

Add support for spell checking quarto files #78

Closed olivroy closed 8 months ago

olivroy commented 8 months ago

Fix #77

A reprex that includes cross-references as well

temp_file <- tempfile(fileext = ".qmd")
writeLines(
    "
This is correct.
This is an eeerrrooorrr.
# Header
```{r}
#| label: fig-weirdooo
#| fig-cap: Will not detect errrors here, but it is a good enough start
foooo <- function() TRUE
foooo()

This is @fig-weirdooo for thiiis ", temp_file )

spelling::spell_check_files(temp_file) WORD FOUND IN eeerrrooorrr file4d5c1a4c6c37.qmd:2 thiiis file4d5c1a4c6c37.qmd:10

jeroen commented 8 months ago

Are you sure that regex "\\@\\(\\w+\\-.*?\\)" is correct? In your example the @fig-weirdooo does not have parentheses?

olivroy commented 8 months ago

You are right, changed it to \\@\\w+\\-[[:graph:]]+ as it can be @fig-w-s (so anything but space)

jeroen commented 8 months ago

I am trying to think of false positives we can get with that regex. For example an email address: jeroen@r-universe.dev will lose the last part and then just become jeroen. I am not sure if that is worse or not, I don't remember if/how we currently filter email addresses.

olivroy commented 8 months ago

Maybe values <- gsub("\\s\\@\\w+\\-[[:graph:]]+", " ", values)?

Currently, email addresses are not spell-checked, I think

Since 2.0 :

So my regex is actually useless here, it seems

jeroen commented 8 months ago

Yeah we already have this: https://github.com/ropensci/spelling/commit/a22366a4c55539c9f2a8d80df4b5efc0ed82f37c

I think that would already filter out cross references, so you can probably just remove your custom filter? Can you test this?

olivroy commented 8 months ago

All good without it. I added a comment for posterity.

jeroen commented 8 months ago

Thank you

pawelru commented 7 months ago

Thank you guys for this PR! Much appreciated!

@jeroen would you consider to release to CRAN anytime soon? I think that this would be a nice enhancement for the whole community given increasing popularity of Quarto. There is even some advanced progress of package vignettes in .qmd format so this is not only for book type of projects but also packages.

jeroen commented 7 months ago

Ok i have released a new version to CRAN now.