-
Notifications
You must be signed in to change notification settings - Fork 528
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Emphasis not rendered when followed by a comma, period or semicolon + space #306
Comments
Interestingly, PHP Markdown is the only parser with that behavior, so I really ought to fix this. Thank you for the report. |
I've tracked the problem down to this line https://github.com/michelf/php-markdown/blob/lib/Michelf/Markdown.php#L1252 where |
I'm trying to remember, but can't find the reason. A simple way to find out would be to remove them, make a pull request and look at the failing tests from the auto tester. |
Are the tests running here on Github (via Travis) or shall I run them locally? |
Here, using Travis. You can run them locally too. |
I think I found the reason. It's to avoid confusing asterisks that are meant to be asterisks in situations like that:
Many implementations get it right, including Github:
While this works in PHP Markdown too, the way it's implemented it breaks other cases. The basic idea to make that work is that the opening asterisk can be anywhere but at the end of a word, and so we check for whitespace after the asterisk. But since words are often followed by punctuation, punctuation counts as whitespace in this situation. That makes sense in the general case, but not in your example where there is no word preceding the punctuation. So I think the fix would be to not count punctuation as whitespace if the asterisk is preceded by whitespace. |
Sounds about right. In our case, though, it was enough to remove the punctuation from the regexes, because as our markdown is derived from a rich text editor, the asterisks are escaped. |
I can confirm this behavior with the Markdown text
Hope it helps. Related to friendica/friendica#6938 |
When trying to parse something like
hello *, this is emphasized* etc..
the part between the asterisks doesn't get rendered. It happens at least when the first asterisk is followed by a comma, period, or semicolon and a space. See the following image:The text was updated successfully, but these errors were encountered: