Skip to content

Commit

Permalink
Make .onLoad() more robust w.r.t. knitr (#254)
Browse files Browse the repository at this point in the history
* Dummy commit to kick GHA

* Ensure knitr::knit_engines is accessible

* Remove dummy comment

* Add NEWS bullet

Also retroactively modify earlier bullet that under-describes a change in 1.5.1
  • Loading branch information
jennybc authored Jan 21, 2022
1 parent 76793ef commit 736fc9e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
4 changes: 3 additions & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# glue (development version)

* glue now registers its custom knitr engines in a way that is more robust to namespace-loading edge cases that can arise during package installation (#254).

# glue 1.6.0

* `glue()`, `glue_data()`, `glue_col()`, and `glue_data_col()` gain a new `.literal` argument, which controls how quotes and the comment character are treated when parsing the expression string (#235). This is mostly useful when using a custom transformer.
Expand All @@ -10,7 +12,7 @@

* Jennifer Bryan is now the maintainer.

* The existing custom language engines for knitr, `glue` and `glue_sql`, are documented in a new vignette (#71).
* The existing custom language engines for knitr, `glue` and `glue_sql`, are documented in a new vignette (#71). *Detail added after release: glue now sets up registration of these engines in `.onLoad()`.*

* `glue_col()` gives special treatment to styling functions from the crayon package, e.g. `glue_col("{blue foo}")` "just works" now, even if crayon is not attached (but is installed) (#241).

Expand Down
3 changes: 2 additions & 1 deletion R/zzz.R
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
s3_register("vctrs::vec_cast", "character.glue")
s3_register("vctrs::vec_cast", "glue.character")

if (isNamespaceLoaded("knitr")) {
if (isNamespaceLoaded("knitr") &&
"knit_engines" %in% getNamespaceExports("knitr")) {
knitr::knit_engines$set(glue = eng_glue, glue_sql = eng_glue_sql, gluesql = eng_glue_sql)
} else {
setHook(packageEvent("knitr", "onLoad"), function(...) {
Expand Down

0 comments on commit 736fc9e

Please sign in to comment.