Skip to contents

Perform a spell check on document files or plain text.

Usage

spell_check_files(path, ignore = character(), lang = "en_US")

spell_check_text(text, ignore = character(), lang = "en_US")

Arguments

path

path to file or to spell check

ignore

character vector with words which will be added to the hunspell::dictionary

lang

set Language field in DESCRIPTION e.g. "en-US" or "en-GB". For supporting other languages, see the hunspell vignette.

text

character vector with plain text

Details

This function parses a file based on the file extension, and checks only text fields while ignoring code chunks and meta data. It works particularly well for markdown, but also latex, html, xml, pdf, and plain text are supported.

For more information about the underlying spelling engine, see the hunspell package.

See also

Other spelling: spell_check_package(), wordlist

Examples

# Example files
files <- list.files(system.file("examples", package = "knitr"),
  pattern = "\\.(Rnw|Rmd|html)$", full.names = TRUE)
spell_check_files(files)
#>   WORD                  FOUND IN
#> Beamer                knitr-beamer.Rnw:49,70,72
#> CairoJPEG             knitr-manual.Rnw:263
#> CairoPNG              knitr-graphics.Rnw:82
#> FragileFrame          knitr-beamer.Rnw:49,71
#> GGobi                 knitr-graphics.Rnw:46,341,400
#> Maruko                knitr-graphics.Rnw:213
#> Noweb                 knitr-manual.Rnw:61
#> RData                 knitr-manual.Rnw:423
#> RStudio               knitr-manual.Rnw:648
#> Ramnath               knitr-manual.Rnw:244
#> Rnw                   knitr-graphics.Rnw:48
#>                       knitr-input.Rnw:11
#>                       knitr-manual.Rnw:120,533,545,553,660,667
#>                       knitr-minimal.Rnw:52
#>                       knitr-subfloats.Rnw:53
#>                       knitr-twocolumn.Rnw:64
#> Sexpr                 knitr-beamer.Rnw:95
#>                       knitr-manual.Rnw:159,199
#> StackOverflow         knitr-manual.Rnw:386
#> SweaveDrivers         knitr-manual.Rnw:73
#> Texmaker              knitr-manual.Rnw:653
#> Vaidyanathan          knitr-manual.Rnw:244
#> WinEdt                knitr-manual.Rnw:653
#> Xie                   knitr-beamer.Rnw:51
#>                       knitr-listings.Rnw:28
#>                       knitr-manual.Rnw:54
#>                       knitr-minimal.Rnw:28
#>                       knitr-subfloats.Rnw:32
#>                       knitr-twocolumn.Rnw:39
#> Yihui                 knitr-beamer.Rnw:51
#>                       knitr-listings.Rnw:28
#>                       knitr-manual.Rnw:54
#>                       knitr-minimal.Rnw:28
#>                       knitr-subfloats.Rnw:32
#>                       knitr-twocolumn.Rnw:39
#> abc                   knitr-manual.Rnw:441
#> accumulatively        knitr-manual.Rnw:296
#> andre                 knitr-manual.Rnw:242
#> asis                  knitr-graphics.Rnw:128,160
#>                       knitr-manual.Rnw:325,326,333
#> autodep               knitr-manual.Rnw:491,505
#> cacheSweave           knitr-manual.Rnw:192,421,424,429,451,483
#> cairoDevice           knitr-graphics.Rnw:81
#> chunkA                knitr-manual.Rnw:485,486
#> chunkB                knitr-manual.Rnw:485,486
#> codetools             knitr-manual.Rnw:496
#> de                    knitr-manual.Rnw:242
#> dep                   knitr-manual.Rnw:491,508,512
#> dependson             knitr-manual.Rnw:140,483,485,486
#> dev                   knitr-graphics.Rnw:54,55
#>                       knitr-manual.Rnw:94,261,262,263,370
#> dothis                knitr-manual.Rnw:580,586,587,594,601,607,608,609
#> edu                   knitr-manual.Rnw:61
#> eval                  knitr-manual.Rnw:575,586,594,605,607,609
#> filehash              knitr-manual.Rnw:423,425
#> findGlobals           knitr-manual.Rnw:496
#> formatR               knitr-manual.Rnw:207,237,239
#> getOption             knitr-manual.Rnw:446
#> ggobi                 knitr-graphics.Rnw:341
#> ggplot                knitr-graphics.Rnw:108,177,283,325,397
#>                       knitr-manual.Rnw:90,92
#> github                knitr-manual.Rnw:244
#> globals               knitr-manual.Rnw:508
#> googlegroups          knitr-manual.Rnw:678
#> grDevices             knitr-graphics.Rnw:80
#> grdevice              knitr-manual.Rnw:261
#> highr                 knitr-manual.Rnw:206
#>                       knitr-themes.Rnw:42,43
#> http                  knitr-manual.Rnw:60,61,242,344
#> https                 knitr-manual.Rnw:119,122,141,244,417,652,653
#> hyperref              knitr-graphics.Rnw:399
#> includegraphics       knitr-manual.Rnw:313
#> jpeg                  knitr-manual.Rnw:259
#> knitr                 knitr-beamer.Rnw:49,56,63,67,70,72
#>                       knitr-graphics.Rnw:42,43,53,89,141,277,288
#>                       knitr-input.Rnw:10,11
#>                       knitr-listings.Rnw:26,31,85
#>                       knitr-manual.Rnw:52,64,75,76,88,101,113,118,119,122,135,141,158,162,183,185,191,212,241,244,250,260,291,312,341,367,373,378,383,417,425,451,452,456,471,505,525,529,564,573,578,605,616,636,642,648,649,652,653,658,659,678
#>                       knitr-minimal.Rmd:3,59
#>                       knitr-minimal.Rnw:26,31
#>                       knitr-spin.Rmd:33,50
#>                       knitr-subfloats.Rnw:30,48,52
#>                       knitr-themes.Rnw:39,42,66
#>                       knitr-twocolumn.Rnw:37
#> labelled              knitr-manual.Rnw:531
#> lazyLoad              knitr-manual.Rnw:427
#> linewidth             knitr-manual.Rnw:363
#>                       knitr-subfloats.Rnw:44
#> literateprogramming   knitr-manual.Rnw:60
#> lm                    knitr-graphics.Rnw:245
#> lp                    knitr-graphics.Rnw:266,270
#> lstlisting            knitr-manual.Rnw:173
#> mailto                knitr-manual.Rnw:678
#> makeLazyLoadDB        knitr-manual.Rnw:426
#> mfrow                 knitr-graphics.Rnw:107
#> newpage               knitr-graphics.Rnw:91
#> noweb                 knitr-manual.Rnw:61
#> nr                    knitr-manual.Rnw:61
#> packageVersion        knitr-graphics.Rnw:43
#>                       knitr-manual.Rnw:659
#>                       knitr-subfloats.Rnw:52
#> pdfcrop               knitr-graphics.Rnw:287,288,323,400
#> pgfSweave             knitr-manual.Rnw:192,369,374,449
#> png                   knitr-manual.Rnw:259,262,263
#> pre                   knitr-themes.Rnw:67
#> prev                  knitr-manual.Rnw:512
#> propto                knitr-minimal.Rmd:38
#> qplot                 knitr-manual.Rnw:100
#> ramnathv              knitr-manual.Rnw:244
#> recordPlot            knitr-graphics.Rnw:92,330
#> recordedplot          knitr-manual.Rnw:147
#> rggobi                knitr-graphics.Rnw:342,397
#> rgl                   knitr-graphics.Rnw:46,331,373,375,376,377,380,387,397
#>                       knitr-manual.Rnw:618,619,620,628
#> rnw                   knitr-manual.Rnw:121
#> roxygen               knitr-spin.Rmd:1
#> scap                  knitr-graphics.Rnw:266
#> setHook               knitr-graphics.Rnw:92
#> simon                 knitr-manual.Rnw:242
#> solarized             knitr-themes.Rnw:51,74
#> standAlone            knitr-manual.Rnw:375
#> subfloat              knitr-subfloats.Rnw:39,46,56
#> subfloats             knitr-subfloats.Rnw:30,36
#> textwidth             knitr-manual.Rnw:91,103
#> tikz                  knitr-graphics.Rnw:45,55,56,57,58,228,230,257
#>                       knitr-manual.Rnw:93,94,191,365,368,370,372,373,375,379,381,397,405,408,410
#> tikzDefaultEngine     knitr-graphics.Rnw:250
#> tikzDevice            knitr-graphics.Rnw:242,250,397,398
#>                       knitr-manual.Rnw:93,368,371,405
#> tokenizes             knitr-themes.Rnw:44
#> toolset               knitr-listings.Rnw:44
#> tufte                 knitr-graphics.Rnw:399
#> uncached              knitr-manual.Rnw:468
#> usepackage            knitr-manual.Rnw:340
#> wikipedia             knitr-manual.Rnw:344
#> www                   knitr-manual.Rnw:60,61,242
#> xie                   knitr-manual.Rnw:532
#> yihui                 knitr-manual.Rnw:119,122,141,417,652,653
#> π                    knitr-minimal.Rmd:33