- Issue created by @peter törnstrand
- Status changed to Needs review
10 months ago 10:04pm 26 January 2024 - 🇺🇸United States Ki
It was not easy to find regex to handle different scenarios. Pushed the fix in the release 8.x-2.0-beta7.
- 🇸🇪Sweden peter törnstrand
Still having issues with this using beta7, if I change the regexp to
#([^"])?(https?://[^\s<]+)([^"])#
it works. Made the first match capturing group optional. - 🇺🇸United States Ki
We'd need to come up with a regex that works with ckeditor 4, ckeditor 5, and no editor. Will the suggested fix satisfy it?
- 🇸🇪Sweden peter törnstrand
Sorry for late reply. I have not tried it beyond my own use case. I will test and report my findings.
- Status changed to RTBC
9 months ago 12:46pm 28 February 2024 - 🇸🇪Sweden peter törnstrand
Yes, the pattern
#([^"])?(https?://[^\s<]+)([^"])#
works for all three cases. - Status changed to Fixed
9 months ago 11:45pm 1 March 2024 - 🇺🇸United States Ki
Applied the fix.
This is almost identical to the pattern for `Replace in-line URLs` option, though. Now I wonder if I should get rid of the option, which is getting irrelevant.
- 🇺🇸United States loze Los Angeles
This now fails for me when using no text editor and there are no characters following the url, see screenshot
This patch fixes it for me.
- Status changed to Needs review
9 months ago 7:13am 3 March 2024 - 🇺🇸United States Ki
Peter Törnstrand
I've applied loze's patch and pushed to the latest 8.x-2.x-dev version.
Could you it works for you?
Thanks.
Ki - Status changed to Needs work
8 months ago 5:42am 10 March 2024 - 🇺🇸United States loze Los Angeles
After further testing testing these latests commit, the regex still fails in a few places
in particular the url inside the tag gets converted to a video in the following example.
<a href="https://www.youtube.com/watch?v=CsGQOPLGImA">https://www.youtube.com/watch?v=CsGQOPLGImA</a>
Also some urls that do not have an enabled provider are mangled. for example:
the website <a href="https://drupal.org"><em>Drupal</em></a>
displays broken html, see screenshot - Status changed to Needs review
8 months ago 6:20am 10 March 2024 - 🇺🇸United States loze Los Angeles
I think is regex should work
'#(<p>|\n|^)(https?://\S+)(</p>|\n|$)#'
This works with ckeditor and without in my testing when urls are on their own line.
It also works for Peter Törnstrand's use case when it is the only text in the textarea. - 🇺🇸United States loze Los Angeles
the regex in #16 still failed in some cases. Try this one, It seems to work.
'#(<p>|\n|^)?(https?://[^\s<]+)(</p>|\n|$)?#'
- 🇺🇸United States Ki
It seems one regex that works for one easily breaks another. I'll try to find time to do tests, but I'd appreciate those in the thread test their case and work together to come up with a regex that works for all cases. Or is that actually possible? Should we introduce a checkbox setting to handle ckeditor5 as an exceptional case? Since ckeditor5 merges all lines into one in the backend, it is essentially no different from the option setting "Replace in-line URLs"
- 🇺🇸United States mortona2k Seattle
The links on my site broke after enabling this module.
I'm using the "Convert urls into links" filter, and this is causing them to render with broken html.
I think this meets the criteria for a major bug. https://www.drupal.org/docs/develop/issues/fields-and-other-parts-of-an-... →
- 🇺🇸United States Ki
Attempt to support ckeditor 5's behavior of saving content source in one line caused too much trouble. The behavior existed for a while and seems to have gone now.
I have reverted the regex back to old simple one. Instead, I've revised the regex for in-line URL option and updated the description for the "Replace in-line URLs" checkbox to "Recognize in-line URLs. Enable too if the wysiwyg editor saves the content source in one line."
The update has been released in beta-9 version for review and testing.
@mortona2k
If you are a new user of the module, please make sure that the filter for "Convert URLs into links" comes after. As mentioned in README, the order of filters is important for the soembed filter to work.Thanks.