-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Markdown: Ignore mid-word underscores #4944
Conversation
Two _words_ -> Two <em>words</em> One_word -> One_word
I can agree with this change. I was thinking we could maybe "protect" shortcakes before handing it over to the Markdown parser. I'm also wondering, since we've been moving shortcake handling up and up, if we should just move it in front of all other handling. This might be less ideal though, as we'd probably make shortcakes out of every link (with the shortcake fallback in place). In any case, this would need at least a comment, preferably tests to ensure all works as expected. For this we will need to create a WordPress module for shortcakes, instead of using a global. |
Unrelated to this, if we continue to use shortcake fallbacks, we might want to rethink how we parse shortcakes. If we just want to match anything ( |
(I think your autocorrect is suffering from sugar withdrawal. 😬)
Yeah, this was my thinking in a previous PR; I wouldn't want to break links/images, and actually I'd be happy if we could fix a different kind of link, the footer kind: This contains an [awesome] link to something. This here is even [better][awesomer].
[awesome]: http://example.org
[awesomer]: http://example.org Which makes me think we might want to perform Markdown parsing before anything else, assuming we can get it to leave undefined references alone. That is, given: This contains an [awesome] link to something. This here is even [better][awesomer].
[awesomer]: http://example.org It would generate:
|
It seems to leave it alone? Or what do you mean? |
Oops. |
It does. :) I hadn't tested yet and didn't know for sure. However, thinking about backwards compatibility, I wonder about the need to disable conversion within shortcode tags: This contains an [awesome]hello, _world_[/awesome] link to something. This here is even [better][awesomer].
[awesomer]: http://example.org becomes
that destruction between the |
@iseulde, so I made this little bundle of horrors: https://gist.github.com/mcsf/57a4f328ff20ace2b3423bb69c2bcc53 I suggest reading the tests first to get the intention. Showdown's extension mechanism feels a bit clunky—from the docs, it doesn't seem like extensions can be dynamic, per-execution, etc., so this patch definitely cheats a lot. Anyway, it... is possible to disable Markdown parsing of shortcode content using Showdown extensions. 😅 It now ignores Markdown-like syntax here: [my_shortcode]hello, _there_.[/my_shortcode] but not here: **oh**, [unknown]hello, _there_. |
Description
Related: #4942, #4456
Fixes #5335
See Showdown documentation for
literalMidWordUnderscores
option:This change removes a small point of collision between two competing formatting systems: Markdown and WordPress shortcode syntax. It fixes cases where pasting a shortcode like
[my_shortcode]foo bar[/my_shortcode]
would be mishandled due to a perceived emphasis (<em>
) mark in that content.When pasting:
How Has This Been Tested?
Types of changes
Bug fix, but also a decision in what we kind of markdown we want to support. I think this is a good chance in itself, but cc @iseulde for thoughts.
Checklist: