Closed billdenney closed 7 years ago
Not sure what's the problem, can you please add more details and screenshots? When I run pandoc
on the above markdown table, I get this result, which looks OK to me:
Also, what do you mean by "it doesn't work with knitr/rmarkdown"? A minimal Rmd reproducing the problem would be highly appreciated.
With further investigation, this falls under "my fault, but maybe you can still help". :)
It turns out that the issue occurs when results="asis" and there is no blank line before the beginning of the table. File that under my fault. Perhaps a way that it can be prevented for me and other users in the future is to insert a blank line at the beginning (and end?) of the markdown created by pandoc.table?
Rename this text file to .Rmd, and it is a reproducible example.
Here is a screen shot of the result:
Ah, I see, thanks for the feedback -- that's actually makes sense.
So pander
already adds a blank line before and after the table, see eg your example with pander_return
(which shows what is written to the stdout
when calling pander
):
> pander_return(mytable)
[1] ""
[2] "-------------------------------------------------------------------------"
[3] " AIC df indentation isBest "
[4] "-------------------------------- -------- ---- ------------- ------------"
[5] " **E0=0, Emax=1, hill=1 (gnls -34.75 2 0 "
[6] " model)** "
[7] ""
[8] " **E0=0, Emax=estimated, hill=1 -36.01 3 0 "
[9] " (gnls model)** "
[10] ""
[11] " **E0=estimated, -34.4 4 0 "
[12] " Emax=estimated, hill=1 (gnls "
[13] " model)** "
[14] ""
[15] " **E0=0, Emax=1, hill=estimated -36.63 3 0 Best Model "
[16] " (gnls model)** "
[17] ""
[18] " **E0=0, Emax=estimated, -34.72 4 0 "
[19] " hill=estimated (gnls model)** "
[20] ""
[21] " **E0=estimated, -32.78 5 0 "
[22] " Emax=estimated, hill=estimated "
[23] " (gnls model)** "
[24] "-------------------------------------------------------------------------"
[25] ""
So I think what you are requesting is already done for the convenience of pander
users so that you do not have to add an extra line break before and after the table, but if you use cat
in R, that writes to stdout
without auto adding a newline -- you have to do that manually. So here calling cat
and then pander
means that you want to continue on the very same line, and although pander
adds one line-break -- but in markdown, 2 breaks are required for a "hard break" / new paragraph.
Does it make sense? I'm closing this ticket as I don't think pander
should start with two line breaks, but please feel free to reopen if you don't agree and I'm happy to discuss.
With the following data.frame, I'm having difficulty with pander formatting the resulting table. I'm also working within knitr/rmarkdown which likely has an interaction.
When doing a standard
pander(mytable)
, I get a table that then mixes pre-formatted and other info within the markdown due to the prefixed spaces.When I do
pander(mytable, justify="left")
, it appears to generate correct markdown, but it doesn't work with knitr/rmarkdown. When I dopander(mytable, justify="left", style="grid")
, it both generates a good markdown table and works with knitr/rmarkdown.