On 24 July 2015 at 07:34, Ricordisamoa
<ricordisamoa(a)openmailbox.org> wrote:
Il 24/07/2015 06:35, C. Scott Ananian ha
scritto:
Well, it's really just a different way of
thinking about things. Instead
of:
```
import mwparserfromhell
>> text = "I has a template! {{foo|bar|baz|eggs=spam}} See it?"
>> wikicode = mwparserfromhell.parse(text)
>> templates = wikicode.filter_templates()
>>
> ```
you would write:
```
js> Parsoid = require('parsoid');
js> text = "I has a template! {{foo|bar|baz|eggs=spam}} See it?";
js> Parsoid.parse(text, { document: true }).then(function(res) {
templates =
res.out.querySelectorAll('[typeof~="mw:Transclusion"]');
console.log(templates);
}).done();
```
That said, it wouldn't be hard to clone the API of
http://mwparserfromhell.readthedocs.org/en/latest/api/mwparserfromhell.html
Parsoid's expressiveness seems to convey useless information, overlook
important details, or duplicate them in different places.
If I want to resize an image, am I supposed to change "data-file-width"
and "data-file-height"? "width" and "height"? Or
"src"?
I think what I'm looking for is sort of an 'enhanced wikitext' rather than
'annotated HTML'.
and that would probably be a great addition to the parsoid package API.
HTML is just a tree structured data
representation. Think of it as XML if
it makes you happier. It just happens to come with well-defined semantics
and lots of manipulation libraries.
I don't know about edits tagged as "VisualEditor". That seems like that
should only be done by VE.
All edits made via visualeditoredit <
https://www.mediawiki.org/w/api.php?action=help&modules=visualeditoredi…
are tagged.
I take it you would like an easy work flow to
fetch a page, make edits, and then write the new
revision back?
Right.
RESTBase could help you there. With one API call, you can get the (stored)
latest HTML revision of a page in Parsoid format~[1], but without the need
to wait for Parsoid to parse it (if the latest revision is in RESTBase's
storage).