I have a parser function that is not being rendered properly by the experimental Preview tab in WikiEditor. The function does the following:
* It add a custom property "foo" to the ParserOutput object, with value "bar" * It hooks OutputPageBeforeHTML to render the value "bar"
When I use the "Save Page" or "Show Preview" buttons below the edit box everything works fine. With the experimental Preview tab, though, the value doesn't get rendered. (It is in the ParserOutput object though.) I'm guessing that OutputPageBeforeHTML doesn't get called by the Preview tab.
I also tried hooking EditPageGetPreviewText to render the value also, but that doesn't work either with the Preview tab.
Any advice appreciated. Should I be using a better/additional hook?
Thanks, DanB
On Wed, Dec 7, 2011 at 11:58 AM, Daniel Barrett danb@vistaprint.com wrote:
I have a parser function that is not being rendered properly by the experimental Preview tab in WikiEditor. The function does the following:
It add a custom property "foo" to the ParserOutput object, with
value "bar"
It hooks OutputPageBeforeHTML to render the value "bar"
When I use the "Save Page" or "Show Preview" buttons below the edit box everything works fine. With the experimental Preview tab, though, the value doesn't get rendered. (It is in the ParserOutput object though.) I'm guessing that OutputPageBeforeHTML doesn't get called by the Preview tab.
I think what you want to do here is to emit a substitution strip marker from your parser function hook, then let that get substituted back in during final stages of parsing -- this would be equivalent to how tag hooks like <ref> and <nowiki> work.
See CoreParserFunctions::tagObj() which implements the {{#tag:}} parser function (essentially a wrapper around tag hooks using the parser function syntax). This should show how to insert stuff for replacement...
-- brion
On Wed, Dec 7, 2011 at 7:58 PM, Daniel Barrett danb@vistaprint.com wrote:
I have a parser function that is not being rendered properly by the experimental Preview tab in WikiEditor. The function does the following:
- It add a custom property "foo" to the ParserOutput object, with value "bar"
- It hooks OutputPageBeforeHTML to render the value "bar"
When I use the "Save Page" or "Show Preview" buttons below the edit box everything works fine. With the experimental Preview tab, though, the value doesn't get rendered. (It is in the ParserOutput object though.) I'm guessing that OutputPageBeforeHTML doesn't get called by the Preview tab.
I also tried hooking EditPageGetPreviewText to render the value also, but that doesn't work either with the Preview tab.
The OutputPage* and EditPage* hooks are UI hooks. They're not called when parsing things through the API. For reliable results, you need backend-ish hooks, probably in Parser or Article.
Roan
wikitech-l@lists.wikimedia.org