Merge "Drop zh-tw message "saveprefs""
[lhc/web/wiklou.git] / resources / src / mediawiki.api / mediawiki.api.parse.js
1 /**
2 * @class mw.Api.plugin.parse
3 */
4 ( function ( mw, $ ) {
5
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 } );
21
22 return apiPromise
23 .then( function ( data ) {
24 return data.parse.text[ '*' ];
25 } )
26 .promise( { abort: apiPromise.abort } );
27 }
28 } );
29
30 /**
31 * @class mw.Api
32 * @mixins mw.Api.plugin.parse
33 */
34
35 }( mediaWiki, jQuery ) );