From d9bef1563933bdb358a44a1ba19ee60108519a94 Mon Sep 17 00:00:00 2001 From: AM Hoffman Date: Wed, 31 Jan 2024 16:36:39 -0500 Subject: [PATCH 1/2] Add accent debugging to spell check MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Was getting some confusing errors when adding words with accents to dictionary.txt. It wouldn't run, and I wasn't sure why :) In other words, "ó" in the dictionary.txt file was causing the spell check to break. Added some messaging to try to make this easier to diagnose from the Actions log. --- scripts/spell-check.R | 29 ++++++++++++++++++----------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/scripts/spell-check.R b/scripts/spell-check.R index 189bd66..6d0a768 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., ó) in the dictionary.txt file. You need to use TeX formatting (e.g., \\'{o}) for these.") + } +) # Print out how many spell check errors write(nrow(sp_errors), stdout()) From c9dbe50286d2fd4154f57b40900ececb3cae7758 Mon Sep 17 00:00:00 2001 From: AM Hoffman Date: Wed, 31 Jan 2024 16:51:50 -0500 Subject: [PATCH 2/2] swap for HTML not tex --- scripts/spell-check.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/spell-check.R b/scripts/spell-check.R index 6d0a768..9bc82ae 100644 --- a/scripts/spell-check.R +++ b/scripts/spell-check.R @@ -57,7 +57,7 @@ tryCatch( } }, error = function(e){ - message("Spell check did not work. Check that your dictionary is formatted correctly. You cannot have special characters (e.g., ó) in the dictionary.txt file. You need to use TeX formatting (e.g., \\'{o}) for these.") + 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.") } )