Page MenuHomePhabricator

Move CodeMirror's MediaWiki mode into a separate library
Open, LowestPublic

Description

It would be really awesome if CodeMirror's MediaWiki mode was a separate library.
https://github.com/wikimedia/mediawiki-extensions-CodeMirror/tree/master/resources/modes/mediawiki

That way wikitext can be syntax highlighted in applications other than MediaWiki itself (i.e. using the API to post a wiki).

Event Timeline

Wikitext syntax highlighting depend on mediawiki settings such as site language, extension installed and etc.
Thus it is not possible to make a general mediawiki mode аnd in the future this dependence will only increase.

Niharika triaged this task as Lowest priority.Nov 7 2017, 11:49 PM

What can be done, is to move the mediawiki specific config into a configuration object (like now), but provide 'sane' default fallbacks. That would allow to make it flexible enough for us and to redistribute for others (who likely don't need our complexity) and allow them to configure/override/amend however their situation requires....

Is the mode self-contained enough to be able to be contributed back to the CodeMirror project? I don't see MediaWiki in the supported modes for CodeMirror itself. I'm thinking that if CodeMirror itself supports MediaWiki as a mode, then at least any CodeMirror product (e.g. MediaWiki widget) would be capable of editing WikiText.

The feature that I'm really after is the ability to highlight MediaWiki syntax "on-wiki" (as supported by extension:SyntaxHighlight and the Pygments library) for simple documentation of Wiki syntax for editors; but MediaWiki isn't supported there either. See Add “wikitext” as language in Pygments: https://phabricator.wikimedia.org/T29828 And the same issue upstream in the Pygments GitHub issue tracker.

I'm thinking that if there is a lexer for MediaWiki, even if it's in JavaScript for the CodeMirror project, then we're one step closer to getting a PHP implementation for the Pygments project.

In case someone may be interested, I have made an attempt to create a standalone library @bhsd/codemirror-wikitext.

Reedy renamed this task from Move Code Mirror's Mediawiki Mode into a separate library to Move Code Mirror's MediaWiki Mode into a separate library.Jan 3 2026, 4:13 PM
Mr._Starfleet_Command renamed this task from Move Code Mirror's MediaWiki Mode into a separate library to Move CodeMirror's MediaWiki mode into a separate library.Fri, Apr 17, 12:24 AM
Mr._Starfleet_Command updated the task description. (Show Details)