vmg / sundown

Standards compliant, fast, secure markdown processing library in C
1.99k stars 385 forks source link

Markdown table extension does not seem to work #14

Closed FSX closed 13 years ago

FSX commented 13 years ago

I have the following source:

## MKDEXT_NO_INTRA_EMPHASIS

Lorem ipsum _d _olo_ r_ sit amet, __consectetur__ adipiscing _elit_.

## MKDEXT_TABLES

| First Header  | Second Header |
| ------------- | ------------- |
| Content Cell  | Content Cell  |
| Content Cell  | Content Cell  |

## MKDEXT_FENCED_CODE

This is a paragraph introducing:

~~~~~~~~~~~~~~~~~~~~~
a one-line code block
~~~~~~~~~~~~~~~~~~~~~

## MKDEXT_AUTOLINK

Here is an URL: http://github.com/

## MKDEXT_STRIKETHROUGH

Nullam tincidunt dui ~vitae~ nulla ~~tristique~~ ultricies.

## MKDEXT_LAX_HTML_BLOCKS

<div>Donec quis lacus arcu, nec venenatis dolor. **Suspendisse** nibh eros, _pretium_ in vestibulum non, ultrices sed erat.</div>

<span>Donec quis lacus arcu, nec venenatis dolor. **Suspendisse** nibh eros, _pretium_ in vestibulum non, ultrices sed erat.</span>

<p>Donec quis lacus arcu, nec venenatis dolor. **Suspendisse** nibh eros, _pretium_ in vestibulum non, ultrices sed erat.</p>

<strong>Donec quis lacus arcu, nec venenatis dolor. **Suspendisse** nibh eros, _pretium_ in vestibulum non, ultrices sed erat.</strong>

And this is the output:

<h2>MKDEXT_NO_INTRA_EMPHASIS</h2>

<p>Lorem ipsum <em>d _olo</em> r_ sit amet, <strong>consectetur</strong> adipiscing <em>elit</em>.</p>

<h2>MKDEXT_TABLES</h2>

<p>| First Header  | Second Header |
| ------------- | ------------- |
| Content Cell  | Content Cell  |
| Content Cell  | Content Cell  |</p>

<h2>MKDEXT_FENCED_CODE</h2>

<p>This is a paragraph introducing:</p>

<pre><code>a one-line code block
</code></pre>

<h2>MKDEXT_AUTOLINK</h2>

<p>Here is an URL: <a href="http://github.com/">http://github.com/</a></p>

<h2>MKDEXT_STRIKETHROUGH</h2>

<p>Nullam tincidunt dui ~vitae~ nulla <del>tristique</del> ultricies.</p>

<h2>MKDEXT_LAX_HTML_BLOCKS</h2>

<div>Donec quis lacus arcu, nec venenatis dolor. **Suspendisse** nibh eros, _pretium_ in vestibulum non, ultrices sed erat.</div>

<p><span>Donec quis lacus arcu, nec venenatis dolor. <strong>Suspendisse</strong> nibh eros, <em>pretium</em> in vestibulum non, ultrices sed erat.</span></p>

<p>Donec quis lacus arcu, nec venenatis dolor. **Suspendisse** nibh eros, _pretium_ in vestibulum non, ultrices sed erat.</p>

<p><strong>Donec quis lacus arcu, nec venenatis dolor. <strong>Suspendisse</strong> nibh eros, <em>pretium</em> in vestibulum non, ultrices sed erat.</strong></p>

The table is not converted to HTML. I used the Upskirt example with all markdown extensions enabled. The table syntax is from the PHP Markdown Extra page.

I'm not sure what MKDEXT_NO_INTRA_EMPHASIS and MKDEXT_LAX_HTML_BLOCKS are supposed to do.

vmg commented 13 years ago

Hey Frank, thanks for spotting this!

We had this little issue where our parser was being too strict when parsing the headers of a table.

| This | Does | Parse |
|------|------|------:|
| Foo  | Bar  | Foo   |

| This   | Used to | Fail    |
| ------ |  -----  | ------: |
| Foo    |   Bar   |   Foo   |

Now we are more lax about adding whitespace around your headers. Your examples are now parsing properly, at least on my computer. :)

Regarding those flags: MKDEXT_NO_INTRA_EMPHASIS changes the emphasis parser so you can write words with underscores between them without triggering emphasis. For example, the word this_is_bongos by default renders to this<em>is</em>bongos, but with that flag it's just rendered to this_is_bongos. This is an extension we enable by default in GitHub Flavored Markdown (yes_we_do), because GitHub is about programming, and 99% of the time, when you add underscores to a word, you don't mean to put emphasis there.

The lax HTML blocks flags allows you to skip a restriction in the Markdown standard that says that all inline HTML blocks must be preceded and followed by an empty line.

This is a paragraph
<div>
    This is some inline HTML. This block would not render properly according to the
    markdown standard, because it's not preceded by an empty line.
</div>

This is another paragraph

<div>
    This block renders properly
</div>

You can use the MKDEXT_NO_INTRA_EMPHASIS flag to disable the 'blank newline' requirement.

I think that's it, hope that was informative!

Thanks as always for reporting -- oh, and I've just seen your query on the GitHub IRC channel... Probably a bad idea, because I'm a hardcore idler. If you need anything from me, just PM me here in GitHub and I'll answer much more quickly.

Cheers!

FSX commented 13 years ago

Thanks for responding and fixing this so quickly. It also works here.