knit_filter: Spell check filter for source documents

Description Usage Arguments Value Examples

View source: R/utils-vignettes.R

Description

When performing spell checking on source documents, we may need to skip R code chunks and inline R expressions, because many R functions and symbols are likely to be identified as typos. This function is designed for the filter argument of aspell() to filter out code chunks and inline expressions.

Usage

1
knit_filter(ifile, encoding = "unknown")

Arguments

ifile

Filename of the source document.

encoding

Encoding of ifile.

Value

A character vector of the file content, excluding code chunks and inline expressions.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
library(knitr)
knitr_example = function(...) system.file("examples", ..., package = "knitr")

if (Sys.which("aspell") != "") {
    # -t means the TeX mode
    utils::aspell(knitr_example("knitr-minimal.Rnw"), knit_filter, control = "-t")
    
    # -H is the HTML mode
    utils::aspell(knitr_example("knitr-minimal.Rmd"), knit_filter, control = "-H -t")
}

yihui/knitr documentation built on Dec. 14, 2018, 6:22 p.m.