greghendershott / markdown

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

Bold/italic within characters like dashes is not properly rendered #64

Open lexi-lambda opened 8 years ago

lexi-lambda commented 8 years ago

The following example does not produce the HTML I would expect:

> (parse-markdown "This is a—*test*—with some—*em dash*—characters.")
'((p () "This is a—*test*—with some—*em dash*—characters."))

Most markdown implementations will treat the words surrounded by asterisks as italicized.

Notably, if I add some punctuation inside the dashes, the parse changes significantly:

> (parse-markdown "This is a—*test!*—with some—*em dash*—characters.")
'((p
   ()
   "This is a—*test!"
   (em () "—with some—*em dash")
   "—characters."))

Which still seems quite incorrect, but might be relevant.

greghendershott commented 8 years ago

This might be a duplicate of #55?

lexi-lambda commented 8 years ago

Possibly; I’m not sure. My guess is that * adjacent to should not be considered to be “in the middle of words”, so I was wondering if there was some handling of that which was causing this behavior instead.

greghendershott commented 8 years ago

I'm not sure either. I mentioned #55 mostly because of the discussion there and why it's not resolved.

I like markdown. It meets my low expectations of it. :) Mostly it's pleasantly DWIM. When it's not? I've come to believe that "use some HTML markup to get exactly WIM" is the least-worst answer.

Maybe that's because I'm close to exhausting my finite lifetime quota of enthusiasm for resolving ambiguities and corner cases. Markdown doesn't have a real specification. Was never intended to.

I think CommonMark is an understandable response -- do make a real spec, which e.g. has 12 rules for this and 5 more rules for when the first 12 are still ambiguous. Great. But that's no longer markdown. I'm not super excited about using CommonMark, as a writer. Nor implementing a parser for it in Racket, even if I had time now, which I don't.

lexi-lambda commented 8 years ago

Yeah, that’s fair! I certainly don’t blame you. I am mostly just reporting this because I ran into it, for completeness’s sake. If I find some time, I might look into fixing it, but otherwise I am fine for the official response to be “use HTML”.

Thanks for all the work you’ve put into this package, by the way—writing a Markdown parser does not seem like an easy feat.

greghendershott commented 8 years ago

You're welcome, and, thank you for the reporting it. I'm definitely interested in fixing problems generally.

Also I hope I didn't sound cranky about markdown or CommonMark. I admire John MacFarlane's determination.