WMDE Technical Wishes/Bracket Matching

From Meta, a Wikimedia project coordination wiki
Jump to navigation Jump to search

Summary[edit]

Bracket matching is a common feature of text editors used to write source code, but is currently missing from the existing wikitext editors integrated into Wikipedia. The feature highlights pairs of brackets, so that editors can more easily navigate through source code and find any improper or missing matching. It’s particularly useful for nested statements, which are very common in template source code.

Background[edit]

Using the Syntax Highlighting[edit]

Syntax highlighting can be turned on and off in the 2010 wikitext editor using the highlight icon in the toolbar:
Turn on the syntax highlighter in 2010 wikitext editor.png

Syntax highlighting can be found in 2017 wikitext editor under the ‘hamburger menu’ and is by default already turned on:
Turn on the syntax highlighter in 2017 wikitext editor.png

In 2019 the community of the German Wikipedia voted the topic area “Make working with templates easier” as the area where technical improvements are most urgent. Therefore, the Technical Wishes team of Wikimedia Deutschland are working on improvements in this area for two years. More background and further projects can be found here.

The syntax of writing templates in wikitext has grown historically and contains a lot of curly braces ({{}}), making it hard to read and very difficult to work with. The onwiki source editors are primarily made to support writing articles in wikitext and are missing features which help programmers write in source code. Bracket matching is a step towards making working with complex syntax easier in these editors. It was asked for repeatedly by people of the communities, is a proven feature and comparably easy to implement.


Implementation[edit]

This feature will be integrated into the existing syntax highlighter, which is provided by the CodeMirror extension. The syntax highlighter is already available in both the 2017 wikitext editor and the classic 2010 wikitext editor. Currently, it highlights text with different colors, depending on the type of content. Bracket matching will be active in both editors when syntax highlighting is turned on, in any namespace using these editors.

Features[edit]

When the cursor is next to a bracket, both matching brackets are highlighted with a gray background. If the cursor is at an arbitrary position inside two brackets the innermost of the surrounding brackets will be highlighted.

If there are unbalanced brackets – an opening bracket missing its closing counterpart or the other way around – it will be highlighted in red.

Related gadgets and scripts[edit]

There are some existing, community-developed tools which also provide wikitext highlighting. See this comparison for the difference between them and CodeMirror. When using any of these or other editors, you will not get access to this feature. This includes:

Status and Roadmap[edit]

  • Development starts in September 2020

Links[edit]

Feedback[edit]

We are interested in any kind of feedback – please post it on the discussion page. We are also looking for people interested in doing usability testing with our team.