Last modified: 2012-05-19 12:39:45 UTC
In my extension, I have implemented server-side parser function which also has client-side "parser function editor" implemented as ResourceLoader module. In that module user may input wikitext of single parser function's parameter into form field and then the source wikitext of the whole parser function is displayed (so it can be copy/pasted into actual page). There is one problem, function has unnamed parameters and when the user places pipe character "|" into the input field, it starts new parameter instead of becoming part of the single parameter's text, which breaks editor logic. I cannot simply escape all occurencies of "|" as entity | because it would break wikilinks [[|]] and template parameters {{|}}. So I have to parse the wikitext somewhat and replace only non-lexical "|" to |. I am trying to use 'mediawiki.jqueryMsg' module in the following way: var parser = new mw.jqueryMsg.parser(); var ast = parser.wikiTextToAst( text ); However, even for very simple and valid wikitext like this: a[[link]]1 {{tpl:a|b}} asdf|ghij it throws an errors: Uncaught Error: Parse error at position 11 in input: a[[link]]1 {{#tpl:a|b}} asdf|ghij /resources/mediawiki/mediawiki.jqueryMsg.js:502 I wanted to build AST tree then expected to rebuild wikitext recursively with espaced pipe characters only in 'CONCAT' nodes. Is that possible? I do not need html output. I am developing for 1.18, when encountered this error tried 1.20 master, however the problem still exists.
Sorry - seems to got confused with markup, tpl:a is not valid name. Builds AST tree with the following wikitext just file: a[[link]]1 {{tpl|a|b}} asdf|ghij