Skip to main content
edited tags
Link
Willie Wong
  • 26.7k
  • 8
  • 81
  • 112
Source Link

How to render html tables in markdown using Pandoc?

The following markdown code containing html table tags doesn't render properly when converted to latex format using Pandoc.

file.md:

<table> <tr> <th>Alfreds Futterkiste</th> <th>Maria Anders</th> <th>Germany</th> </tr> <tr> <td>Centro comercial Moctezuma</td> <td>Francisco Chang</td> <td>Mexico</td> </tr> </table> | Alfreds Futterkiste | Maria Anders | Germany | |---------------------|--------------|---------| | Centro comercial Moctezuma | Francisco Chang | Mexico | 

pandoc file.md -s -t latex

results in (output snipped to relevant portion):

Alfreds Futterkiste Maria Anders Germany Centro comercial Moctezuma Francisco Chang Mexico \begin{longtable}[]{@{}lll@{}} \toprule Alfreds Futterkiste & Maria Anders & Germany \\ \midrule \endhead Centro comercial Moctezuma & Francisco Chang & Mexico \\ \bottomrule \end{longtable} 

adding the --verbose option to pandoc shows it is ignoring the html tags

[INFO] Not rendering RawBlock (Format "html") "<table>" [INFO] Not rendering RawBlock (Format "html") "<tr>" [INFO] Not rendering RawBlock (Format "html") "<td>" [INFO] Not rendering RawBlock (Format "html") "</td>" [INFO] Not rendering RawBlock (Format "html") "<td>" [INFO] Not rendering RawBlock (Format "html") "</td>" [INFO] Not rendering RawBlock (Format "html") "<td>" [INFO] Not rendering RawBlock (Format "html") "</td>" [INFO] Not rendering RawBlock (Format "html") "</tr>" [INFO] Not rendering RawBlock (Format "html") "<tr>" [INFO] Not rendering RawBlock (Format "html") "<td>" [INFO] Not rendering RawBlock (Format "html") "</td>" [INFO] Not rendering RawBlock (Format "html") "<td>" [INFO] Not rendering RawBlock (Format "html") "</td>" [INFO] Not rendering RawBlock (Format "html") "<td>" [INFO] Not rendering RawBlock (Format "html") "</td>" [INFO] Not rendering RawBlock (Format "html") "</tr>" [INFO] Not rendering RawBlock (Format "html") "</table>" 

How can I get it to process these as html tables within markdown like the pipe tables?

I do not wish to use pipe tables as they are harder for tech writers to edit/use.