HOW get rendered openxml chunks inside cells of tables in RMD to DOCx ? I just get same openxml text (mdt) inside tables instead of content ..
any suggestions please?
xml_test.RMD:
Updated Test RMD code :
---
output:
word_document:
reference_docx: ./template.docx
keep_md: yes
md_extensions: +raw_tex
editor_options:
chunk_output_type: console
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = FALSE)
```
```{r, setuplib, include=FALSE}
#library(tidyverse)
library(knitr)
#library(rmarkdown)
#library(dplyr)
#library(stringr)
library(huxtable)
library(kableExtra)
#library(ftExtra)
```
```{r, xml-test, echo=FALSE, collapse = FALSE}
# XML CONTENT
text_xml <- "<w:p><w:r><w:t>Example text.</w:t></w:r></w:p>"
sanitize(text_xml, type = "rtf")
knitr::asis_output(" \n")
sanitize(text_xml, type = "html")
knitr::asis_output(" \n")
#sanitize(text_xml, type = "latex")
#knitr::asis_output(" \n")
#to_ht <- c(knitr::asis_output(mdt), knitr::asis_output(mdt))
to_ht <- c(text_xml)
#ht <- huxtable::as_hux(to_ht, add_colnames = TRUE, add_rownames = TRUE, escape_contents=FALSE, autoformat = FALSE)
ht <- huxtable::as_hux(text_xml, add_colnames = FALSE, add_rownames = FALSE, escape_contents=FALSE, autoformat = FALSE)
#markdown(ht) <- TRUE
#ht <- set_markdown(ht)
# BAD XML OUTPUT INSIDE CELLS
theme_grey(ht)
knitr::asis_output(" \n")
#knitr::asis_output(ht)
knitr::asis_output(" \n")
# NORMAL XML OUTPUT HERE:
knitr::asis_output(as.character(text_xml))
```
I found as_hux() has incorrect sanitize text in: " <w:p><w:r><w:t>Example text.</w:t></w:r></w:p>
"
instead of RAW or WORD in md:
"<w:p><w:r><w:t>Example text.</w:t></w:r></w:p>"
as result I have this issue with wrong output in WORD huxtable cell
QUESTION: how i can avoid this conversion in MD file ?