IMHO the question, in this case, is not "how to build the perfect wikitext grammar/parser", but how to ease editing of wikitext through editor enhancements. For that, it seems sufficient to cover the vast majority of cases instead of writing a perfect solution, as long as it falls back to "ugly" wikitext when in doubt. Having 1% of templates appear in all their ugliness is better than 100%.
To that end, I have just written some proof-of-concept JavaScript: http://en.wikipedia.org/wiki/User:Magnus_Manske/tmpl.js It is not a solution, but shows a possible approach (example text to use: [[Picopict]]): * On edit start, it finds all templates in wikitext * It does so only in namespace 0, so no template variables need to be considered (otherwise, move the damned text out of article namespace! ;-) * It will not touch templates that have no parameter - {{reflist}} is easy enough * It will replace all other templates with strings like ##TEMPLATEnumber:name##, e.g., ##TEMPLATE1:Infobox VG## * These will be replaced with the original text again on save/preview/diff * Double-clicking on, say, TEMPLATE1 will select that entire word. If it is a template placeholder, an action is performed. For this demo, it only shows the original text of the template (note that nested templates are left as wikitext). Obviously, this can be expanded to call up an editor of some kind. I don't want to write one now that JQuery is around the corner :-) And yes, I am introducing new syntax. That's not the point here; could just as well be some other, pretty placeholder in a wysiwyg editor. As to the issue of getting possible template variable names: Why not * load the wikitext of the template in the background * remove all nowiki, noinclude, etc * get everything that looks like "{{{NAME|" or "{{{NAME}}}" * remove known magic words * Profit! Cheers, Magnus _______________________________________________ Wikitech-l mailing list [email protected] https://lists.wikimedia.org/mailman/listinfo/wikitech-l
