Opened 9 years ago
Closed 8 years ago
#37693 closed defect (bug) (fixed)
TinyMCE: backtics not handled correctly in paragraphs that already contain backticks
Reported by: |
|
Owned by: |
|
---|---|---|---|
Milestone: | 4.7 | Priority: | normal |
Severity: | normal | Version: | 4.3 |
Component: | TinyMCE | Keywords: | has-patch |
Focuses: | javascript | Cc: |
Description
Steps to reproduce:
- Have a paragraph that contains literal backticks. For example, copy this to TinyMCE:
In this paragraph with `backticks`, try to add some more.
- Anywhere in this paragraph, enter
`test`
and press a spacebar.
It should convert it to <code>test</code>
but it doesn't.
My guess is that a regex or something similar doesn't handle multiple backtics in a paragraph correctly.
Attachments (13)
Change History (38)
This ticket was mentioned in Slack in #core-tinymce by borekb. View the logs.
9 years ago
This ticket was mentioned in Slack in #core by jeffpaul. View the logs.
9 years ago
This ticket was mentioned in Slack in #core by jeffpaul. View the logs.
9 years ago
This ticket was mentioned in Slack in #core by jeffpaul. View the logs.
9 years ago
#9
@
8 years ago
- Focuses javascript added
- Keywords has-patch added; needs-patch removed
- Status changed from assigned to reviewing
This last patch should work well. @borekb, could you please test the patch, if you can? @azaozz, could you please test and review?
A test case has been added, and because of the scope of the change, I added a test case for patterns with two characters. There was once a test for that, but was removed after removing the bold pattern. We should still test it though as it should work.
#12
@
8 years ago
- Resolution fixed deleted
- Status changed from closed to reopened
Yeah, that broke multi-character patterns when they use the same characters as single-character pattern, like **
and *
. I know we don't use any of there at the moment, but may in the future, or a plugin can add them.
In 37693.6.patch attempting to fix this. Expects that the patterns are sorted by priority: longer patterns first. This also changes the behaviour to support the pattern characters to appear in the string. Example:
__
and_
are registered;- Typing
__ $var_name __
should properly replace the starting and ending__
and leave the_
in the middle.
This still needs testing and is a change in behaviour. Few tests may need updating too (fail at the moment).
This ticket was mentioned in Slack in #core by helen. View the logs.
8 years ago
#16
follow-up:
↓ 18
@
8 years ago
37693.9.patch looks good. 37693.10.patch adds some cleanup and changes it to test for a white space or start of line before the pattern, instead of looking for the first char of the pattern (as we discussed in #core-editor). So if the pattern is *
, test* test*
will not trigger it, and test *test*
will.
#18
in reply to:
↑ 16
@
8 years ago
Replying to azaozz:
37693.9.patch looks good. 37693.10.patch adds some cleanup and changes it to test for a white space or start of line before the pattern, instead of looking for the first char of the pattern (as we discussed in #core-editor). So if the pattern is
*
,test* test*
will not trigger it, andtest *test*
will.
That looks good. The only case I have where I would expect it to trigger is something like some*thing*
. I agree that we shouldn't allow it when there is whitespace after the starting pattern though. So maybe some* thing*
should not trigger it, but some *thing*
and some*thing*
should.
#20
@
8 years ago
But the last patch does again not allow this:
Typing
__ $var_name __
should properly replace the starting and ending__
and leave the_
in the middle.
It seems we need to choose. Either we allow test*test*
or we allow the above. We can't do both I think.
#21
@
8 years ago
Also, let's keep in mind that we added this to allow simple shortcuts, not to fully support markdown. I think bold and italic inside words will be more useful than allowing delimiter characters inside the text. It cannot be solved anyway for something like _$var_name_
, only __$var_name__
, so the rule is a bit weird in my opinion. Additionally I think *
delimiters are bit better for this, and if _
is used, the conversion can still be undone easily.
#22
@
8 years ago
Example text: "It's WordPress, not Wordpress."
It can be used to emphasise mistakes, emphasise a syllable or a free morpheme in a compound.
Confirmed.