Jump to content

User:EpochFail/Syntax highlighter article

From Wikipedia, the free encyclopedia

This article is part of a series on new tools available to Wikipedians. The tool being discussed is the gadget labeled "Dot's syntax highlighter".

Why does Wikipedia need syntax highlighting?

[edit]

Wikitext was meant to be a simple syntax for creating and editing articles with simple text formatting, but in practice articles require complex syntax to meld article content with templates and references. Over time, articles tend to grow so complex that just finding the text of the article often requires wading through blobs of obtuse syntax. The sheer complexity of the system deters new editors and wastes the time of experienced editors.

Syntax highlighting helps by color-coding different kinds of syntax. It's not a new concept; it's familiar to every student of computer science becuase syntax highlighting has been a feature of text and code editors such as gedit and nano for as long as I can remember. Aside from visually distinguishing code from content, syntax highlighters help you spot syntax errors before you even click "Show preview".

How does the gadget work?

[edit]
The syntax highlighter in action

The syntax highlighter gadget is listed in Preferences, Gadgets as "Dot's syntax highlighter". Installation is point-and-click. The gadget is designed to be simple and unobtrusive; it follows the Unix philosophy: "Do one thing, and do it well." References turn pink, templates turn yellow, links turn blue, and other syntaxes turn various colors also. If you find these colors unappealing, instructions are provided on how to customize the colors used.

The gadget works best in Firefox. Chrome and Opera come in second place but have problems editing text in Thai and Tibetan. Internet Explorer does not work at all. The bottom line is that the syntax highlighter almost always works excellently, but your mileage may vary.

Why hasn't such a feature been implemented before?

[edit]

Well, the main reason is that the World Wide Web and HTML specifically were not envisioned to serve every purpose under the sun. Complex applications, such as syntax highlighting text editors, were meant to be implemented as desktop applications or browser plugins. Still, I wanted something simpler to write than a browser plugin and easier to install. Others have tried before and come up with wikEd and AceWikiEditor, but wikEd does not update syntax highlighting automatically, AceWikiEditor breaks spellcheck, and both tend to break other gadgets that assist in editing. Again, I wanted something that "just works" and I am happy with the result. The latest database reports suggest that at least 1,512 others on the English Wikipedia are happy with it too.

What about the VisualEditor project?

[edit]

The VisualEditor has a much more ambitious goal than syntax highlighting. It aims to provide a complete what-you-see-is-what-you-get editor that pretty much does away with wikitext altogether. This approach is certainly more intuitive, but it tends to give you less control over the page and suffers from similar problems as wikEd and AceWikiEditor. To address this problem the VisualEditor is expected to have a mode for editing wikitext with syntax highlighting, but this has not yet been implemented. In writing my own syntax highlighter, I hope to provide Wikipedians with an alternative and set a standard of quality for the VisualEditor and other future developments.