Recommended way to initialize JS renderer in 'asis' Markdown chunck

前端 未结 3 504
遇见更好的自我
遇见更好的自我 2020-12-07 02:40

\'asis\' chuncks are very useful to output a list of objects in a Markdown document, see following examples : Highcharter, DT, Leaflet, ...

However, in the above exam

3条回答
  •  独厮守ぢ
    2020-12-07 03:31

    The answer to my question has been given by @cderv :
    https://github.com/rstudio/rmarkdown/issues/1877#issuecomment-679864674

    The results = 'asis' is now more documented in https://bookdown.org/yihui/rmarkdown-cookbook/results-asis.html#results-asis . It is aimed at generating raw mardown content from a R chunk. Anything must result in a text output, and implicitly that means no knitr magic really happens for any R object in those chunk, because knitr does no adjustment when knit_printing the content (as it is juts text)

    I think I would not use result = 'asis' to cat() a complex R object like an htmlwidget. You found a workaround but you may encounter other issues.

    As this answer has been liked by @yihui, it gives a hint that cat + asis on htmlwidget should be used at one's own risk.

    However, I'll personnaly continue to use the workarounds mentioned in the question, because as long as it works I find it very practical.

    Thanks @atusi & @cderv for their valuable input.

提交回复
热议问题