Skip to content

Commit

Permalink
Add support for spell checking quarto files (#78)
Browse files Browse the repository at this point in the history
  • Loading branch information
olivroy committed Jan 30, 2024
1 parent 92fbeb7 commit 17dc327
Show file tree
Hide file tree
Showing 8 changed files with 22 additions and 11 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,5 @@ Imports:
knitr
Suggests: pdftools
Roxygen: list(markdown = TRUE)
RoxygenNote: 7.2.3.9000
RoxygenNote: 7.3.1
Language: en-GB
4 changes: 4 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
dev

- Support for spellchecking on Quarto files (@olivroy, #77)

2.2.1
- Fix for commonmark 1.7.0 change for auto-linked markdown URLs

Expand Down
2 changes: 1 addition & 1 deletion R/check-files.R
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ spell_check_files <- function(path, ignore = character(), lang = "en_US"){
}

spell_check_file_one <- function(path, dict){
if(grepl("\\.r?md$",path, ignore.case = TRUE))
if(grepl("\\.r?q?md$",path, ignore.case = TRUE))
return(spell_check_file_md(path, dict = dict))
if(grepl("\\.rd$", path, ignore.case = TRUE))
return(spell_check_file_rd(path, dict = dict))
Expand Down
4 changes: 4 additions & 0 deletions R/parse-markdown.R
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@ parse_text_md <- function(path, extensions = TRUE, yaml_fields = c("title" ,"sub
# Strip bookdown text references, see: https://bookdown.org/yihui/bookdown/markdown-extensions-by-bookdown.html#text-references
values <- gsub("\\(ref:.*?\\)", "", values)

# Quarto references start with @, for example @sec-, @fig- @eq- etc. https://quarto.org/docs/authoring/cross-reference-options.html
# No special regex is necessary since all words containing @ are removed from
# spell check #9

data.frame(
text = values,
position = sourcepos,
Expand Down
4 changes: 2 additions & 2 deletions R/spell-check.R
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,9 @@ spell_check_package <- function(pkg = ".", vignettes = TRUE, use_wordlist = TRUE

if(isTRUE(vignettes)){
# Where to check for rmd/md files
vign_files <- list.files(file.path(pkg$path, "vignettes"), pattern = "\\.r?md$",
vign_files <- list.files(file.path(pkg$path, "vignettes"), pattern = "\\.q?r?md$",
ignore.case = TRUE, full.names = TRUE, recursive = TRUE)
root_files <- list.files(pkg$path, pattern = "(readme|news|changes|index).r?md",
root_files <- list.files(pkg$path, pattern = "(readme|news|changes|index).r?q?md",
ignore.case = TRUE, full.names = TRUE)

# Markdown vignettes
Expand Down
7 changes: 4 additions & 3 deletions man/spell_check_files.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions man/spell_check_package.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions man/wordlist.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 17dc327

Please sign in to comment.