Implement extension registration from an extension.json file
[mediawiki.git] / resources / src / mediawiki.api / mediawiki.api.parse.js
blob2dcf8078fe6750acb867a29fcc68b065afb6f462
1 /**
2  * @class mw.Api.plugin.parse
3  */
4 ( function ( mw, $ ) {
6         $.extend( mw.Api.prototype, {
7                 /**
8                  * Convenience method for 'action=parse'.
9                  *
10                  * @param {string} wikitext
11                  * @return {jQuery.Promise}
12                  * @return {Function} return.done
13                  * @return {string} return.done.data Parsed HTML of `wikitext`.
14                  */
15                 parse: function ( wikitext ) {
16                         var apiPromise = this.get( {
17                                 action: 'parse',
18                                 contentmodel: 'wikitext',
19                                 text: wikitext
20                         } );
22                         return apiPromise
23                                 .then( function ( data ) {
24                                         return data.parse.text['*'];
25                                 } )
26                                 .promise( { abort: apiPromise.abort } );
27                 }
28         } );
30         /**
31          * @class mw.Api
32          * @mixins mw.Api.plugin.parse
33          */
35 }( mediaWiki, jQuery ) );