pegdown icon indicating copy to clipboard operation
pegdown copied to clipboard

Formatting does not work for text in braces

Open obfischer opened this issue 9 years ago • 3 comments

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

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

obfischer avatar Oct 31 '14 08:10 obfischer

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.

billliu1992 avatar Oct 31 '14 15:10 billliu1992

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.

obfischer avatar Oct 31 '14 16:10 obfischer

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. H_ello_ there) with asterisks but not underscores (i.e. t_est_).

revivek avatar Aug 05 '16 15:08 revivek