greghendershott / markdown

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

Backtick code block not recognized within <details> element #69

Closed greghendershott closed 7 years ago

greghendershott commented 7 years ago

Backtick code blocks aren't recognized inside a <details> element. For example:

<details>

```racket
(define (sqr x)
  (* x x))
```

</details>

Originally reported as https://github.com/greghendershott/frog/issues/202


Although I'd need to reload my brain as it's been months (years?) since I worked on the markdown parser, my initial guess is that nothing in the details element is being parsed as markdown -- possibly because details isn't in the block-elements set in html.rkt?

greghendershott commented 7 years ago

My initial guess/memory was wrong.

As soon as you use some HTML open tag, you basically "escape" into an HTML parser -- which won't parse markdown -- until the matching closing tag.

So for instance <p>Some _text_ here</p> will not parse the underlines around text as <em>; you'll get the underlines as "raw text".

Generally this is the safe/smart thing to do -- as best I understand, and as best I remember from the days when I tried to keep this markdown parsing logic in my brain.

Having said all that, I notice many markdown parsers do handle <details>. Maybe I should add that as a special case.

(On the one hand I don't love special cases. But on the other hand I'm very worried about touching how HTML is handled, generally -- and breaking many things, generally. I don't have time now to chase down a lot of breakage. (I barely have time to attempt this as a limited special case.))

greghendershott commented 7 years ago

I have a commit for this. I'm going to sleep on it.

Incidentally, here's how various markdown parsers handle this%0A%60%60%60%0A%0A%3C%2Fdetails%3E%0A).