Rapporter / pander

An R Pandoc Writer: Convert arbitrary R objects into markdown
http://rapporter.github.io/pander/
Open Software License 3.0
294 stars 66 forks source link

pander.headar inside loop with results = 'markup' chunk #348

Open iago-pssjd opened 3 years ago

iago-pssjd commented 3 years ago

pandoc.header does not work inside a loop on an rmarkdown chunk with results='markup', while it works with results='asis'.

I ask the same question as here (https://stackoverflow.com/questions/66580211/how-to-change-chunk-options-results-formatting-inside-a-loop-in-a-chunk), because of the claim:

Also, pander is integrated with knitr by default. pander simply identifies if knitr is running in the background, and if so, it uses capture.output to return the resulting string as an knit_asis object, meaning that you do not need to specify the results='asis' option in your knitr chunk:

I copy the reprex

---
title: "Reprex"
date: "11/03/2021"
output: html_document
---

```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
library(pander)```
# R Markdown

```{r cars}

for(i in 1:10){
  pandoc.header(paste("Section", i), level = 2)
}```

Thank you!

iago-pssjd commented 3 years ago

In fact, now I found this (https://github.com/yihui/knitr/issues/1137) which seems to be related.