Page MenuHomeWickedGov Phorge

parse.js
No OneTemporary

Size
1 KB
Referenced Files
None
Subscribers
None

parse.js

( function () {
Object.assign( mw.Api.prototype, /** @lends mw.Api.prototype */ {
/**
* Convenience method for 'action=parse'.
*
* @param {string|mw.Title} content Content to parse, either as a wikitext string or
* a mw.Title.
* @param {Object} additionalParams Parameters object to set custom settings, e.g.
* `redirects`, `sectionpreview`. `prop` should not be overridden.
* @return {jQuery.Promise<string>} Promise that resolves with the parsed HTML of `wikitext`
*/
parse: function ( content, additionalParams ) {
const config = Object.assign( {
formatversion: 2,
action: 'parse',
// Minimize the JSON we get back, there is no way to access anything else anyway
prop: 'text',
contentmodel: 'wikitext'
}, additionalParams );
let apiPromise;
if ( mw.Title && content instanceof mw.Title ) {
// Parse existing page
config.page = content.getPrefixedDb();
apiPromise = this.get( config );
} else {
// Parse wikitext from input
config.text = String( content );
apiPromise = this.post( config );
}
return apiPromise
.then( ( data ) => data.parse.text )
.promise( { abort: apiPromise.abort } );
}
} );
}() );

File Metadata

Mime Type
text/plain
Expires
Aug 15 2026, 15:26 (13 w, 8 h ago)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
27/8e/17a2a9749009fc2a9a2f79c3b45d
Default Alt Text
parse.js (1 KB)

Event Timeline