Parsoid uses the expandtemplates API call to expand parser functions -- but some parser functions can return raw HTML.
In this case, a call to expand x{{#rawhtml2:<a href="http://mahalo.com/">Mahalo</a>}}y'''z''' like:
will return:
{ "expandtemplates": { "wikitext": "x<a href=\"http://mahalo.com/\">Mahalo</a>y'''z'''", "modules": [], "modulescripts": [], "modulestyles": [], "jsconfigvars": {} } }
and this will be mangled by parsoid, since the return value is treated as wikitext and <a> is not valid wikitext.
We probably need to add a new core API specifically for "expand parser function" (not surrounded by wikitext), which can return the isHTML flag from the parser function.
See also: T178584: Remove insertStripItem workarounds from parser function implementations