R/spell.R

Defines functions spell

Documented in spell

#' spell
#'
#' Perform a spell check on RMarkdown files ignoring some `exams` keywords using [spelling::spell_check_files()].
#' 
#' @inheritParams spelling::spell_check_files
#'
#' @return a data frame with problematic words
#' @importFrom spelling spell_check_files
#' @export
#'
#' @examples
#' # none
spell <- function(path, ignore=c(
  "Meta", "information", "extype", "num", "mchoice", "schoice",
  "Solution", "exsolution", "extol", "exname", "Question",         # keywords exams
  "align", "begin", "bigg", "cases", "cdot", "end", "frac", 
  "infty", "int", "left", "left.", "leq", "mu", "qquad", "right",
  "sum", "text", "vert"                                            # keywords LaTeX
  ),
                  lang = Sys.getenv("LANG")) {
  lang <- strsplit(lang, "[^A-Za-z]")[[1]]
  if (length(lang)>1) lang <- paste0(lang[1:2], collapse='_')
  spelling::spell_check_files(path, ignore, lang)
}
sigbertklinke/exams2moodle documentation built on July 6, 2023, 3:26 p.m.