This is an old revision of the document!
Table of Contents
AutoLink 4 Plugin
Compatible with DokuWiki
greebo
This extension has not been updated in over 2 years. It may no longer be maintained or supported and may have compatibility issues.
Similar to autolink2, autolink3, structautolink
This plugin automatically links text on your page to other pages of your wiki. There are already two other plugins that do this. What makes this one different?
- It's easy to configure.
- It's up to date, and works with the latest version of DokuWiki.
- It doesn't modify the original copies of the page; links are created on demand. This makes it easy to undo changes.
- It works with autotooltip to add tooltips to its links.
More information: Choosing an autolink plugin.
Installation
Install the plugin using the Plugin Manager and the download URL above, which points to latest version of the plugin. Refer to Plugins on how to install plugins manually.
Examples/Usage
This plugin is configured with a list of links in the DokuWiki admin interface. Each line of the configuration consist of three fields separated by commas:
- Text to find. This can include certain regular expression characters, like square brackets and question marks. Pipe (|) and parentheses are not allowed. This plugin always links whole words and phrases. It will never link just part of a word.
- The link for the text.
- The namespace where the replacement is done. Omit this field to replace everywhere.
- Flags. These can include:
- tt: If the Auto-Tooltip plugin is installed, the link will be displayed with a tooltip, including the page title and abstract.
Simple example
Things, mywiki:thing
This links the word “Things” to mywiki:thing, everywhere on your wiki. It only links it when capitalized.
Limiting replacement to a namespace
Things, mywiki:thing, mywiki
The word “Things” will only be replaced inside the “mywiki” namespace.
Tooltips
Things, mywiki:thing, , tt
The link will include a tooltip, which is drawn from the title and abstract of mywiki:thing.
Regular expressions
[Tt]hings?, mywiki:thing
This links the words “Thing,” “thing,” “Things” and “things” to mywiki:thing. Remember that some regular expression characters are not allowed.
Proper ordering
Incredible Things, mywiki:thing Things, mywiki:thing
Replacements are made in the order in which they occur in the configuration. So if you have a short replacement which is contained within a longer one, list the longer one first:
Development
Performance
I tested with 500 regular expression matches, with no noticeable impact on performance. If you scale to several thousand, I recommend limiting the number of regular expression links.
Nerd speak
The algorithmic complexity of this plugin is O(r*u + s), where r is the total number of configured links with regular expression characters, s is the number of configured links without regular expression characters, and u is the number of unique matched text strings on the page.
Change Log
- Work-around for DokuWiki Kaos bug in plugin.info.txt processing (2024-02-11 03:37)
- Work-around for DokuWiki Kaos bug in plugin.info.txt processing (2024-02-11 03:33)
- Fixed deprecated warnings (2024-01-15 19:11)
- Merge branch 'master' of https://github.com/zioth/dokuwiki-autolink4 (2023-12-29 19:00)
- Fixed #17: Errors in log in latest dokuwiki version (2023-12-29 18:59)
- Merge pull request #16 from SneakBug8/patch-1 (2023-12-17 01:26)
- Fix a typo (2023-12-15 22:08)
- Fixed errors in newer versions of php (2023-12-15 17:23)
ToDo/Wish List
- Optionally only link the first occurrence on the page.
- Instead of the link opening up the page, open a pop-up containing the abstract. From there, the user can click to the page.
- If you have more than 500 or so configured links, you reach the maximum number of hooks DokuWiki can handle. This can be fixed by turning this into an action plugin, or by modifying DokuWiki's code to chunk the regex.