
roan.kattouw at gmail
Aug 8, 2009, 11:04 AM
Post #6 of 6
(735 views)
Permalink
|
|
Re: ParseTree generated by the API and tag extension
[In reply to]
|
|
2009/8/8 Alex Bernier <alex.bernier [at] free>: > Is it possible to call the preprocessor in the <foo> handler ? > Indirectly, that's what's already happening, but in a later stage. The sequence of events is: 1. Preprocessor recognizes <foo>blah<bar>blah</bar>blah</foo> as an extension tag <foo> with content "blah<bar>blah</bar>blah" 2. Entry from 1. ends up in the parse tree 3. When parsing, the handler for <foo> is invoked, which does something with the tag contents ("blah<bar>blah</bar>blah") and calls recursiveTagParse() on them. 3a. This causes the preprocessor to be run on "blah<bar>blah</bar>blah", which dissects it into a literal "blah", an extension tag <bar> with content "blah", and another literal "blah". 3b. Based on this dissection, the parser calls the <bar> handler 3c. recursiveTagParse() returns the return value of the <bar> handler surrounded with "blah" 3d. The <foo> handler returns something 4. The parser inserts the return value of the <foo> handler in the HTML output As you can see, there's nested parsing going on here, and the fact that there's a <bar> tag inside the <foo> tag is only discovered in the inner parse (step 3a), which means it doesn't end up in the parse tree of the outer parse (step 2). The reason it works this way is that some tags don't *want* their contents to be parsed or preprocessed, because they treat it as plain text, not wikitext. Roan Kattouw (Catrope) _______________________________________________ Wikitech-l mailing list Wikitech-l [at] lists https://lists.wikimedia.org/mailman/listinfo/wikitech-l
|