2 * mw.Api methods for parsing wikitext.
6 $.extend( mw.Api.prototype, {
8 * Convinience method for 'action=parse'. Parses wikitext into HTML.
10 * @param wikiText {String}
11 * @param ok {Function} [optional] deprecated (success callback)
12 * @param err {Function} [optional] deprecated (error callback)
13 * @return {jQuery.Promise}
15 parse: function ( wikiText, ok, err ) {
16 var apiDeferred = $.Deferred();
18 // Backwards compatibility (< MW 1.20)
20 apiDeferred.done( ok );
23 apiDeferred.fail( err );
30 .done( function ( data ) {
31 if ( data.parse && data.parse.text && data.parse.text['*'] ) {
32 apiDeferred.resolve( data.parse.text['*'] );
35 .fail( apiDeferred.reject );
38 return apiDeferred.promise();
42 }( mediaWiki, jQuery ) );