Skip to content
Permalink
Browse files

get_engine_pattern returns a constant.

  • Loading branch information...
lorenzwalthert committed Feb 9, 2018
1 parent 1e381d9 commit 87bebd4252506ad496ba3db27062e100de5635a5
Showing with 35 additions and 3 deletions.
  1. +15 −1 R/transform-code.R
  2. +18 −0 man/get_engine_pattern.Rd
  3. +1 −1 man/identify_r_raw_chunks.Rd
  4. +1 −1 man/separate_chunks.Rd
@@ -64,7 +64,7 @@ separate_chunks <- function(lines) {
#' whose name matches `engine-pattern` are considered as R code.
#' @inheritParams separate_chunks
#' @param engine_pattern A regular expression that must match the engine name.
identify_r_raw_chunks <- function(lines, engine_pattern = "[rR]") {
identify_r_raw_chunks <- function(lines, engine_pattern = get_engine_pattern()) {
pattern <- get_knitr_pattern(lines)
if (is.null(pattern$chunk.begin) || is.null(pattern$chunk.end)) {
stop("Unrecognized chunk pattern!", call. = FALSE)
@@ -83,6 +83,20 @@ identify_r_raw_chunks <- function(lines, engine_pattern = "[rR]") {
list(starts = starts[is_r_code], ends = ends[is_r_code])
}

#' What's the engine pattern for rmd code chunks?
#'
#' The function returns the regular expression pattern that identifies
#' all r engines in Rmd chunks. Defaults to `[Rr]`. You probably only want to
#' change this if you create a knitr engine that processes R code but is not
#' the default engine `r`.
#' The pattern must be followed by a space (in the case the chunk is given
#' a name), a comma (if no name is given but further options are passed to the
#' engine) or a closing curly brace (in case no option and no name is given to
#' the chunk).
get_engine_pattern <- function() {
"[rR]"
}

#' Get chunk pattern
#'
#' Determine a regex pattern for identifying R code chunks.

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.

0 comments on commit 87bebd4

Please sign in to comment.
You can’t perform that action at this time.