Skip to content

Commit

Permalink
Add include_md option
Browse files Browse the repository at this point in the history
Issue #956
  • Loading branch information
katrinabrock committed Dec 6, 2024
1 parent 4165d84 commit e62185b
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
5 changes: 3 additions & 2 deletions R/utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -86,12 +86,13 @@ book_filename = function(config = load_config(), fallback = TRUE) {

source_files = function(format = NULL, config = load_config(), all = FALSE) {
subdir = config[['rmd_subdir']]; subdir_yes = isTRUE(subdir) || is.character(subdir)
ext_regex <- if(isTRUE(config[['include_md']])) '[.]R?md$' else '[.]Rmd$'
# a list of Rmd chapters
files = list.files('.', '[.]Rmd$', ignore.case = TRUE)
files = list.files('.', ext_regex, ignore.case = TRUE)
# content in subdir if asked
subdir_files = unlist(mapply(
list.files,
if (is.character(subdir)) subdir else '.', '[.]Rmd$', ignore.case = TRUE,
if (is.character(subdir)) subdir else '.', ext_regex, ignore.case = TRUE,
recursive = subdir_yes, full.names = is.character(subdir), USE.NAMES = FALSE
))
subdir_files = setdiff(subdir_files, files)
Expand Down
2 changes: 1 addition & 1 deletion tests/testit/test-utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ assert('source_files() handles several configurations correctly', {
files = c(
'index.Rmd', '_ignored.Rmd', '01-first.Rmd',
'subdir/other.Rmd', 'subdir/_ignore.Rmd', 'subdir2/last.Rmd',
'abc/def.Rmd', 'abc/ghi.Rmd', 'subdir/jkl.md'
'abc/def.Rmd', 'abc/ghi.Rmd', 'abc/jkl.md'
)
lapply(unique(dirname(files)), dir.create, FALSE, recursive = TRUE)
file.create(files)
Expand Down

0 comments on commit e62185b

Please sign in to comment.