wrapping errors and warnings to page width
A modification of yihui/knitr#1142 that works for bookdown (knit_hooks is not exposed when rendering in bookdown)
@cderv This and issue #5 are examples of (what appears to be) knitr options not working in bookdown.
Thanks ! I'll have a look !
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