greghendershott / markdown

Markdown parser written in Racket.
101 stars 28 forks source link

Codeblock after paragraph #78

Open pmatos opened 5 years ago

pmatos commented 5 years ago

If I use a codeblock like this:

Here's a codeblock:
```racket
(define foo 1)

it doesn't work because it expects a newline before ```. Why is this?

This works

Here's a codeblock:

(define foo 1)
greghendershott commented 5 years ago

(I transferred this issue from frog to markdown. I haven't tried doing that before on GitHub, so hopefully it worked correctly.)

Some markdown parsers expect a clearer end-of-paragraph before being ready to parse backticks as code-blocks. Mine is in that camp. A sampling of others.

There is some potential ambiguity because backticks are also used for inline <code> elements, too. Including using multiple backticks, which is necessary to escape a backtick. In other words:

This is ```inline code with a ` in the middle``` right here.

Renders as:

This is inline code with a ` in the middle right here.

You don't need three in this example. Just two would suffice. But the parser needs to handle three.

Of course it's not completely ambiguous because some parsers do the right thing that you want.

However I'm reluctant to open the hood on the markdown parser. It's been N years since I really worked on it. I'd be even more likely, than usual, to introduce some other bug in the process of fixing this.

So I'll leave this open as worthwhile to do. And someday I can tackle it as part of a batch, when I have a block of time to reload my brain and hopefully do it effectively. But in the meantime if you could add the extra blank line, as a work-around, that at least will make your markdown "more portable" (if there even is a thing when it comes to markdown).