9
votes

I'm writing document with Jekyll/Markdown and its engine is kramdown.
And now I'm wondering the way to write lists in table built by markdown.

I tried following.

|Name   |Columns             |
|-------|--------------------|
|PRIMARY|<ul><li>id</li></ul>|

In GitHub's Gist, it's rendered as I thought.

But in Jekyll (my local one or GitHub Pages' one), it's not.
http://yuya-takeyama.github.io/2011/10/08/hello-github-pages.html

Is there any way to write lists in table in Jekyll?
I'll replace markdown engine if it's required.

5

5 Answers

4
votes

nomarkdown tag helps:

|Name   |Columns                               |
|-------|--------------------------------------|
|PRIMARY|{::nomarkdown}<ul><li>id</li></ul>{:/}|

Jekyll rendered table

The solution works with both kramdown and redcarpet.

2
votes

I think Kramdown doesn't support multiline tables, and no HTML in table cells either (although I'm no Kramdown expert).

However, Pandoc has a few different table syntaxes, among them:

+---------+----------+
| Name    | Columns  |
+=========+==========+
| PRIMARY | - id one |
|         | - id two |
+---------+----------+

You can use, this plugin to use Pandoc from Jekyll. Note, that you'll have to run Jekyll locally since GitHub doesn't support Jekyll plugins.

2
votes

This seems to maximize GitHub Markdown compatibility:

markdown: redcarpet
redcarpet:
  extensions:
    - no_intra_emphasis
    - fenced_code_blocks
    - autolink
    - tables
    - strikethrough
    - superscript
    - with_to_data

The extension addressing your question is tables, but you probably want the rest if you want your Gists to look like your pages for the same markup.

2
votes

As we known, Jekyll uses kramdown as a default markdown converter from 2.0+. And It doesn't support the table cell alignment, merging and so on, I think the below can help you.

jekyll-spaceship - 🚀 A Jekyll plugin to provide powerful supports for table, mathjax, plantuml, mermaid, emoji, video, youtube, vimeo, dailymotion, etc.

https://github.com/jeffreytse/jekyll-spaceship

For now, these extended features are provided:

  • Cells spanning multiple columns
  • Cells spanning multiple rows
  • Cells text align separately
  • Table header not required
  • Grouped table header rows or data rows

Markdown:

table code

Code above would be parsed as:

html table

-3
votes
  1. Open _config.yml
  2. Add markdown: kramdown
  3. Run jekyll serve in your terminal.
  4. Enjoy.

Please check out the kramdown manual for more information about how to pimp your tables: http://kramdown.gettalong.org/quickref.html#tables