On 24 July 2015 at 07:34, Ricordisamoa ricordisamoa@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=visualeditoredit... 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). There is also section API support (you can get individual HTML fragments of a page by ID, and send only those back for transformation into wikitext~[2]). There is also support for page editing (aka saving), but these endpoints have not yet been enabled for WMF wikis in production due to security concerns.
[1] https://en.wikipedia.org/api/rest_v1/?doc#!/Page_content/page_html__title__g... [2] https://en.wikipedia.org/api/rest_v1/?doc#!/Transforms/transform_sections_to...
Cheers, Marko
mwparserfromhell doesn't actually seem to have that functionality
It is actually pretty easy to do with Pywikibot. But since Parsoid happens to work server-side, it makes sense to request and send back the structured tree directly.
, but it
would also be nice to facilitate that use case if we can. --scott
_______________________________________________ Wikitech-l mailing list Wikitech-l@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/wikitech-l
Thanks for your time.
Wikitech-l mailing list Wikitech-l@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/wikitech-l