* @return {string} return.done.data Parsed HTML of `wikitext`.
*/
parse: function ( content, additionalParams ) {
- var apiPromise, config = $.extend( {
- formatversion: 2,
- action: 'parse',
- contentmodel: 'wikitext'
- }, additionalParams );
+ var apiPromise,
+ config = $.extend( {
+ formatversion: 2,
+ action: 'parse',
+ contentmodel: 'wikitext'
+ }, additionalParams );
- if ( typeof content === 'string' ) {
- // Wikitext
- config.text = content;
- } else {
- // mw.Title
+ if ( mw.Title && content instanceof mw.Title ) {
+ // Parse existing page
config.page = content.getPrefixedDb();
+ } else {
+ // Parse wikitext from input
+ config.text = String( content );
}
apiPromise = this.get( config );