Added Linkify words in post Theme

This site can use Linkify words in post (theme)

What this does?

Allows you to automatically hyperlink certain words or patterns in your post with desired destination URL.

Here is a working example

SWISH and SWI-Prolog

If in the line above SWISH and SWI-Prolog are not links it is not working for you.

To see this feature work you may have to change your theme.

  1. In the upper right click on you user icon.
  2. Click on your user name
  3. Click on preferences
  4. In left selection, click on Interface
  5. Under Theme select either Dark, Light or Neutral. This theme (Linkify words in post) is not available with Default.

The words that will be automatically converted to a link are defined in a list only accessible by admins.

If you would like to add a candidate for consideration just reply using the required format


or using regular expressions (in JavaScript implementation ) with the format


You can also reply with more than one item but each item must contain a word and a single corresponding link.

There is no guarantee that if you submit a candidate that it will used, changed or even used then latter changed.

To start I will let the candidates accumulate for several days and the appropriate discussions to take place. :sun_with_face:

Since this applies automatically to preexisting post if this causes problems let @EricGT know so that I can fix the earlier post to present as originally desired.


I guess the obvious one for predicates would be something like


But I suppose that might have too many false positives

1 Like

Nice! Only I see no links :frowning: What I really would like is to make name/arity link to the docs. The only problem is that if we do this with just name/arity it will also create false link for all references to hypothetical/locally defined/… predicates and a regex covering the building and library predicates of SWI-Prolog is rather big (not hard to generate though). I thought we needed to build a plugin for that, but maybe it can be simpler.

If we had the ability to patch the code/inject some javascript to override, I guess it would be fairly simple to add an extra check to make a HEAD request for the URL & only generate the link if it gives a 200.

Most likely reason is that your theme setting is set to Default and needs to be changed. The steps are in the original post. As I just added this, a refresh of the page might be needed.

That is what I thought also, but in reviewing the list of themes saw this and gave it a quick test. You most likely received the idea that it required a plugin from one of my post of days gone by; so it is most likely my fault. :upside_down_face:


This is the post where I wrongly noted this as a plugin. (Note the post is only accessible by admins).

Since Linkify words in post is a theme and open source at GitHub and we can install themes from GitHub, and themes can incorporate JavaScript you might be able to use it as a base and enhance it. :grinning:

1 Like

Oh, we can use arbitrary themes from github? I’ll try forking & making the change then, though I’m not sure how to go about testing locally without installing a whole Discourse thing.

That is what I expected to be needed. Only non-existing predicates gives a 200 page without documentation. Anyway, we can add an API call that returns the URL of the documentation (and possibly some more info such as whether the predicate is built-in or library, the summary docs (which we can add in a title attribute) etc). Then we first need to self-host I’m afraid.

1 Like

First some naming conventions to keep things straight.
There are themes which I will call Primary Theme and Components which are also a theme and which I will call a Component Theme.

Currently this site has 4 primary themes: Dark,Light, Neutral and Default
Currently this site has 3 component themes:
Auto linkify words
Header Links Theme Component

Any user can set their primary theme as noted above.

Admins can install primary themes and component themes. During an install a theme can be selected from a partial list of the popular themes, from your device, from a Git repository (which doesn’t have to be GitHub), or you can create a new one.

For both Primary Themes and Component Themes in the Admin tool, when a specific one of them is selected on the right will appear the theme settings and at the bottom will be a button to Preview the change.

The Preview button gives you the ability to test it locally.

You will have to install the theme before you can get to the Preview button, but after having done this a few times I am more relaxed when doing it.

Since themes are just CSS and JavaScript running after the text for the post has been returned from the SQL query and does not update the database, AFAIK it is totally safe, the worse I expect you can do is mess up the single HTML page you are previewing.

Side note:

The process of installing and getting these themes to work was a bit confusing to me at first but now I am getting the hang of it. Still don’t know if/how I can update the Default theme, but will search/ask at meta Discourse.


We’ll also need to add CORS headers (ref 1, ref 2) to so we can use an ajax (ref) request to check the urls. I was trying to hack something together that just looks at the HTML to try to tell if it’s a real predicate, but I can’t even get that far right now, because of the lack of an Access-Control-Allow-Origin header (ref).

I’ll hack something together. What about


returning a JSON object holding a URL, a summary, a class (builtin, autoload, library), a library (if it is a library or autoload). For now we accept [module:]name{/|//}arity?

Nope. Deleted the cache and reloaded. Still no luck. The is using FF76. Using default theme.

The component theme Linkify words in post is not part of the primary theme Default. I don’t know if/how it can be added to Default.

When a component theme is installed one of the first settings is Include component on these themes, the choice for Default is never allowed.

So to use this, one of the Primary Themes that this component theme is included, i.e. Dark , Light or Neutral, must be selected by a user.

The steps for a user to select/change their theme are in the first post of this topic.

  1. In the upper right click on you user icon.
  2. Click on your user name
  3. Click on preferences
  4. In left selection, click on Interface
  5. Under Theme select either Dark , Light or Neutral . This theme is not available with Default .


That sounds good :+1:

Thanks. After selecting light theme it works. In the end we should try to fix this as the default should be ok …

1 Like


As the theme Default is not available in the admin’s themes page, for the theme Light I am selecting Theme is enabled by default

Hopefully this will make Light the new default and those who have not changed their theme setting will see the changes made by the added component themes as the component themes are included in the Light theme. :crossed_fingers:

The check mark, which was not present in any theme, is now present for the Light theme indicating, based on what I read, that it is the default theme.


More of a response for anyone reading this.

AFAIK, anyone can create a Discourse theme and we can use it here.

The common way to get Discourse themes is to find them in the Discourse theme list, find the GitHub link noted in the theme, then as an admin install the theme using the GitHub link.

As noted above there are additional locations that can be used for installing, GitHub, any Git repository including one on your system or another system, installing from a local system (I don’t know if/the required format). Also admins have an option to create a new one.

The only option I have used thus far is to install from GitHub.

And yes a user could suggest a theme be installed and they would be considered but this is not like a one day sale, there is no rush.

1 Like

@jamesnvc, it would be great if you get the doc-link feature working!! That would be extremely useful.

$ time curl
  "summary":"True if Elem is a member of List.",
real	0m0.384s
user	0m0.005s
sys	0m0.005s
$ curl
  "summary":"Convert between an atom and a list of character codes.",
$ curl
  "summary":"Open the data at the HTTP server as a Prolog stream.",

This gives 404 and JSON null:


The main worry is the round trip time. This is nice for you to experiment with. If we really go for it, the plugin should probably collect all candidates and then do a POST on this handler with a JSON array of candidate documentation links.



See: Need proofread of this advise about using theme preview

1 Like