It sorts out data that has already been processed with a WYSIWYG editor and any data like embedded video etc, then looks at anything else that is a url. The reason it is so complicated is that it must be able to find all websites, not just ones within a very specific context, but it must be able to sort out things that aren’t websites too.
phpbb has a function that does something similar, but it doesn’t work well.
If I type as text:
it will show up to you as a link
but if I only type this:
You will see it as only text.
This is a problem, because you and I can both recognize that all three are links and all three should go to the same place under most circumstances.
There is more to my code than the snippet I included, but that seems to be the section that is picking up an extra space. I was able to fix the display of the code by making
but it is still generating a space before, but now it is being handled properly on rendering in the browser, and it seems all modern browsers can handle it, so it may no longer be an issue, but I would like it to generate proper html if possible.