简体   繁体   中英

How to convert tables in markdown file into html file using pandoc

I'm trying to convert markdown files into html using pandoc , This is the markdown table format in.md file:

| Name | Unit | Symbol |
|----|----|----|
| variable A |  | $a$ | 
| variable B |  | $b$ |
| variable C |  | $\mu$ |
pandoc --toc --standalone --mathjax -f markdown_strict -t html file_name.md -o file_name.html --metadata pagetitle="page title"

but the tables are shown as text. I have used this solution as well but I still have tables as normal text without table borders in html . However directly exporting through ReText the html shows tables without any issue. How do I get the tables in html file while using pandoc ?

John Gruber's original Markdown, which is the format that pandoc assumes when converting with -f markdown_strict , has no syntax for tables. The table format in the input is called "pipe table", and you'll need to enable the respective Markdown extension to make pandoc parse it:

pandoc -f markdown_strict+pipe_tables ...

Alternatively, you could use a different Markdown format like pandoc's default Markdown ( -f markdown ), GitHub Flavored Markdown ( -f gfm ), or extended CommonMark ( -f commonmark_x ), as those all have support for pipe tables baked in.

All of those formats also support the dollar syntax for math, which you'll probably want enabled as well. Enabling it with markdown_strict is possible by appending +tex_math_dollars to the format definition.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM