Luís de Sousa
Luís de Sousa

Reputation: 6842

Table in Markdown for GitHub pages

I am developing a small website with GitHub pages following a structure very similar to the one preented in this guide. There is an index.html master file and then a few pre-set layouts, the actual content in each page is coded in Markdown.

In one of the content pages I would like to present table. Markdown supports tables at a bare level, I thus use HTML to some more structure:

---
layout: default
---

Content
=======

<table align=center>
  <tr><th align=center>Header A</th><th align=center>Header B</th><th align=center>Header C</th></tr>
  <tr><td>Content a1</td><td>Content b1</td><td>Content c1</td></tr>
  <tr><td>Content a2</td><td>Content b2</td><td>Content c2</td></tr>
  <tr><td>Content a3</td><td>Content b3</td><td>Content c3</td></tr>
</table>

This produces an actual table with a Markdown viewer on my system. But GitHub presents the HTML code instead:

enter image description here

How can I create a formatted table for GitHub pages?

Upvotes: 1

Views: 1420

Answers (1)

marcanuy
marcanuy

Reputation: 23962

Surround table attributes with double quotes like align="center" and kramdown will process the HTML:

<table align="center">
  <tr><th align="center">Header A</th><th align="center">Header B</th><th align="center">Header C</th></tr>
  <tr><td>Content a1</td><td>Content b1</td><td>Content c1</td></tr>
  <tr><td>Content a2</td><td>Content b2</td><td>Content c2</td></tr>
  <tr><td>Content a3</td><td>Content b3</td><td>Content c3</td></tr>
</table>

Gives

enter image description here

Upvotes: 2

Related Questions