Skip to content
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

Add support for spell checking quarto files #78

Merged
merged 4 commits into from
Jan 30, 2024
Merged

Conversation

olivroy
Copy link
Contributor

@olivroy olivroy commented Jan 30, 2024

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
Copy link
Member

jeroen commented Jan 30, 2024

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

@olivroy
Copy link
Contributor Author

olivroy commented Jan 30, 2024

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

@jeroen
Copy link
Member

jeroen commented Jan 30, 2024

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
Copy link
Contributor Author

olivroy commented Jan 30, 2024

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

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

Since 2.0 :

  • Markdown: filter words that contain an '@' symbol (citation key or email address)

So my regex is actually useless here, it seems

@jeroen
Copy link
Member

jeroen commented Jan 30, 2024

Yeah we already have this: a22366a

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

@olivroy
Copy link
Contributor Author

olivroy commented Jan 30, 2024

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

@jeroen jeroen merged commit 17dc327 into ropensci:master Jan 30, 2024
5 checks passed
@jeroen
Copy link
Member

jeroen commented Jan 30, 2024

Thank you

@olivroy olivroy deleted the qmd branch January 30, 2024 19:36
@pawelru
Copy link

pawelru commented Mar 4, 2024

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
Copy link
Member

jeroen commented Mar 5, 2024 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[feature request] .qmd (quarto) format
3 participants