Create custom markdown-blocks from R code

Viewed 38

Is it possible to create a custom markdown block within a R function?

Background: I have a custom function which renders a table in a very custom format. At the end of the table I would love to append a standardized text, such as "Table 1: title of my amazing table" in the format my-format. my-format refers to a custom style from a reference_docx. It generates a word document. So in markdown I would write:

```{r}
ft <- flextable(...)
ft # print out flextable
```

:::{custom-style="my-format"}
Table 1: title of my amazing table
:::

Instead I would like to write:

```{r, results='asis'}
ft
cat(paste(':::{custom-style="my-format"}',
    'Table 1: title of my amazing table',
    ':::', '', sep="\n"))
```

However, it does not work as intended. It does not print my flextable anymore. Since this code is inside a function I can't make two r blocks out of it.

0 Answers
Related