2 * @class mw.Api.plugin.parse
6 $.extend( mw
.Api
.prototype, {
8 * Convenience method for 'action=parse'.
10 * @param {string|mw.Title} content Content to parse, either as a wikitext string or
12 * @param {Object} additionalParams Parameters object to set custom settings, e.g.
13 * redirects, sectionpreview. prop should not be overridden.
14 * @return {jQuery.Promise}
15 * @return {Function} return.done
16 * @return {string} return.done.data Parsed HTML of `wikitext`.
18 parse: function ( content
, additionalParams
) {
23 contentmodel
: 'wikitext'
24 }, additionalParams
);
26 if ( mw
.Title
&& content
instanceof mw
.Title
) {
27 // Parse existing page
28 config
.page
= content
.getPrefixedDb();
30 // Parse wikitext from input
31 config
.text
= String( content
);
34 apiPromise
= this.get( config
);
37 .then( function ( data
) {
38 return data
.parse
.text
;
40 .promise( { abort
: apiPromise
.abort
} );
46 * @mixins mw.Api.plugin.parse
49 }( mediaWiki
, jQuery
) );