nkls
nkls

Reputation: 11

How to insert customly styled text from function called in code chunk in docx-targeted R Markdown?

I'd like to insert some text like "<div custom-style='Style1'>Text</div>" into a docx-targeted R Markdown document by calling a function from a code chunk (using RStudio and Pandoc 2). Ordinarily, I could do this easily in a code chunk using pander("<div custom-style='Style1'>Text</div>"). But nothing is output when pander() is called from my function outside of the code chunk from which the function is called. I cannot use results="asis" for the code chunk because that will make flextable (which is used in the function after pander()) paste xml-like markup instead of the actual table into the docx document. Using (a) cat(pander()) or (b) setting panderOptions('knitr.auto.asis', FALSE) and using pander() both do not lead to a correctly styled output (it is styled as "Source Code" in the docx). Any help would be greatly appreciated. Thank you.

Upvotes: 1

Views: 154

Answers (0)

Related Questions