Page MenuHomePhabricator

Implement brace matching in page editing
Open, LowPublicFeature


I propose implementing brace matching in page editing. This would make it easier to write, maintain and troubleshoot complicated templates.

Especially when nested #if, #switch, and other parser functions are involved, it can get hard to pinpoint an error or even figure out how the template works just from looking at the markup. Brace matching is a useful type of syntax highlighting for seeing where each statement begins and ends and navigating through the markup.

Moreover, with all the variables, magic words, parser functions, etc. that have double or triple braces, it can be easy to leave off a brace somewhere and accidentally place an extra one somewhere else, resulting in subtle errors. With brace matching, it could be easier to find those mismatched braces. Some brace matching implementations ignore braces contained in comments. Mediawiki's brace matching might also ignore braces within nowikis (e.g. <nowiki>{<nowiki>).

Version: unspecified
Severity: enhancement



Event Timeline

bzimport raised the priority of this task from to Low.Nov 21 2014, 10:04 PM
bzimport set Reference to bz13302.
bzimport added a subscriber: Unknown Object (MLST).

I second this. We already have brace matching for Lua modules. Can we simply adapt the [[mw:Extension:CodeEditor]] code for the template namespace as well? The ability to match curly braces would be extremely useful for template editors.

Schnark added a subscriber: Schnark.

This should probably be done in the CodeMirror extension, that now provides syntaxhighlighting for wikitext as a beta feature.

Very good idea. I suggest to add tagging matching (<div> as open, </div> as close, <div/> as ignored).

At WMDE Technical Wishes we implemented bracket matching in the CodeMirror extension. This feature is currently deployed in some wikis for testing. It will be deployed for all wikis in the course of this year. For more info see our project page at

Aklapper changed the subtype of this task from "Task" to "Feature Request".Feb 4 2022, 11:01 AM
Aklapper removed a subscriber: wikibugs-l-list.