markdown tables on GitHub via Pandoc

2019-05-22 20:57发布

问题:

When I combine several .md files with tables into a single .pdf and a single .md file using Pandoc, only the .pdf maintains formatting. I created a simple repository that has four .md files showing each table example on the Pandoc website.

I compiled with the following commands:

pandoc -o README.md *.md

pandoc -o README.pdf *.md

As you can see from the repository, the (pdf) looks fine, but the markdown file showing on GitHub as the readme does not.

Also, of the four individual .md files, only the pipe table shows correctly on GitHub.

Questions:

  1. What type of markdown tables are supported by GitHub? Tables are not addressed in this spec sheet.

  2. Pandoc seems to be the best way to combine multiple .md files into one doc, but the formatting does not hold when outputting to .md. Looks fine for .pdf. Why? And is there a fix?

回答1:

  1. You're correct that the GitHub documentation doesn't say what kind of tables GFM supports. I think your test shows that it supports pipe tables. Since Pandoc can natively output GFM (see below), that's likely your best bet.

  2. You can specify the precise output format using the -t option. In this case:

    pandoc -o whole-thing.md -t markdown_github *.md
    

    The supported output formats are listed in the Pandoc README.