mdiep / MMMarkdown

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

``` (Triple Grave Accent) Parsing Error #53

Closed albertbori closed 9 years ago

albertbori commented 9 years ago

Code:

var content = MMMarkdown.HTMLStringWithMarkdown(self.detail, extensions: MMMarkdownExtensions.GitHubFlavored, error: nil)

Markdown:

# My Markdown Post
**Bold**
*Italic*
~~Strikethrough~~

```function thing() {
    alert("stuff");
}```

    function otherThing() {
        alert("other stuff");
    }

- Item
- Item 2

Raw link: http://google.com
Pretty link: [Internet](http://google.com)

![Mind Blown](http://d3819ii77zvwic.cloudfront.net/wp-content/uploads/2014/07/ik49VlPshlPIz.gif)

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla interdum, massa eget sodales congue, leo est aliquam lectus, ac elementum magna diam efficitur arcu. Fusce at velit eu orci condimentum dignissim ut a nulla. Suspendisse justo nulla, semper et erat eget, rutrum vulputate ligula. Aliquam erat volutpat. Integer ut congue nibh. Suspendisse condimentum odio dapibus, ultricies tortor a, porttitor tellus. Etiam nec quam in elit consectetur elementum a eu libero. Aenean porta, lorem et pellentesque consequat, arcu magna tincidunt ipsum, in feugiat nunc diam vitae tellus. Praesent dignissim, lorem non mattis maximus, elit nisi bibendum metus, et sagittis purus risus ac orci.

Actual Result:

<h1>My Markdown Post</h1>
<p><strong>Bold</strong><br />
<em>Italic</em><br />
<del>Strikethrough</del></p>
<pre><code class="function">    alert("stuff");
}```

    function otherThing() {
        alert("other stuff");
    }

- Item
- Item 2

Raw link: http://google.com
Pretty link: [Internet](http://google.com)

![Mind Blown](http://d3819ii77zvwic.cloudfront.net/wp-content/uploads/2014/07/ik49VlPshlPIz.gif)

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla interdum, massa eget sodales congue, leo est aliquam lectus, ac elementum magna diam efficitur arcu. Fusce at velit eu orci condimentum dignissim ut a nulla. Suspendisse justo nulla, semper et erat eget, rutrum vulputate ligula. Aliquam erat volutpat. Integer ut congue nibh. Suspendisse condimentum odio dapibus, ultricies tortor a, porttitor tellus. Etiam nec quam in elit consectetur elementum a eu libero. Aenean porta, lorem et pellentesque consequat, arcu magna tincidunt ipsum, in feugiat nunc diam vitae tellus. Praesent dignissim, lorem non mattis maximus, elit nisi bibendum metus, et sagittis purus risus ac orci.
</code></pre>

Expected Result:

The parser should find the closing triple tick, even if it is not padded by whitespace:

My Markdown Post

Bold Italic Strikethrough

function thing() { alert("stuff"); }

function otherThing() {
    alert("other stuff");
}

Raw link: http://google.com Pretty link: Internet

Mind Blown

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla interdum, massa eget sodales congue, leo est aliquam lectus, ac elementum magna diam efficitur arcu. Fusce at velit eu orci condimentum dignissim ut a nulla. Suspendisse justo nulla, semper et erat eget, rutrum vulputate ligula. Aliquam erat volutpat. Integer ut congue nibh. Suspendisse condimentum odio dapibus, ultricies tortor a, porttitor tellus. Etiam nec quam in elit consectetur elementum a eu libero. Aenean porta, lorem et pellentesque consequat, arcu magna tincidunt ipsum, in feugiat nunc diam vitae tellus. Praesent dignissim, lorem non mattis maximus, elit nisi bibendum metus, et sagittis purus risus ac orci.

mdiep commented 9 years ago

Thanks for the report!

It looks like this is because MMMarkdown interprets this as a valid fenced code block:

```function thing() {
    alert("stuff");
}```

(It should be interpreted as an inline code block.)

I'll need to investigate what the right thing to do here is.