Skip to content

Commit

Permalink
Merge pull request #349 from spencermountain/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
spencermountain committed Apr 14, 2020
2 parents 2cafa91 + 3f0253e commit c37f07f
Show file tree
Hide file tree
Showing 92 changed files with 36,275 additions and 2,361 deletions.
4 changes: 3 additions & 1 deletion .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@
"consistent-return": 2,
"no-octal-escape": 2,
"no-constant-condition": 1,
"no-unused-expressions": 2
"no-unused-expressions": 2,
"comma-dangle": [1, "only-multiline"],
"space-before-function-paren": 0
},
"globals": {
"process": true,
Expand Down
28 changes: 18 additions & 10 deletions builds/wtf_wikipedia-client.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion builds/wtf_wikipedia-client.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion builds/wtf_wikipedia-client.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion builds/wtf_wikipedia-client.mjs

Large diffs are not rendered by default.

28 changes: 18 additions & 10 deletions builds/wtf_wikipedia.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* wtf_wikipedia 8.1.1 MIT */
/* wtf_wikipedia 8.1.2 MIT */
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('https')) :
typeof define === 'function' && define.amd ? define(['https'], factory) :
Expand Down Expand Up @@ -500,11 +500,13 @@
} // try 'may refer to' on first line for en-wiki?


var firstLine = doc.sentences(0).text();
if (doc.sentences(0)) {
var firstLine = doc.sentences(0).text();

if (firstLine !== null && firstLine[0]) {
if (/. may refer to ./i.test(firstLine) === true) {
return true;
if (firstLine !== null && firstLine[0]) {
if (/. may refer to ./i.test(firstLine) === true) {
return true;
}
}
}

Expand Down Expand Up @@ -4904,6 +4906,7 @@
ordination: true,
'hockey team coach': true,
'hockey team gm': true,
'pro hockey team': true,
'hockey team player': true,
'hockey team start': true,
mlbbioret: true
Expand Down Expand Up @@ -7391,12 +7394,17 @@
//https://en.wikipedia.org/wiki/Template:Medical_cases_chart
'medical cases chart': function medicalCasesChart(tmpl, list) {
var order = ['date', 'deaths_expr', 'recovery_expr', 'cases_expr', 'alt_expr_1', '4th_expr', '5th_expr', 'alt_expr_2', 'col_1', 'col_1_change', 'show_col_1', 'col_2', 'col_2_change', 'show_col_2', 'divisor', 'numwidth', 'collabsible', 'collapsed', 'id'];
var obj = parse$3(tmpl); // parse each row template

var rows = obj.rows.match(/\{\{Medical cases chart\/Row.*\}\}/gi);
var obj = parse$3(tmpl);
obj.data = obj.data || '';
var rows = obj.data.split('\n');
obj.rows = rows.map(function (row) {
return parse$3(row, order);
var arr = row.split(/;/);
return order.reduce(function (h, k, i) {
h[k] = arr[i] || null;
return h;
}, {});
});
delete obj.data;
list.push(obj);
return '';
},
Expand Down Expand Up @@ -8806,7 +8814,7 @@

var category = fetchCategory;

var _version = '8.1.1';
var _version = '8.1.2';

var wtf = function wtf(wiki, options) {
return _01Document(wiki, options);
Expand Down
28 changes: 18 additions & 10 deletions builds/wtf_wikipedia.mjs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* wtf_wikipedia 8.1.1 MIT */
/* wtf_wikipedia 8.1.2 MIT */
import https from 'https';

var parseUrl = function parseUrl(url) {
Expand Down Expand Up @@ -494,11 +494,13 @@ var isDisambig = function isDisambig(doc) {
} // try 'may refer to' on first line for en-wiki?


var firstLine = doc.sentences(0).text();
if (doc.sentences(0)) {
var firstLine = doc.sentences(0).text();

if (firstLine !== null && firstLine[0]) {
if (/. may refer to ./i.test(firstLine) === true) {
return true;
if (firstLine !== null && firstLine[0]) {
if (/. may refer to ./i.test(firstLine) === true) {
return true;
}
}
}

Expand Down Expand Up @@ -4898,6 +4900,7 @@ var known = {
ordination: true,
'hockey team coach': true,
'hockey team gm': true,
'pro hockey team': true,
'hockey team player': true,
'hockey team start': true,
mlbbioret: true
Expand Down Expand Up @@ -7385,12 +7388,17 @@ var templates$a = {
//https://en.wikipedia.org/wiki/Template:Medical_cases_chart
'medical cases chart': function medicalCasesChart(tmpl, list) {
var order = ['date', 'deaths_expr', 'recovery_expr', 'cases_expr', 'alt_expr_1', '4th_expr', '5th_expr', 'alt_expr_2', 'col_1', 'col_1_change', 'show_col_1', 'col_2', 'col_2_change', 'show_col_2', 'divisor', 'numwidth', 'collabsible', 'collapsed', 'id'];
var obj = parse$3(tmpl); // parse each row template

var rows = obj.rows.match(/\{\{Medical cases chart\/Row.*\}\}/gi);
var obj = parse$3(tmpl);
obj.data = obj.data || '';
var rows = obj.data.split('\n');
obj.rows = rows.map(function (row) {
return parse$3(row, order);
var arr = row.split(/;/);
return order.reduce(function (h, k, i) {
h[k] = arr[i] || null;
return h;
}, {});
});
delete obj.data;
list.push(obj);
return '';
},
Expand Down Expand Up @@ -8800,7 +8808,7 @@ var fetchCategory = function fetchCategory(category, lang, options) {

var category = fetchCategory;

var _version = '8.1.1';
var _version = '8.1.2';

var wtf = function wtf(wiki, options) {
return _01Document(wiki, options);
Expand Down
15 changes: 9 additions & 6 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
---

<!-- #### [unreleased]
* lowercase/normalize table headers
- `.categories()` return `Category` objects
- - keep `Category:` prefix on categories
- make `.method('foo')` results consistent
-->
#### [unreleased]

### 8.1.2

- another fix for covid templates

### 8.1.1

- fix for covid templates

### 8.1.0

Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "wtf_wikipedia",
"description": "parse wikiscript into json",
"version": "8.1.1",
"version": "8.1.2",
"author": "Spencer Kelly <spencermountain@gmail.com> (http://spencermounta.in)",
"repository": {
"type": "git",
Expand Down Expand Up @@ -43,7 +43,7 @@
"wikiscript"
],
"prettier": {
"trailingComma": "none",
"trailingComma": "es5",
"tabWidth": 2,
"semi": false,
"singleQuote": true,
Expand Down
4 changes: 4 additions & 0 deletions plugins/category/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ wtf.parseCategory('Major League Baseball venues').then(docs => {
// 'Rogers Center is a entertainment venue ...'
//]
})

// get the name of a random category
let cat = await wtf.randomCategory('fr')
// 'Catégorie:Édifice religieux à Paris'
```

work-in-progress
Expand Down
Loading

0 comments on commit c37f07f

Please sign in to comment.