Hi all,

I'm currently working on an InlineQuery Parser Function called {{#ask}}

So this: <ask format="ul">[[friend of::*]]</ask>

Becomes this: {{#ask:format=ul|[[friend of::*]]}}

I thought I was done, having basically written a wrapper around <ask> that simply uses the Parser Function interface instead of an extension tag.  Unfortunately this will not work as a general purpose solution since the output of <ask> is raw HTML, not Wikitext.

So, it's not going to be as easy as I'd hoped. :(   However, there are at least two solutions:

1) Continue to wrap <ask> and parse the resultant HTML back to wikitext (dirty, dirty hack, but requires no core changes and no core functionality duplication)

2) Implement a range of new SMWQueryPrinter classes, one for each existing type, but outputting the wikitext equivalents of the raw HTML.  So SMWWikiTablePrinter would correspond to SMWTablePrinter, etc.

I'm heavily leaning towards the latter, but because it requires more code, I am again faced with a few options:

1) Duplicate whatever I need to get the job done - for example a new SMWInlineQueries class (SMWInlineWikiQueries) that inherits from the original, but with a "getWikiResult" method.  This option requires no core SMW changes, but results in duplicate code that would have to be kept in sync with newer SMW releases (dirty hack)

2) Add hooks into the SMW core to reduce duplication, but still keep the functionality separate.  An example hook would be at the end of "getHTMLResult" - right after the "switch($this->mFormat)" block.  Something like :

wgRunHooks("SMWInlineQueryGetHTMLResultBeforePrint", array( &$this, &$printer, &$sq ));

Then anyone could plug any printer they wanted in, no questions asked.  This option requires minimal acceptance by the community as the patches would be only a few lines.

3) Actually contribute all this work directly into the SMW core (most elegant solution, but requires buy-in from the community).

So, dear community, what would you have me do?  One way or another, I will have my {{#ask}} function, as I need it for my own site, and I plan to release the code OSS. Is it worth trying to integrate this with the SMW core?

Thank you for considering this - and thanks in advance for your replies!

-- Jim R. Wilson (jimbojw)