Merge "Import: Handle uploads with sha1 starting with 0 properly"
[mediawiki.git] / resources / src / mediawiki / api / parse.js
blobbc3d44f946750a3e59415f7d07873fd44cc91f5c
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 ) );