-
-
Notifications
You must be signed in to change notification settings - Fork 878
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
Export parse_params()
for developers of functionality in third-party packages adjacient to {knitr}
#2112
Comments
Exporting the current I'll need to move some code from Anyway, I'm okay with exporting these low-level functions, but probably not very soon. |
Ok thanks, sounds good 👍 |
Actually, I feel that exporting |
Ok, I think I get what you mean now, i.e. if knitr:::parse_params("a=1, engine='Rcpp'")
#> $a
#> [1] 1
#>
#> $engine
#> [1] "Rcpp"
#>
#> $label
#> [1] "unnamed-chunk-3"
knitr:::parse_params("Rcpp, foo, a=1,")
#> $label
#> [1] "Rcpp, foo"
#>
#> $a
#> [1] 1 Created on 2022-03-10 by the reprex package (v2.0.1.9000) Is that the problem you said we'll encounter? Of course, if we can get knitr:::parse_params("Rcpp, foo, a=1,")
#> $engine
#> [1] "Rcpp"
#> $label
#> [1] "foo"
#>
#> $a
#> [1] 1 from |
If you only work with R Markdown documents, you can preprocess the chunk header before passing it to params = sub('^([a-zA-Z0-9_]+)(.*)$', 'engine="\\1",\\2', params) Yes, for R Markdown, you can safely assume the first string is always the engine. |
ok, great. Thanks for the regex. {styler} styles |
Great! Just a small correction: |
This old thread has been automatically locked. If you think you have found something related to this, please open a new issue by following the issue guide (https://yihui.org/issue/), and link to this old issue if necessary. |
By filing an issue to this repo, I promise that
xfun::session_info('knitr')
. I have upgraded all my packages to their latest versions (e.g., R, RStudio, and R packages), and also tried the development version:remotes::install_github('yihui/knitr')
.I understand that my issue may be closed if I don't fulfill my promises.
I'd ask you to export
parse_params()
so other projects that are adjacient to {knitr} can leverage that functionality in their developing efforts. This would most likely make the end user experience more consistent and reduce code duplication. In particular, in {styler}, we currently parse the parameters ourself to:Rcpp
engine? r-lib/styler#928, ignore knitr chunks that use a non-R engine such as sql r-lib/styler#312, Restriction on R Markdown chunk names r-lib/styler#831{knitr} already expors some functionality that most end users don't need, like
sew()
,all_patterns
and more, so exportingparse_params()
be in line with current API policies. There are most likely other packages that would benefit in the long run, plus the API of that function is probably quite established and stable.This came up in r-lib/styler#928.
The text was updated successfully, but these errors were encountered: