diff --git a/scripts/spell-check.R b/scripts/spell-check.R index 189bd66..9bc82ae 100644 --- a/scripts/spell-check.R +++ b/scripts/spell-check.R @@ -42,17 +42,24 @@ files <- c(files, quiz_files) files <- grep("About.Rmd", files, ignore.case = TRUE, invert = TRUE, value = TRUE) files <- grep("style-sets", files, ignore.case = TRUE, invert = TRUE, value = TRUE) -# Run spell check -sp_errors <- spelling::spell_check_files(files, ignore = dictionary) - -if (nrow(sp_errors) > 0) { - sp_errors <- sp_errors %>% - data.frame() %>% - tidyr::unnest(cols = found) %>% - tidyr::separate(found, into = c("file", "lines"), sep = ":") -} else { - sp_errors <- data.frame(errors = NA) -} +tryCatch( + expr = { + # Run spell check + sp_errors <- spelling::spell_check_files(files, ignore = dictionary) + + if (nrow(sp_errors) > 0) { + sp_errors <- sp_errors %>% + data.frame() %>% + tidyr::unnest(cols = found) %>% + tidyr::separate(found, into = c("file", "lines"), sep = ":") + } else { + sp_errors <- data.frame(errors = NA) + } + }, + error = function(e){ + message("Spell check did not work. Check that your dictionary is formatted correctly. You cannot have special characters (e.g., DinĂ©) in the dictionary.txt file. You need to use HTML formatting (e.g., Diné) for these.") + } +) # Print out how many spell check errors write(nrow(sp_errors), stdout())