tidymodels / TMwR

Code and content for "Tidy Modeling with R"
https://tmwr.org
Other
578 stars 272 forks source link

wrapping errors and warnings to page width #3

Open topepo opened 4 years ago

topepo commented 4 years ago

A modification of yihui/knitr#1142 that works for bookdown (knit_hooks is not exposed when rendering in bookdown)

topepo commented 4 years ago

@cderv This and issue #5 are examples of (what appears to be) knitr options not working in bookdown.

cderv commented 4 years ago

Thanks ! I'll have a look !

cderv commented 2 years ago

It is possible that your hook is correct but where is loaded does not work. Here is a full analysis https://github.com/rstudio/bookdown/issues/1252#issuecomment-913530117

Basically when new_session: yes, before_chapter_script is sourced before render(), as each file is rendered in a different session. This means that it is possible that some options (like knitr configuration) does not apply because overwrittren by render(). Usually in a document project, those change of behavior for knitr are done in a setup chunk. And with a bookdown project this would apply. Some different way to load a common file in all document are shared in the issue linked above.

That may be what causes the hook you defined to not work.

No issue I think if you use new_session: false

BTW there is also this solution but that would apply to all outputs https://bookdown.org/yihui/rmarkdown-cookbook/text-width.html