Skip to content

Commit

Permalink
Merge pull request #83 from g-sun/master
Browse files Browse the repository at this point in the history
add parse() method
  • Loading branch information
macbre committed Nov 20, 2015
2 parents 443a16c + c877a56 commit dcfef31
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,10 @@ Get entries form Special:Log - [read more](http://www.mediawiki.org/wiki/API:Log

Returns XML with preprocessed wikitext - [read more](https://www.mediawiki.org/wiki/API:Parsing_wikitext#expandtemplates)

### bot.parse(content, title, callback)

Returns parsed wikitext - [read more](https://www.mediawiki.org/wiki/API:Parsing_wikitext#parse)

### bot.fetchUrl(url, callback)

Makes a GET request to provided resource and returns its content.
Expand Down
18 changes: 18 additions & 0 deletions lib/bot.js
Original file line number Diff line number Diff line change
Expand Up @@ -632,6 +632,24 @@ module.exports = (function() {
}, 'POST');
},

parse: function(text, title, callback) {
this.api.call({
action: 'parse',
text: text,
title: title,
contentmodel: 'wikitext',
generatexml: 1
}, function(err, data, next, raw) {
if (err) {
callback(err);
return;
}
var xml = getFirstItem(raw.parse.text);
var images = raw.parse.images;
callback(err, xml, images);
}, 'POST');
},

getRecentChanges: function(start, callback) {
var props = [
'title',
Expand Down

0 comments on commit dcfef31

Please sign in to comment.