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?
Yes, sure, just explicitly add those
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?
I am fine to simplify this if it corrects these issues.
Skip it cause it has special semantics in markdown (makes something an explicit link)
I guess they are OK
Wohoo, my first PR to Discourse got merged, thanks @sam!
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
I actually have a hardcoded working version of this for anyone interested.
Also, something like this could be very powerful e.g. for creating a glossary or in wiki categories.
I think it’s already there because it’s the new default
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)
Could you psst the screenshot of the error? What is the URL with the error message?
Hmm, I had a look and you may have a superfluous space at the beginning of the URL. Can you please check?
If this is the case, perhaps this theme could automatically trim spaces around URL to prevent this in the future.
The space did the trick. It works fine now
@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.
Thanks for the debug
I’ve made a PR for supporting regular expressions. Happy to take feedback…
Okay, we’re getting closer with the PR.
After this gets merged, the OP will need to be updated. This is the notation that we landed upon:
Note that we support capturing variables to dynamically generate the URLs, so foo234 will autolink to example.com/234.
By default, the regex is case-sensitive (unlike the normal words), but you can add the “i” modifier. Other modifiers are not supported.
@sam also suggests to have some explanatory text below the site-settings, but thb I have no idea how that should be done…
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.
Feature suggestion: links in the form of prefix/suffix.
For example, “pr/1234” linking to
https://github.com/discourse/discourse/pulls/1234 and “pr/1234/files” sticking /files on the end
Configure as maybe “prefix/” and a percent sign or $0 as the replacement key