Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace str_replace_all() with base equivalent #2174

Merged
merged 12 commits into from
Sep 28, 2022
3 changes: 2 additions & 1 deletion R/pattern.R
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ all_patterns = list(
`md` = list(
chunk.begin = '^[\t >]*```+\\s*\\{([a-zA-Z0-9_]+( *[ ,].*)?)\\}\\s*$',
chunk.end = '^[\t >]*```+\\s*$',
ref.chunk = '^\\s*<<(.+)>>\\s*$', inline.code = '(?<!(^|\n)``)`r[ #]([^`]+)`'),
ref.chunk = '^\\s*<<(.+)>>\\s*$',
inline.code = '(?<!(^``))(?<!(\n``))`r[ #]([^`]+)\\s*`'),

`rst` = list(
chunk.begin = '^\\s*[.][.]\\s+\\{r(.*)\\}\\s*$',
Expand Down
2 changes: 1 addition & 1 deletion R/utils-vignettes.R
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ knit_filter = function(ifile, encoding = 'UTF-8') {
m = group_indices(grepl(p1, x), grepl(p2, x))
i = m %% 2 == 0
x[i] = '' # remove code chunks
x[!i] = stringr::str_replace_all(x[!i], p$inline.code, '') # remove inline code
x[!i] = gsub(p$inline.code, '', x[!i], perl = TRUE) # remove inline code
structure(x, control = '-H -t')
}

Expand Down