mdiep / MMMarkdown

An Objective-C framework for converting Markdown to HTML.
MIT License
1.25k stars 168 forks source link

Github tables don't parse into HTML tables unless they have a blank line in front of them #31

Closed rogernolan closed 10 years ago

rogernolan commented 10 years ago

I'm running against :HEAD to get the github markdown. Calling

        NSString *rawhtml = [MMMarkdown HTMLStringWithMarkdown:_markdown extensions:MMMarkdownExtensionsTables error:&error];

For input:

The leopards have names. Here is a handy table to help you identify them:
Name     |     colour
-----------|------------
fluffy   | leopard coloured
tiddles | leopard coloured
Socks | leopard coloured

Output is:


<p>The leopards have names. Here is a handy table to help you identify them:
Name     |     colour
-----------|------------
fluffy   | leopard coloured
tiddles | leopard coloured
Socks | leopard coloured</p>

instead of

<table>
<tr>
  <th>Name</th>
  <th>Colour</th>       
</tr>
<tr>
  <td> fluffy </td>
  <td> leopard coloured</td>        
</tr>
<tr>
  <td> tiddles </td>
  <td> leopard coloured</td>        
</tr>
<tr>
  <td> Socks </td>
  <td> leopard coloured</td>        
</tr>
</table>

Putting an extra CR in front of the table Markdown fixes this:

The leopards have names. Here is a handy table to help you identify them:

Name     |     colour
-----------|------------
fluffy   | leopard coloured
tiddles | leopard coloured
Socks | leopard coloured

parses to:

<p>The leopards have names. Here is a handy table to help you identify them:</p>
<table><thead><tr><th>Name</th><th>colour</th></tr></thead><tbody><tr><td>fluffy</td><td>leopard coloured</td></tr><tr><td>tiddles</td><td>leopard coloured</td></tr><tr><td>Socks</td><td>leopard coloured</td></tr></tbody></table>

Here's the same text in Github:

The leopards have names. Here is a handy table to help you identify them: Name colour
fluffy leopard coloured
tiddles leopard coloured
Socks leopard coloured
rogernolan commented 10 years ago

Closing because adding the example to GitHub shows my understanding of Markdown is flawed. Sorry.