Module:AutoLinker/doc
This is the documentation page for Module:AutoLinker
- Template:AutoLinker Documentation
This template provides a user-friendly interface for the Module:AutoLinker Lua module.
- Installation Instructions
1. **Create the Lua module:**
- Go to your wiki's Module namespace: `Module:AutoLinker` - Copy the complete Lua code (autolinker_module.lua) into the page - Save
2. **Create the template wrapper:**
- Go to your wiki's Template namespace: `Template:AutoLinker` - Copy the template code below into the page - Save
3. **Customize the page list:**
- Edit `Module:AutoLinker` - Modify the `p.getStaticPages()` function - Add/remove page titles that should be auto-linked - Save
---
- Template Code
Copy this into `Template:AutoLinker`:
```
Auto-Linker Tool
Paste text below to automatically link all matching page titles in your wiki.
Input Text: <textarea id="autolinker-input" style="width: 100%; height: 200px; font-family: monospace; padding: 8px; border: 1px solid #ccc;"></textarea>
Output Text (linked): <textarea id="autolinker-output" style="width: 100%; height: 200px; font-family: monospace; padding: 8px; border: 1px solid #ccc; background-color: #fffacd;"></textarea>
<button onclick="autoLinkerProcess()">Process Text</button> <button onclick="autoLinkerCopy()">Copy Output</button> <button onclick="autoLinkerReset()">Reset</button>
Note: This tool uses the static page list. For more control, use the invoke syntax directly:
Lua error: Internal error: The interpreter exited with status 126.
<script> function autoLinkerProcess() {
var inputText = document.getElementById('autolinker-input').value;
var outputText = document.getElementById('autolinker-output');
// For now, show instructions
outputText.value = 'JavaScript method coming soon.\n\n' +
'For immediate results, use the wiki markup syntax below:\n\n' +
'Lua error: Internal error: The interpreter exited with status 126.\n\n' +
'Copy the above into your page, save it, and the linked text will appear.';
}
function autoLinkerCopy() {
var output = document.getElementById('autolinker-output');
output.select();
document.execCommand('copy');
alert('Output copied to clipboard!');
}
function autoLinkerReset() {
document.getElementById('autolinker-input').value = ;
document.getElementById('autolinker-output').value = ;
} </script> ```
---
- Usage Methods
- Method 1: On a Wiki Page (Easiest)
Create a special page (e.g., `Tools:AutoLinker`) and use this syntax:
``` Lua error: Internal error: The interpreter exited with status 126. ```
The page will display the linked text:
``` Your text goes here. This is about Targeted Individuals and Directed Energy Weapons. ```
Copy and paste that result elsewhere.
- Method 2: Using the Template
``` Template:AutoLinker ```
This displays the form interface.
- Method 3: In Your Article
Embed it directly where you want auto-linking:
```
Linked Section
Lua error: Internal error: The interpreter exited with status 126. ```
---
- Advanced Parameters
When calling the module directly, you can use:
``` Lua error: Internal error: The interpreter exited with status 126. ```
- `text`: The input text to process (required) - `mode`: Where to get the page list
- `static` = Use curated list only (fast, requires maintenance) - `dynamic` = Query wiki API (slower, more complete) - `auto` = Try dynamic first, fall back to static (default)
---
- Customizing the Page List
To add or remove pages from auto-linking:
1. Edit `Module:AutoLinker` 2. Find the `p.getStaticPages()` function 3. Add new pages to the return table:
```lua return {
"Your Page Title", "Another Page", -- etc
} ```
- Tips:**
- Add both singular and plural forms if needed - Longer titles first (handled automatically) - Use proper capitalization - Test with `Lua error: Internal error: The interpreter exited with status 126.`
---
- Debugging
To see the list of pages being matched:
``` Lua error: Internal error: The interpreter exited with status 126. ```
To test with sample text:
``` Lua error: Internal error: The interpreter exited with status 126. ```
---
- Limitations & Notes
- **Already linked text** is skipped (won't double-link existing links) - **Maximum 500 matches per invocation** (safety limit, prevents performance issues) - **Whole words only** (matches "Energy Weapons" but not inside other words) - **Performance:** Static mode is fast; dynamic mode slower on large wikis - **Case sensitivity:** Can be toggled in the module config
---
- Troubleshooting
- Nothing is getting linked:**
- Check that page titles in the static list exactly match your wiki pages - Verify the module is in the `Module:` namespace - Test with `Lua error: Internal error: The interpreter exited with status 126.`
- Too many false matches:**
- Add longer, more specific titles to the list first - Reduce the number of generic terms - Use the `wholeWordsOnly` setting
- Performance is slow:**
- Use `mode=static` instead of `mode=auto` - Reduce the static page list - Don't process extremely long texts at once