Jump to content

Extension:WikiMarkdown

From mediawiki.org
MediaWiki extensions manual
WikiMarkdown
Release status: stable
Implementation Tag , ContentHandler
Description Allows for markdown syntax to be used on wiki pages
Author(s) Nathan Kuenzig (kuenzigntalk)
Latest version 1.1.3
Compatibility policy Master maintains backward compatibility.
MediaWiki 1.35+
Database changes No
License MIT License
Download
README on GitHub
  • $wgAllowMarkdownExtra
‎<markdown>

The WikiMarkdown extension allows for markdown syntax to be used on wiki pages using the ‎<markdown> tag. It is powered by the Parsedown library.

Usage

[edit]

Once installed, you can use ‎<markdown> tags on wiki pages. For example,

Emphasis

[edit]

This is bold text

This is bold text

This is italic text

This is italic text

Strikethrough

is the result of the following wikitext markup:

<markdown>
## Emphasis

**This is bold text**

__This is bold text__

*This is italic text*

_This is italic text_

~~Strikethrough~~
</markdown>

Markdown content handler

[edit]

The extension adds a content handler for markdown pages, which can be edited using a markdown editor when CodeEditor is installed.

Markdown error category

[edit]

The extension adds pages that encountered errors during markdown parsing to a tracking category.

Parameters

[edit]

inline

[edit]

The attribute indicates that the markdown should be inline as part of a paragraph (as opposed to being its own block).

Installation

[edit]

Install Dependencies

[edit]

Make sure your OS has Composer 2.0+ . Installation guide

Add the line "extensions/WikiMarkdown/composer.json" to the "composer.local.json" file in the root directory of your wiki, e.g.

{
	"extra": {
		"merge-plugin": {
			"include": [
				"extensions/WikiMarkdown/composer.json"
			]
		}
	}
}

Then run composer update in the root directory of your wiki. This will install any dependencies (i.e. the Parsedown, Parsedown Extra, and Parsedown Extended libraries).

Install the extension

[edit]
  • Download extension from github and unpack it into 'extensions' folder.
  • Download the GitHub repo and place the file(s) in a directory called WikiMarkdown in your extensions/ folder.
  • Only when installing from Git, run Composer to install PHP dependencies, by issuing composer install --no-dev in the extension directory. (See task T173141 for potential complications.)
  • Add the following code at the bottom of your LocalSettings.php file:
    wfLoadExtension( 'WikiMarkdown' );
    $wgAllowMarkdownExtra = true; // allows usage of Parsedown Extra
    $wgAllowMarkdownExtended = true; // allows usage of Parsedown Extended
    
  • Configure as required.
  • Yes Done – Navigate to Special:Version on your wiki to verify that the extension is successfully installed.

Configuration

[edit]
$wgAllowMarkdownExtra
To enable Parsedown Extra support, set $wgAllowMarkdownExtra = true; (default is "false")
$wgAllowMarkdownExtended
To enable Parsedown Extended support, set $wgAllowMarkdownExtended = true; (default is "false")
$wgParsedownExtendedParameters
Optionally change which parameters are used with Parsedown Extended. Look at the documentation for what options you can turn on or off. This defaults to:
[
    'math' => [
        'single_dollar' => true
    ],
    'sup' => true,
    'sub' => true
]

SyntaxHighlight integration

[edit]

When SyntaxHighlight is installed, the extension will automatically apply its highlighting to markdown code blocks. The code blocks will render the same as the SyntaxHighlight code blocks and will support all the same languages.

Math integration

[edit]

When Math is installed and Parsedown Extended with the math option is available, the extension will automatically use the Math extension to render mathematical equations.

VisualEditor integration

[edit]

The extension enables direct editing with VisualEditor. A popup is opened when a user wants to edit ‎<markdown> sections. For this to work, VisualEditor must be installed and configured from the latest Git version, same for Parsoid.

See also

[edit]