diff --git a/R/parser.R b/R/parser.R index d6aa4a5467..aa69e5ec0a 100644 --- a/R/parser.R +++ b/R/parser.R @@ -566,6 +566,12 @@ match_chunk_end = function(pattern, line, i, b, lines, signal = stop) { if (!any(match_chunk_begin(pattern, lines[i + 1:(k - 1)], '^\\1`*\\\\{'))) return(FALSE) } + # TODO: for now we only disallow unmatched indentation during R CMD check + # that's not running on CRAN; we will fully disallow it in the future (#2057) + p = gsub('\\^\\s+', '', pattern) + if (grepl(p, line) && (is_cran() || is_bioc()) && identical(signal, stop2)) { + signal = warning2 + } signal( 'The starting backticks on line ', i, ' ("', line, '") in ', current_input(), ' do not match the chunk header, which starts with "', diff --git a/R/utils.R b/R/utils.R index 73e51d9026..0795a79396 100644 --- a/R/utils.R +++ b/R/utils.R @@ -177,6 +177,8 @@ is_cran_check = function() { is_cran() && is_R_CMD_check() } +is_bioc = function() Sys.getenv('BBS_HOME') != '' + # round a number to getOption('digits') decimal places by default, and format() # it using significant digits if the option knitr.digits.signif = TRUE round_digits = function(x) {