Looking at Regular expressions - JavaScript | MDN, it seems that \\b is not so great in JS. For example it apparently wouldn’t work for non-latin characters like ě or š. @sam do you agree?
Sure. So if I understand correctly, I’ll just add those explicitly, right?
By the way, it seem that these autolink do not respect the “default other external links in new tab”. Even when this setting is activated, the autolinks open in the same tab. Can somebody replicate this behavior?
I am playing with the regex, but the current behavior is a bit strange.
On one hand, we allow multiple special chars after the word, so link_word,,, will work, but we demand that after these characters, there is a space or endline so this does not work: linked_word..other_word This behavior seems both quite permissive and restrictive at the same time.
You might think those are silly examples, but because we need demand space on the left as well, word lists like link1, link2, link3 actually do not work either in the current code!
Wouldn’t it be much simpler if we just checked one boundary character at both sides and did not care about the rest?
Question 2: What about < >?
Question 3: What about quotation marks? Probably not?
Now for something more ambitious…what about supporting regexes?
I can imagine many use cases:
support for synonyms
word cases, for example in Czech a noun can take 7 different forms depending on the context, with regex I can match all of them easily
In our actual use case, we need to generate the URL dynamically based on what was matched (linking to issues in JIRA). So ideally, something like this should work if I put it into the word list
@Johani now that @joffreyjaffeux added the new fancy control, can you have a look at using it in this component? It will make managing big lists so much easier.
There seems to be a bug with the links when a word or phrase gets linkified… I have Discourse Meta linkified and when I click on it, I get the Oops! This page doesn't exist or is private! message. Here is a photo of the apparent path of the link (which is the correct path btw)
@sam I am surprised that this does not work e.g. that the code does not trim spaces (especially because OP contains examples with spaces!). Would you accept PR fix (although I don’t have time to fix it right away)
That’s on me. I updated the screenshot / settings instructions in the OP not long ago and added those spaces. I just pushed a small fix and the component will now trim words / URLs so white-space shouldn’t matter anymore.
Just FYI: I don’t fully understand what you mean but it might be possible once the regular expressions are supported, see
Hmm, I think it should be fairly easy todo, although there are some details to be discussed. If there is still interest in this feature, I might give it a try, although probably not right away.