Jump to content

Extension:ParagraphLinks

From mediawiki.org
MediaWiki extensions manual
ParagraphLinks
Release status: stable
Implementation User interface
Description Adds hover link icons to section headings for easy copying of direct links to specific sections within wiki pages
Author(s) Luca Mauri
Latest version 1.0.1 (2025-10-04)
Compatibility policy Snapshots releases along with MediaWiki. Master is not backward compatible.
MediaWiki 1.35+
PHP 7.4+
Composer lucamauri/paragraphlinks
License GNU General Public License 3.0 or later
Download
README.md
  • $wgParagraphLinksEnabled - Enable/disable the extension globally (default: true)
  • $wgParagraphLinksNamespaces - Array of namespace IDs where the extension is active (default: [0, 4, 10, 12, 14])

ParagraphLinks is a MediaWiki extension that adds a copy-link icon (🔗) to section headings, allowing users to quickly copy direct links to specific sections within wiki pages. The icon appears on hover next to each heading, similar to the behavior found in popular documentation platforms like GitHub and GitLab.

Features

[edit]
  • Hover-activated link icons on section headings (H2–H6)
  • Automatic anchor detection using existing MediaWiki-generated heading IDs
  • One-click clipboard copying with modern Clipboard API support
  • Responsive design that adapts to different screen sizes
  • Accessibility support with proper ARIA labels and keyboard navigation
  • Configurable namespaces to control where the extension is active
  • No database modifications - purely client-side implementation
  • Mobile-friendly with touch-optimized interface

Installation

[edit]

The extension can be installed either manually or via Composer, the latter is recommended.

Composer installation

[edit]
  1. From your MediaWiki root directory:
    composer require lucamauri/paragraphlinks
    
  2. Add to LocalSettings.php:
    wfLoadExtension( 'ParagraphLinks' );
    
  3. Run the update script if needed:
    php run maintenance/update.php
    

Manual installation

[edit]
  1. Download or clone the extension into your extensions/ directory:
    cd /path/to/mediawiki/extensions/
    git clone https://github.com/lucamauri/paragraphlinks.git ParagraphLinks
    
  2. Add the following line to your LocalSettings.php:
    wfLoadExtension( 'ParagraphLinks' );
    
  3. Run the update script (if prompted):
    php run maintenance/update.php
    

Configuration

[edit]

The extension provides some configuration options:

$wgParagraphLinksEnabled
Enable or disable the extension globally. Default: true
$wgParagraphLinksEnabled = true;
$wgParagraphLinksNamespaces
Array of namespace IDs where paragraph links are enabled. Default includes Main, Project, Template, Help, and Category namespaces.
$wgParagraphLinksNamespaces = [
    NS_MAIN,      // 0 - Main namespace
    NS_PROJECT,   // 4 - Project namespace
    NS_TEMPLATE,  // 10 - Template namespace
    NS_HELP,      // 12 - Help namespace
    NS_CATEGORY   // 14 - Category namespace
];

Usage

[edit]
  1. Navigate to any wiki page with section headings
  2. Hover over a section heading (H2 through H6)
  3. A link icon (🔗) will appear to the left of the heading text
  4. Click the icon to copy the full URL with anchor to your clipboard
  5. A notification will confirm successful copying or alert on failure

See also

[edit]
[edit]