Raw handling: Skip shortcode if not on its own line#19059
Conversation
Improves the existing logic for detection of "inline shortcodes" by ensuring that a shortcodes stands not only at the start of a line/paragraph, but also at the end of one.
| ! /(\n|<p>)\s*$/.test( beforeHTML ) | ||
| ! ( | ||
| /(\n|<p>)\s*$/.test( beforeHTML ) && | ||
| /^\s*(\n|<\/p>)/.test( afterHTML ) |
|
Any issues that this fixes? |
Nothing tracked to my knowledge — just something I stumbled upon. |
There was a problem hiding this comment.
Actually, on second thought I'm going to roll back on the non-capturing group changes. I'm thinking that the fact that we're testing with RegExp::test instead of ::exec or String::match should be enough — and if not, that's something for the VMs to work on!
Quoting from RegExp::test:
Use test() whenever you want to know whether a pattern is found in a string. test() returns a boolean, unlike the String.prototype.search() method, which returns the index (or -1 if not found). To get more information (but with slower execution), use the exec() method (similar to the String.prototype.match() method). As with exec() (or in combination with it), test() called multiple times on the same global regular expression instance will advance past the previous match.
There was a problem hiding this comment.
Sounds good! Thanks for looking into it! :)
96ba092 to
c4b361e
Compare
Description
Improves the existing logic for detection of "inline shortcodes" by ensuring that a shortcodes stands not only at the start of a line/paragraph, but also at the end of one.
Example
The following classic input:
yields:
[foo]A[/foo]followed by Paragraph block with content[foo]B[/foo].[foo]A[/foo] [foo]B[/foo].How has this been tested?
Addition of integration tests.
Checklist: