77# ' `TRUE`, ensures that every article is build in a fresh environment, but
88# ' you may want to set it to `FALSE` to make debugging easier.
99# ' @param pandoc_args Pass additional arguments to pandoc. Used for testing.
10- build_article <- function (name ,
11- pkg = " ." ,
12- lazy = FALSE ,
13- seed = 1014L ,
14- new_process = TRUE ,
15- pandoc_args = character (),
16- override = list (),
17- quiet = TRUE ) {
10+ build_article <- function (
11+ name ,
12+ pkg = " ." ,
13+ lazy = FALSE ,
14+ seed = 1014L ,
15+ new_process = TRUE ,
16+ pandoc_args = character (),
17+ override = list (),
18+ quiet = TRUE
19+ ) {
1820 pkg <- section_init(pkg , " articles" , override = override )
1921
2022 # Look up in pkg vignette data - this allows convenient automatic
@@ -49,35 +51,47 @@ build_article <- function(name,
4951 new_process = new_process ,
5052 pandoc_args = pandoc_args ,
5153 quiet = quiet
52- )
54+ )
5355 } else {
5456 build_quarto_articles(pkg = pkg , article = name , quiet = quiet )
5557 }
5658}
5759
58- build_rmarkdown_article <- function (pkg ,
59- input_file ,
60- input_path ,
61- output_file ,
62- output_path ,
63- depth ,
64- seed = NULL ,
65- new_process = TRUE ,
66- pandoc_args = character (),
67- quiet = TRUE ,
68- call = caller_env() ) {
60+ build_rmarkdown_article <- function (
61+ pkg ,
62+ input_file ,
63+ input_path ,
64+ output_file ,
65+ output_path ,
66+ depth ,
67+ seed = NULL ,
68+ new_process = TRUE ,
69+ pandoc_args = character (),
70+ quiet = TRUE ,
71+ call = caller_env()
72+ ) {
6973 cli :: cli_inform(" Reading {src_path(input_file)}" )
7074 digest <- file_digest(output_path )
7175
7276 data <- data_article(pkg , input_file , call = call )
7377 if (data $ as_is ) {
7478 if (identical(data $ ext , " html" )) {
75- setup <- rmarkdown_setup_custom(pkg , input_path , depth = depth , data = data )
79+ setup <- rmarkdown_setup_custom(
80+ pkg ,
81+ input_path ,
82+ depth = depth ,
83+ data = data
84+ )
7685 } else {
7786 setup <- list (format = NULL , options = NULL )
7887 }
7988 } else {
80- setup <- rmarkdown_setup_pkgdown(pkg , depth = depth , data = data , pandoc_args = pandoc_args )
89+ setup <- rmarkdown_setup_pkgdown(
90+ pkg ,
91+ depth = depth ,
92+ data = data ,
93+ pandoc_args = pandoc_args
94+ )
8195 }
8296
8397 local_envvar_pkgdown(pkg )
@@ -127,7 +141,6 @@ build_rmarkdown_article <- function(pkg,
127141 }
128142
129143 invisible (path )
130-
131144}
132145
133146
@@ -136,7 +149,7 @@ data_article <- function(pkg, input, call = caller_env()) {
136149
137150 opengraph <- check_open_graph(pkg , yaml $ opengraph , input , call = call )
138151 opengraph $ description <- opengraph $ description %|| % yaml $ description
139-
152+
140153 list (
141154 opengraph = opengraph ,
142155 pagetitle = escape_html(yaml $ title ),
@@ -148,19 +161,21 @@ data_article <- function(pkg, input, call = caller_env()) {
148161 )
149162}
150163
151- rmarkdown_setup_custom <- function (pkg ,
152- input_path ,
153- depth = 1L ,
154- data = list (),
155- env = caller_env()) {
164+ rmarkdown_setup_custom <- function (
165+ pkg ,
166+ input_path ,
167+ depth = 1L ,
168+ data = list (),
169+ env = caller_env()
170+ ) {
156171 template <- rmarkdown_template(pkg , depth = depth , data = data , env = env )
157172
158173 # Override defaults & values supplied in metadata
159174 options <- list (
160175 template = template ,
161176 self_contained = FALSE
162177 )
163-
178+
164179 output <- rmarkdown :: default_output_format(input_path )
165180 if (output $ name != " rmarkdown::html_vignette" ) {
166181 # Force to NULL unless overridden by user
@@ -170,12 +185,13 @@ rmarkdown_setup_custom <- function(pkg,
170185 list (format = NULL , options = options )
171186}
172187
173- rmarkdown_setup_pkgdown <- function (pkg ,
174- depth = 1L ,
175- data = list (),
176- pandoc_args = character (),
177- env = caller_env()) {
178-
188+ rmarkdown_setup_pkgdown <- function (
189+ pkg ,
190+ depth = 1L ,
191+ data = list (),
192+ pandoc_args = character (),
193+ env = caller_env()
194+ ) {
179195 template <- rmarkdown_template(pkg , depth = depth , data = data , env = env )
180196
181197 format <- rmarkdown :: html_document(
@@ -187,7 +203,10 @@ rmarkdown_setup_pkgdown <- function(pkg,
187203 extra_dependencies = bs_theme_deps_suppress(),
188204 pandoc_args = pandoc_args
189205 )
190- format $ knitr $ opts_chunk <- fig_opts_chunk(pkg $ figures , format $ knitr $ opts_chunk )
206+ format $ knitr $ opts_chunk <- fig_opts_chunk(
207+ pkg $ figures ,
208+ format $ knitr $ opts_chunk
209+ )
191210
192211 width <- config_pluck_number_whole(pkg , " code.width" , default = 80 )
193212 old_pre <- format $ pre_knit
@@ -202,7 +221,12 @@ rmarkdown_setup_pkgdown <- function(pkg,
202221}
203222
204223# Generates pandoc template by rendering templates/content-article.html
205- rmarkdown_template <- function (pkg , data = list (), depth = 1L , env = caller_env()) {
224+ rmarkdown_template <- function (
225+ pkg ,
226+ data = list (),
227+ depth = 1L ,
228+ env = caller_env()
229+ ) {
206230 path <- withr :: local_tempfile(
207231 pattern = " pkgdown-rmd-template-" ,
208232 fileext = " .html" ,
0 commit comments