mdiep/MMMarkdown

Possible Minor Bug: Trailing characters after closing ``` for GHFM fenced code block interpreted differently

iosdev-republicofapps opened this issue · 1 comments

Hey,

When adding Markdown to Github issue, if the closing line contains characters after the closing ``` then GitHub does not end the fenced code block, as in:

NSString *str = @"Hello, world!";
```xxx

However, MMMarkdown does end the fenced code block in this case, consuming the trailing xxx after the closing ```:

    NSString *markdownInput = @"```\nNSString *str = @\"Hello, world!\";\n```xxx";
    NSString *htmlOutput = [MMMarkdown HTMLStringWithMarkdown:markdownInput extensions:MMMarkdownExtensionsTables|MMMarkdownExtensionsFencedCodeBlocks|MMMarkdownExtensionsUnderscoresInWords error:NULL];
    NSLog(@"For input '%@' got output '%@'", markdownInput, htmlOutput);

produces

2015-01-27 18:17:31.434 MarkdownTestMM[81350:7765794] For input '```
NSString *str = @"Hello, world!";
```xxx' got output '<pre><code>NSString *str = @"Hello, world!";
</code></pre>
'

Notice how the trailing xxx after the closing ``` got consumed by MMMarkdown.

I'm not sure which is the "reference implementation" of GHFM - the parsing in GitHub issues or the parsing in MMMarkdown. But the two parsers behave differently in this case.

The documentation on GHFM is ambiguous about this case: see https://help.github.com/articles/github-flavored-markdown/ . This doesn't mention what should happen if characters follow the closing ```.

Personally, I favor your approach: I think consuming the xxx trailing the ``` is the best and least-confusing-to-users approach. But it differs from what GitHub web GHFM parsing does.

So I just wanted to point this out. I guess it's not so much a bug as a difference in interpretation of the ambiguity in the standard here.

Not trying to be nitpicky, this is just a friendly heads up. :-)

Best wishes.

Thanks for the report! I changed the behavior to match GitHub's markdown.