diff --git a/NEWS b/NEWS index 4f53876..e18649c 100644 --- a/NEWS +++ b/NEWS @@ -1,3 +1,6 @@ +2.2 + - spell_check_package() now loads Rd macros (#42) + 2.1 - Pre-filter script/style/img tags when checking html files because the huge embedded binary blogs produced by rmarkdown slow down the hunspell parser. diff --git a/R/check-files.R b/R/check-files.R index c6d8dd4..526ea1c 100644 --- a/R/check-files.R +++ b/R/check-files.R @@ -86,10 +86,10 @@ spell_check_description_text <- function(file, dict){ } spell_check_file_rd <- function(rdfile, macros = NULL, dict) { - if (is.null(macros)) { - text <- tools::RdTextFilter(rdfile) + text <- if (!length(macros)) { + tools::RdTextFilter(rdfile) } else { - text <- tools::RdTextFilter(rdfile, macros = macros) + tools::RdTextFilter(rdfile, macros = macros) } Encoding(text) <- "UTF-8" spell_check_plain(text, dict = dict) diff --git a/R/spell-check.R b/R/spell-check.R index 0630c58..9274f43 100644 --- a/R/spell-check.R +++ b/R/spell-check.R @@ -54,10 +54,9 @@ spell_check_package <- function(pkg = ".", vignettes = TRUE, use_wordlist = TRUE # Check Rd manual files rd_files <- sort(list.files(file.path(pkg$path, "man"), "\\.rd$", ignore.case = TRUE, full.names = TRUE)) - macros <- tools::loadPkgRdMacros(pkg$path) macros <- tools::loadRdMacros( file.path(R.home("share"), "Rd", "macros", "system.Rd"), - macros = macros + tools::loadPkgRdMacros(pkg$path) ) rd_lines <- lapply(rd_files, spell_check_file_rd, dict = dict, macros = macros)