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

rmd_subdir in _bookdown.yml ignores plain Markdown files #956

Closed
3 tasks done
kylelundstedt opened this issue Sep 25, 2020 · 12 comments · Fixed by #1483
Closed
3 tasks done

rmd_subdir in _bookdown.yml ignores plain Markdown files #956

kylelundstedt opened this issue Sep 25, 2020 · 12 comments · Fixed by #1483
Labels
feature a feature request or enhancement

Comments

@kylelundstedt
Copy link

The rmd_subdir option in the _bookdown.yml file only works for a subdirectory that contains R Markdown files (.Rmd), not for a subdirectory containing plain Markdown files (.md). However, the bookdown documentation seems to suggest that plain Markdown should work:

Although we have been talking about R Markdown files, the chapter files do not actually have to be R Markdown. They can be plain Markdown files (.md), and do not have to contain R code chunks at all.


By filing an issue to this repo, I promise that

  • I have fully read the issue guide at https://yihui.org/issue/.
  • I have provided the necessary information about my issue.
    • If I'm asking a question, I have already asked it on Stack Overflow or RStudio Community, waited for at least 24 hours, and included a link to my question there.
    • If I'm filing a bug report, I have included a minimal, self-contained, and reproducible example, and have also included xfun::session_info('bookdown'). 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('rstudio/bookdown').
    • If I have posted the same issue elsewhere, I have also mentioned it in this issue.
  • I have learned the Github Markdown syntax, and formatted my issue correctly.

I understand that my issue may be closed if I don't fulfill my promises.

@cderv
Copy link
Collaborator

cderv commented Sep 28, 2020

Hi !

I had a look at this .md file support and it seems it is only supported currently if you provide those file in rmd_files explicitly.

By default, if no rmd_files or rmd_subdir is provided, bookdown will not select the .md files, only the .Rmd.

Let's note you can use paths to the file in subdirectory using rmd_files

rmd_files: ["index.Rmd", "other/abstract.md"]

@yihui in the book it is said

Although we have been talking about R Markdown files, the chapter files do not actually have to be R Markdown. They can be plain Markdown files (.md), and do not have to contain R code chunks at all. You can certainly use bookdown to compose novels or poems!

Will that .md support was aimed only when precised in rmd_files ?
We could change the pattern in source_files but this could create some weird content addition in existing book ? (I am thinking of the README.md that often are in bookdown source project - but we could ignore)

What do you think on this one ? Thanks.

@kylelundstedt
Copy link
Author

Hi @cderv

You are quite correct. If you use the rmd_files option AND list the .md files explicitly, it works.
If you do NOT list the *.md files explicitly, it does NOT work.
IMHO, this inconsistent treatment is a bug.

The current bookdown(in dev, but not released yet) allows the use of the rmd_files and rmd_subdir options simultaneously.

rmd_files: "index.Rmd"
rmd_subdir: ["collected-poems-in-markdown-format"]

I believe using both would address your concerns about README.md files in the top-level directory without having to make any special exceptions. Therefore, I think the rmd_subdir option should allow for both explicit and implicit inclusion of plain Markdown files.

What do you think?

@cderv
Copy link
Collaborator

cderv commented Sep 30, 2020

Therefore, I think the rmd_subdir option should allow for both explicit and implicit inclusion of plain Markdown files.

IMO rmd_subdir: TRUE or rmd_subdir: ["collected-poems-in-markdown-format"] should behave like the default behavior regarding root directory : Automatic selection of files. This would be consistend

Currently, .md files are not looked for automatically as I said. Could be consider a bug, but as it seems to always has been the case, it seems more like a new feature to add.

I see several solutions :

  • Add an include_md parameter defaulting to FALSE, that would activate the automatic look up for .md file too in bookdown.
  • Modify only rmd_subdir to look for .md files by default. but .md file in root dir would not be found. If one wants to include .md file it would need to be in a subdir (or set in rmd_files explicitly)
  • Add the feature to bookdown to also pick the .md files in the project by default - this could have unwanted consequence on existing project if people have .md files in the project currently unpicked and without _ as prefix.

Maybe first option is the best to provide this feature for people who want it - but it adds another option 😕

@kylelundstedt
Copy link
Author

@cderv I'll defer to your knowledge and experience here. Cheers!

robitalec added a commit to robitalec/targets-parameterized-bookdown that referenced this issue Jan 6, 2021
since atm bookdown does not track md files unless explicitly stated in rmd_files
rstudio/bookdown#956
@cderv cderv added the feature a feature request or enhancement label Mar 30, 2021
@nigiord

This comment was marked as outdated.

@cderv

This comment was marked as outdated.

@katrinabrock
Copy link
Contributor

Would you accept a PR to fix this? If so, which of the options would you like to be implemented?

@cderv
Copy link
Collaborator

cderv commented Oct 7, 2024

Sure we would accept PR. @yihui do you have any insight on a preferred solution ?

Personally, the one with minimum impact to current project would be to prefer. So probably an opt-in to this.

@katrinabrock
Copy link
Contributor

BTW - Here is my current workaround:

In R:

options(yaml.eval.expr=TRUE)

In _bookdown.yml:

rmd_files: !expr list.files('.', '[.][Rr]?md$', ignore.case=TRUE)

@yihui
Copy link
Member

yihui commented Oct 7, 2024

Sure we would accept PR. @yihui do you have any insight on a preferred solution ?

Perhaps the first option? i.e., include_md: false by default. That won't be a breaking change.

BTW, in litedown, I'll use both .Rmd and .md by default. The rules are here: https://github.com/yihui/litedown/blob/1c70dd31346fe902d765d0263d7fa70acd603c4c/R/site.R#L162-L166

katrinabrock added a commit to katrinabrock/bookdown that referenced this issue Dec 6, 2024
katrinabrock added a commit to katrinabrock/bookdown that referenced this issue Dec 6, 2024
@katrinabrock
Copy link
Contributor

PR here: #1483
(not sure why only the comments and not the PR seems to be cross linked)

@yihui yihui linked a pull request Dec 6, 2024 that will close this issue
katrinabrock added a commit to katrinabrock/bookdown that referenced this issue Dec 6, 2024
@yihui yihui closed this as completed in d6bbb36 Dec 6, 2024
@cderv
Copy link
Collaborator

cderv commented Dec 6, 2024

Thanks @katrinabrock !!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature a feature request or enhancement
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants