ropensci / spelling

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

urls are treated as spelling errors #21

Closed GregorDeCillia closed 5 years ago

GregorDeCillia commented 5 years ago

urls in markdown (md) documents are spell-checked in spell_check_files() and spell_check_package() as long as they have angle brackets around them. This is inconsistent with the behavior of links without angle brackets, which are not spellchecked.

Here is a repex where I create a markdown file from an rmarkdown file using rmarkdown::github_document().

writeLines(con = "test.Rmd", text = "
---
output: github_document
---

https://github.com/ropensci/spelling/issues/21
")

rmarkdown::render("test.Rmd", quiet = TRUE)

cat(readLines("test.md"), sep = "\n")
#> 
#> <https://github.com/ropensci/spelling/issues/21>

spelling::spell_check_files(c("test.md", "test.Rmd"))
#>   WORD       FOUND IN
#> github     test.md:2
#> https      test.md:2
#> ropensci   test.md:2

As we can see, only the urls in the .md file are spellchecked. If the angle brackets get removed, all spell checks pass.

library(magrittr)
readLines("test.md") %>% sub("<", "", .) %>% 
  sub(">", "", .) %>% writeLines("test.md")

spelling::spell_check_files(c("test.md", "test.Rmd"))
#> No spelling errors found.

It would be very handy if this could be fixed in the spelling package, since I am using rmarkdown::github_document() for most of my R packages and I don't see an elegant way to run spell_check_package() without getting spellcheck-warnings because of this behavior.

jeroen commented 5 years ago

It doesn't happen if you give the url a real text like this:

[issue #21](https://github.com/ropensci/spelling/issues/21)

Or if you want the text to be the actual link to you can wrap it in backticks:

[`https://github.com/ropensci/spelling/issues/21`](https://github.com/ropensci/spelling/issues/21)

But yes if you insert plain URLs in your text they are going to be spell checked...

GregorDeCillia commented 5 years ago

Thanks for letting me know. The workaround with the backticks looks good to me.