On 02/23/2016 02:30 PM, James Montalvo wrote:
Thank you for the quick reply!

Unless I'm misunderstanding, I don't believe "noparse" is the culprit for
the external images. Your explanation certainly explains the behavior of
[[File:Test.png]] when I had "noparse"=true, since in view-mode it would
not be parsed, but via Parsoid/API:Expandtemplates it would.

The external image, however, displayed properly in view-mode regardless of
whether "noparse" was true or false, since it was already valid HTML and
didn't require parsing. In VE it seems to be reacting as though <img> tags
are not allowed.

Right, Parsoid treats the img tag as a literal string in the sanitizer. Here is commandline output that demionstrates this.

[subbu@earth lib] echo "<img src='http://goo.gl/fh3yKh' />" | parse.js --normalize
<p>&lt;img src='http://goo.gl/fh3yKh' /></p>

But, if Parsoid was aware of this being valid/trusted HTML (via the isHTML flag), it could wrap the HTML in a DOM fragment and tunnel it through the sanitizer .. for example, as with the <math> tag.

Subbu.

--James

On Tue, Feb 23, 2016 at 1:24 PM, Subramanya Sastry <[email protected]>
wrote:

On 02/23/2016 12:45 PM, James Montalvo wrote:

I'm trying to make images from an external source, provided by a parser
function, work with VisualEditor and Parsoid. For a very simplified
illustration I added the following to the bottom of LocalSettings.php


```
$wgExtensionMessagesFiles['myPfTest'] = "$IP/myPfTest.php";
$wgHooks['ParserFirstCallInit'][] = function( &$parser ) {
      $parser->setFunctionHook(
          'test_func',
          function ( &$parser ) {

              // Output a wiki image and an external image
              $output = "[[File:Test.png|frameless|300px]]" .
                  "<br />" .
                  "<img src='http://goo.gl/fh3yKh' />";

              return array(
                  $output,
                  "noparse" => true,
                  "isHTML" => true,

TL:DR; Parsoid does not support the noparse / isHTML options right now
which explains everything that you describe in your email.

More specifically, Parsoid queries the mediawiki API to get expanded
wikitext for template and parser functions and as
https://www.mediawiki.org/wiki/API:Expandtemplates shows (unless I has
misread it), we don't have access to the noparse / isHTML information. So,
when Parsoid receives the text back, it treats it as wikitext and parses
it. Fixing this will require updating the expandtemplates API to return
this information to Parsoid.

Separately and somewhat tangentially, we have implemented native extension
support in Parsoid. We are still working through our support for it by
porting some tag extensions to Parsoid. In the process, we expect it will
go through some more changes and tweaks, and we will document this fully at
that point.

In that context, while we hadn't anticipated this use case, we could
potentially provide the equivalent of function hooks within Parsoid. These
hooks will not be attached to the parsing lifecycle since the parsing
lifecycle is different in the PHP core parser and Parsoid (or for any other
hypothetical future implementation of wikitext parsing that someone else
might implement). But, once in place, this will let you replicate this
transformation (which is what it is, in reality) in Parsoid either by
having the output of the function parsed, wrapping it as a string, or
treating it as a DOM fragment. But, I am mostly thinking aloud here at this
point.

So, long story short, there isn't a way to do what you are trying to do in
VE/Parsoid .... yet.

Subbu.

_______________________________________________
Wikitech-l mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/wikitech-l
_______________________________________________
Wikitech-l mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/wikitech-l


_______________________________________________
Wikitech-l mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/wikitech-l

Reply via email to