# Automatic package links

**URL:** <https://discourse.julialang.org/t/automatic-package-links/106275>\
**Category:** Meta Discussion\
**Created:** [November 15, 2023, 5:44pm UTC](https://discourse.julialang.org/t/automatic-package-links/106275 "2023-11-15T17:44:25Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mason](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mason/32/2423_2.png) [@Mason](https://discourse.julialang.org/u/Mason)\
**Post date:** [November 15, 2023, 5:44pm UTC](https://discourse.julialang.org/t/automatic-package-links/106275/1 "2023-11-15T17:44:25Z")

</div>

In the [Julia Zulip server](https://julialang.zulipchat.com/), we have something called “linkifiers” which basically just use a regex to detect specific patterns in text, and turn them into links automatically. The main thing we use this for is to turn strings like “DifferentialEquations.jl” into an automatic link pointing to the JuliaHub page for DifferentialEquations: https://juliahub.com/ui/Packages/General/DifferentialEquations, which should work for any package on the general registry. (previously, we did a Github search, but we switched to JuliaHub around a month ago and it’s been mostly good!)

I find this feature quite nice and convenient, and learned recently that it’s actually also available on recent versions of Discourse as an built-in feature: [Watched Words Reference Guide - admins - Discourse Meta](https://meta.discourse.org/t/watched-words-reference-guide/241735#link-7) and also for as an extension: [Linkify Words - theme-component - Discourse Meta](https://meta.discourse.org/t/linkify-words-in-post/82193)

Is this something people would be interested in having on Discourse? I quite like it in Zulip, so maybe if there’s enough interest, the admins here on Discourse could enable it?

Here’s a little poll if people want to weigh in that way:

_Poll ([view on site](https://discourse.julialang.org/t/automatic-package-links/106275/1))_

---

<div class="post-metadata">

**Author:** ![mbauman](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mbauman/32/31082_2.png) [@mbauman](https://discourse.julialang.org/u/mbauman)\
**Post date:** [November 15, 2023, 7:17pm UTC](https://discourse.julialang.org/t/automatic-package-links/106275/2 "2023-11-15T19:17:16Z")

</div>

I think this is a great idea! As a hosted instance, we don’t have regexes enabled on our watched words, but the theme component seems to work.

I see the Zulip has the following regexes, which I think we could just replicate here:

 ![image](https://global.discourse-cdn.com/julialang/original/3X/c/0/c051de1f09f16644d37e7f0c76098bad643aa98c.png)

---

<div class="post-metadata">

**Author:** ![Mason](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mason/32/2423_2.png) [@Mason](https://discourse.julialang.org/u/Mason)\
**Post date:** [November 16, 2023, 8:00pm UTC](https://discourse.julialang.org/t/automatic-package-links/106275/3 "2023-11-16T20:00:02Z")

</div>

people voting for “I don’t want this specific implementation, but want something similar”, it’d be helpful to comment on what that similar thing you want is. Sorry, I should have mentioned in the original post.

---

<div class="post-metadata">

**Author:** ![mbauman](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mbauman/32/31082_2.png) [@mbauman](https://discourse.julialang.org/u/mbauman)\
**Post date:** [November 20, 2023, 3:56pm UTC](https://discourse.julialang.org/t/automatic-package-links/106275/4 "2023-11-20T15:56:01Z")

</div>

Thanks everyone for your input! Looks like we have a solid majority in favor, let’s try it out. Here’s what I’ve implemented (note that you may need to refresh to get the links):

This is a Julia issue: julia#265  
These are Julia commits: julia@7327a8f, julia@72cd63ce28c50c8c72e009df03dfec608802450e  
This is a package issue: JuliaStats/Distributions.jl#123  
This is a registered package ~~info page on JuliaHub:~~ Distributions.jl  
This is a GitHub package link: JuliaStats/Distributions.jl

If you see anything awry or have other suggestions, please make your voice known!

@Mason, just FYI, I added `\b`s to the beginning of these regexes, which isn’t how it’s configured on Zulip. It may help reduce some false positives, like someone writing path/to/src/SubModule/SubModule.jl without ``s.

I wonder if and/or how we could display these rules. Unlike [Zulip](https://julialang.zulipchat.com/#organization/linkifier-settings), by default Discourse doesn’t display these to users (I don’t think). Anyhow, these are the rules as of right now (the component doesn’t support named groups):

```regex
/\b[jJ]ulia\#([0-9]+)/, https://github.com/JuliaLang/julia/issues/$1
/\bjulia@([0-9a-f]{4,40})/, https://github.com/JuliaLang/julia/commit/$1
/\b([a-zA-Z0-9_-]+)/([a-zA-Z0-9._-]+)#([0-9]+)/, https://github.com/$1/$2/issues/$3
/\b([A-Z][a-zA-Z0-9_-]+)(.jl)/, https://juliahub.com/ui/Packages/$1
/\b([a-zA-Z0-9_-]+)/([a-zA-Z0-9._-]+.jl)/, https://github.com/$1/$2

```

---

<div class="post-metadata">

**Author:** ![ChrisRackauckas](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/chrisrackauckas/32/77_2.png) [@ChrisRackauckas](https://discourse.julialang.org/u/ChrisRackauckas)\
**Post date:** [November 21, 2023, 11:20am UTC](https://discourse.julialang.org/t/automatic-package-links/106275/5 "2023-11-21T11:20:37Z")

</div>

Just saw this today on DifferentialEquations.jl, such a great feature, thanks for adding!

---

<div class="post-metadata">

**Author:** ![fredrikekre](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/fredrikekre/32/1688_2.png) [@fredrikekre](https://discourse.julialang.org/u/fredrikekre)\
**Post date:** [April 16, 2024, 9:31am UTC](https://discourse.julialang.org/t/automatic-package-links/106275/6 "2024-04-16T09:31:02Z")

</div>

The `.` in `.jl` in the regexes should be escaped to not match any character. I noticed this while trying to opt out of this feature in some places (e.g. it looks a bit silly in Markdown headers IMO) but replacing `.` with e.g. `․` ( U+2024 but looks like it is normalized to `.` on here) or some other dot looking character didn’t work. Is there another way to opt out?

---

<div class="post-metadata">

**Author:** ![abraemer](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/abraemer/32/51403_2.png) [@abraemer](https://discourse.julialang.org/u/abraemer)\
**Post date:** [April 16, 2024, 9:34am UTC](https://discourse.julialang.org/t/automatic-package-links/106275/7 "2024-04-16T09:34:48Z")

</div>

You could use `…` to escape: `PackageName.jl`

---

<div class="post-metadata">

**Author:** ![fredrikekre](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/fredrikekre/32/1688_2.png) [@fredrikekre](https://discourse.julialang.org/u/fredrikekre)\
**Post date:** [April 16, 2024, 9:36am UTC](https://discourse.julialang.org/t/automatic-package-links/106275/8 "2024-04-16T09:36:33Z")

</div>

Sure, but doesn’t look as nice and it isn’t code after all.

---

<div class="post-metadata">

**Author:** ![mbauman](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mbauman/32/31082_2.png) [@mbauman](https://discourse.julialang.org/u/mbauman)\
**Post date:** [April 16, 2024, 12:34pm UTC](https://discourse.julialang.org/t/automatic-package-links/106275/9 "2024-04-16T12:34:08Z")

</div>

Hah, sure enough, whoops. Asdfjl used to be a package link!

In addition to `Backticks.jl` you can also **Bold.jl** or _Italics.jl_.

---

<div class="post-metadata">

**Author:** ![fredrikekre](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/fredrikekre/32/1688_2.png) [@fredrikekre](https://discourse.julialang.org/u/fredrikekre)\
**Post date:** [April 16, 2024, 12:53pm UTC](https://discourse.julialang.org/t/automatic-package-links/106275/10 "2024-04-16T12:53:29Z")

</div>

> [@mbauman](#):
>
> In addition to `Backticks.jl` you can also **[Bold.jl](https://juliahub.com/ui/Packages/General/Bold)** or _[Italics.jl](https://juliahub.com/ui/Packages/General/Italics)_.

Both of those are links though. Edit: Ok, not after a force reload of the page…

---

<div class="post-metadata">

**Author:** ![mbauman](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mbauman/32/31082_2.png) [@mbauman](https://discourse.julialang.org/u/mbauman)\
**Post date:** [April 16, 2024, 12:54pm UTC](https://discourse.julialang.org/t/automatic-package-links/106275/11 "2024-04-16T12:54:13Z")

</div>

Reload your browser. 🙂 I just added them.

I can also add any other HTML tags to opt out.

---

<div class="post-metadata">

**Author:** ![Mason](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mason/32/2423_2.png) [@Mason](https://discourse.julialang.org/u/Mason)\
**Post date:** [December 4, 2024, 1:02pm UTC](https://discourse.julialang.org/t/automatic-package-links/106275/12 "2024-12-04T13:02:42Z")

</div>

Given the problems reported in other threads (e.g. [Automatic package link pages have poor layout](https://discourse.julialang.org/t/automatic-package-link-pages-have-poor-layout/123087)) with the juliahub generated READMEs / docs, i wonder if it’d be possible to make the linkifier send people directly to the `source` link rather than the juliahub-generated README, since there’s a better chance of the content being correctly displayed on the original hosting platform

---

<div class="post-metadata">

**Author:** ![jules](https://avatars.discourse-cdn.com/v4/letter/j/41988e/32.png) [@jules](https://discourse.julialang.org/u/jules)\
**Post date:** [December 4, 2024, 4:52pm UTC](https://discourse.julialang.org/t/automatic-package-links/106275/13 "2024-12-04T16:52:15Z")

</div>

That’s what I implemented here via GitHub pages [Automatic package link pages have poor layout - #7 by jules](https://discourse.julialang.org/t/automatic-package-link-pages-have-poor-layout/123087/7)

We could add that to the General Registry CI in principle

---

<div class="post-metadata">

**Author:** ![Mason](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mason/32/2423_2.png) [@Mason](https://discourse.julialang.org/u/Mason)\
**Post date:** [December 4, 2024, 10:56pm UTC](https://discourse.julialang.org/t/automatic-package-links/106275/14 "2024-12-04T22:56:10Z")

</div>

oh very nice. I think if we just used this technique and then set up a github action to update it with new links from the general registry a couple times a day, that’d be pretty close to a perfect solution

---

<div class="post-metadata">

**Author:** ![jules](https://avatars.discourse-cdn.com/v4/letter/j/41988e/32.png) [@jules](https://discourse.julialang.org/u/jules)\
**Post date:** [December 4, 2024, 11:50pm UTC](https://discourse.julialang.org/t/automatic-package-links/106275/15 "2024-12-04T23:50:45Z")

</div>

I can make a PR

---

<div class="post-metadata">

**Author:** ![jules](https://avatars.discourse-cdn.com/v4/letter/j/41988e/32.png) [@jules](https://discourse.julialang.org/u/jules)\
**Post date:** [December 19, 2024, 10:51am UTC](https://discourse.julialang.org/t/automatic-package-links/106275/16 "2024-12-19T10:51:42Z")

</div>

This work is now done, we could linkify here on discourse using this format:

- a link that automatically redirects  
[https://juliaregistries.github.io/General/packages/redirect\_to\_repo/Makie](https://juliaregistries.github.io/General/packages/redirect_to_repo/Makie)
- a link that doesn’t automatically redirect due to the unusual host  
[https://juliaregistries.github.io/General/packages/redirect\_to\_repo/InPartS](https://juliaregistries.github.io/General/packages/redirect_to_repo/InPartS)
- a link that 404s as no package of that name is registered  
[https://juliaregistries.github.io/General/packages/redirect\_to\_repo/DoesNotExist](https://juliaregistries.github.io/General/packages/redirect_to_repo/DoesNotExist)

---

<div class="post-metadata">

**Author:** ![Mason](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mason/32/2423_2.png) [@Mason](https://discourse.julialang.org/u/Mason)\
**Post date:** [December 20, 2024, 2:13pm UTC](https://discourse.julialang.org/t/automatic-package-links/106275/17 "2024-12-20T14:13:56Z")

</div>

We’re now using these linkifiers on Zulip and it’s really nice. Thank you again for putting in the work to make these redirect pages @jules.

@mbauman what do you think? Can we switch the Discourse linkifiers to use these redirect pages from the General Registry? I think this solution is a much better fit than the JuliaHub pages because

- it’s significantly faster to load
- Authors _intend_ for people to visit their repos, and they have control over those repos, unlike the JuliaHub pages (i.e. if a problem comes up with their presentation, they know and they can change it), so it feels like a disservice to send people somewhere that they have no control over.
- it gives more immediate access to things like issues / pull requests / giving stars
- Most authors don’t check the JuliaHub pages and don’t know if auto-generated pages screwed up their docs or their README (this has happened to me before and was quite aggravating, especially because after I discovered it, there was no way to fix it other than switch from using Org to Markdown for my README.)
- The General Registry 404 fallback page is significantly more helpful for finding non-registered packages, or dealing with misspelt package names

---

<div class="post-metadata">

**Author:** ![StefanKarpinski](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stefankarpinski/32/24_2.png) [@StefanKarpinski](https://discourse.julialang.org/u/StefanKarpinski)\
**Post date:** [December 22, 2024, 3:29pm UTC](https://discourse.julialang.org/t/automatic-package-links/106275/18 "2024-12-22T15:29:57Z")

</div>

Seems like a good change to me. The JuliaHub hosted docs were meant to be a service to the community but they’ve caused as much trouble as they’ve helped. Let’s go ahead and switch to the new linkifiers.

---

<div class="post-metadata">

**Author:** ![Mason](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mason/32/2423_2.png) [@Mason](https://discourse.julialang.org/u/Mason)\
**Post date:** [December 22, 2024, 4:05pm UTC](https://discourse.julialang.org/t/automatic-package-links/106275/19 "2024-12-22T16:05:52Z")

</div>

> [@StefanKarpinski](#):
>
> The JuliaHub hosted docs were meant to be a service to the community

And just to be clear I don’t want to be too negative, or imply anything bad about the intentions behind them. I think it was a well intentioned idea, and I still think it’s good that they exist (though perhaps the build process needs some work).

It was even my (not JuliaHub affiliated) suggestion at the start of this thread to introduce these linkifiers that point to the JuliaHub pages because I thought they were a great idea. But I think after trying them out for a while they’re not such a great fit for the main way to link to a package on a place like Discourse or Zulip. Now that we have a way to link to the original repo, it’d be good to give that a try.

Sometimes you only know if the problems with an idea are minor or major once you try it out.

---

<div class="post-metadata">

**Author:** ![mbauman](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mbauman/32/31082_2.png) [@mbauman](https://discourse.julialang.org/u/mbauman)\
**Post date:** [December 22, 2024, 7:42pm UTC](https://discourse.julialang.org/t/automatic-package-links/106275/20 "2024-12-22T19:42:34Z")

</div>

Thanks so much for doing this @jules! I’ve just updated the rules; reload your page and all previously auto-linkified package names should use the new direct-to-repo service (although note this doesn’t apply to quotes, which hardcode the link at the time of authoring).

Let me know if anything isn’t working!
