2

The source code for templates in Wikipedia, Wiktionary, and all MediaWiki is usually written in a congealed lump like this:

<includeonly>{{#if:{{{2|}}}|[[{{{1}}}#{{{2}}}]]|[[{{{1}}}]]}} - [http://www.onelook.com/?w={{urlencode:{{{1|{{PAGENAME}}}}}}}&ls=a OneLook] - {{googles|"{{{1}}}"}}</includeonly><noinclude>{{documentation}}</noinclude>

As you can see it's very hard to read, to match the various kinds of brackets and braces and pipes, etc. It's hard to get any idea what somebody else's template code does.

I'm looking for a code editor on Mac or Windows, even Linux that can both syntax highlight and beautify/indent this code. It would be great if it could also re-minify it back into the congealed lump afterwards so other wiki contributors don't complain (-;

I'd also be interested in a plugin or mode for any existing editor that can add these functions.

  • I can try to make, plugin for CudaText. I need only Python library for Mediawiki minify/ unminify. I cannot find it yet. – RProgram Jun 10 '16 at 10:23
  • I doubt there is such a library, but you never know. It could be as simple as removing all whitespace that's not part of a template name or a string. – hippietrail Jun 11 '16 at 3:07
1

SynWrite (Windows only); CudaText (cross-platform) share the same lexer MediaWiki. Install it using AddonsManager menu. This lexer hilites Mediawiki text as follows:

Synwrite

I don't think some app can minify/unminify Mediawiki. So no plugin exists here.

  • Aha there's a syntax highlighter in some parts of MediaWiki right now. I'm not sure if it's an addon I found or if it's included. It's fine for Wikipedia articles like in your pic. But for dense "magic" template code like in my example with nested double and triple braces it's not enough to figure out what's happening without indent/prettify/beautify. – hippietrail Jun 11 '16 at 22:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.