Add autolinking to PEPs

I’d like to request autolinking to PEPs in posts be added to this Discourse.

I clicked on A fast, free threading Python and would have loved a PEP link instead of having to google it.

It seems straightforward based on the limited research I did in

4 Likes

Discourse has a built in feature called Watched Words in the Admin menu under Customize → Watched Words

[Watched Words Reference Guide - admins - Discourse Meta]

As of Discourse v1.9, you can setup Watched Words
Replaces words in posts with links.
[Using Regex with Watched Words - admins - Discourse Meta]
you must first turn on the watched words regular expressions site setting.

Could an admin set this up?

If it doesn’t work could the [Linkify Words - theme-component - Discourse Meta] be added with e.g.
/PEP ([0-9]+)/, https://peps.python.org/pep-0$1?

1 Like

Minor nit - you don’t need the 0 in 0$1. I was going to say that it “doesn’t work”, for example for “PEP 8” and you needed to explicitly 0-pad to 4 digits, but it appears that there are now redirects from the forms without 0-padding to the canonical URL. I don’t know when that was added (it certainly wasn’t announced anywhere that I saw!) but it’s a very welcome addition!

3 Likes

The short links like https://peps.python.org/8 are documented here: PEPS > Canonical links.

The redirects were added in python/peps#2420 in April 2022.

3 Likes

In a funny coincidence, Hugo documented the shortlinks there in direct response to none other than you yourself previously pointing out they were undocumented the last time Hugo let you know about them :joy:

2 Likes

I’d rather have the regex match more (case insensitive and optional space / hyphen from my initial post). Having a couple people’s typing styles fall through the cracks would be annoying as a reader.

1 Like

Perhaps, but the risk here is an increased chance of edge cases (though adding \b at the beginning and end of the pattern would probably filter out most of them), as well as implicitly canonicalizing and encouraging a variety of non-canonical, esoteric and hard to read spellings other than the clear, correct and consistent PEP N. But perhaps I’m being too much of a stickler here.

1 Like