sirthias / pegdown

A pure-Java Markdown processor based on a parboiled PEG parser supporting a number of extensions
http://pegdown.org
Apache License 2.0
1.29k stars 218 forks source link

Formatting does not work for text in braces #146

Open obfischer opened 9 years ago

obfischer commented 9 years ago

It seems so that pegdown can not format Markdown markup surrounded by braces.

Examples like (*should be italic*) are not formatted as expected.

billliu1992 commented 9 years ago

It's not that pegdown cannot format Markdown surrounded by braces, its that pegdown cannot format emph or strong surrounded by anything. Try a*should be italic*a and you will notice that should be italic is not italic. If you just want a workaround, ( *this should work* ) (spaces before and after the * character).

I'm not too sure if this is actually a bug. If you look in the org.pegdown.Parser class, the method isLegalEmphOrStrongStartPos() explicity states a previous textnode needs to end with " " (space char) to be able to enter a emph or strong.

According to Gruber's original Markdown syntax, emph and strong should be able to be placed within a word. However, many Markdown implementations (including GFM!) does not allow in word emphasis/strong, since words_with_underscores are common in code, and would result in unwanted formatting.

obfischer commented 9 years ago

Thank you for the quick respond. I recognized this while porting a blog from Octopress (Jekyll based) to JBake. For Jekyll it seems to be ok to surround markup with braces.

revivek commented 7 years ago

Has there been a resolution on how to continue forward with this, if at all? I would vote that this space requirement is a bug even though the requirement is explicit in the Parser code. This library aims to implement the Markdown spec (plus more), and as @billliu1992 mentioned, the Markdown spec allows emphasis and strong to be placed within a word. Also, FWIW GFM allows in-word formatting (i.e. Hello there) with asterisks but not underscores (i.e. test).