Skip to content

Commit 81e8869

Browse files
Merge pull request #535 from spencermountain/dev
Dev
2 parents 4a3bc7e + 6bab0b6 commit 81e8869

18 files changed

+605
-372
lines changed

builds/wtf_wikipedia-client.min.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

builds/wtf_wikipedia-client.mjs

Lines changed: 2 additions & 2 deletions
Large diffs are not rendered by default.

builds/wtf_wikipedia.cjs

Lines changed: 88 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,10 @@
1-
/*! wtf_wikipedia 10.1.4 MIT */
1+
/*! wtf_wikipedia MIT */
22
(function (global, factory) {
33
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('isomorphic-unfetch')) :
44
typeof define === 'function' && define.amd ? define(['isomorphic-unfetch'], factory) :
55
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.wtf = factory(global.unfetch));
66
})(this, (function (unfetch) { 'use strict';
77

8-
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
9-
10-
var unfetch__default = /*#__PURE__*/_interopDefaultLegacy(unfetch);
11-
128
/**
139
* Parses out the domain and title from a url
1410
*
@@ -1941,7 +1937,7 @@
19411937

19421938
const isRedirect = function (wiki) {
19431939
//too long to be a redirect?
1944-
if (!wiki || wiki.length > 500) {
1940+
if (!wiki) {
19451941
return false
19461942
}
19471943
return REDIRECT_REGEX.test(wiki)
@@ -2669,6 +2665,8 @@
26692665
];
26702666

26712667
//split text into sentences, using regex
2668+
//@spencermountain MIT
2669+
26722670
const abbreviations = literalAbbreviations.concat('[^]][^]]');
26732671
const abbrev_reg = new RegExp("(^| |')(" + abbreviations.join('|') + `)[.!?] ?$`, 'i');
26742672
const acronym_reg = /[ .'][A-Z].? *$/i;
@@ -3488,6 +3486,10 @@
34883486
if (hasKey.test(str) === true) {
34893487
let res = parseKey(str);
34903488
if (res.key) {
3489+
// don't overwrite if empty
3490+
if (h[res.key] && !res.val) {
3491+
return h
3492+
}
34913493
h[res.key] = res.val;
34923494
return h
34933495
}
@@ -4158,7 +4160,10 @@
41584160
'metrod': 'metro',
41594161
'fw': 'ferry',
41604162
'rws': 'stnlnk',
4161-
sclass2: 'sclass'
4163+
sclass2: 'sclass',
4164+
under: 'underline',
4165+
brackets: 'bracket',
4166+
raise: 'lower'
41624167
};
41634168

41644169
//multiple aliases
@@ -4456,7 +4461,7 @@
44564461
"'": `'`,
44574462
'\\': ' /',
44584463
'`': '`',
4459-
bracket: '[',
4464+
// bracket: '[',
44604465
'[': '[',
44614466
'*': '*',
44624467
asterisk: '*',
@@ -4481,6 +4486,8 @@
44814486
checked: '✔️',
44824487
'thumbs up': '👍',
44834488
'thumbs down': '👎',
4489+
'minusplus': '∓',
4490+
'plusminus': '±'
44844491
};
44854492

44864493
//grab the first, second or third pipe..
@@ -4491,6 +4498,7 @@
44914498
resize: 1, //https://en.wikipedia.org/wiki/'Resize',
44924499
lang: 1,
44934500
'rtl-lang': 1,
4501+
'line-height': 1,
44944502
l: 2,
44954503
h: 1, //https://en.wikipedia.org/wiki/'Hover_title',
44964504
sort: 1, //https://en.wikipedia.org/wiki/'Sort',
@@ -4557,10 +4565,34 @@
45574565
'nowiki',
45584566
'nowiki2',
45594567
'unstrip',
4560-
'UnstripNoWiki',
4568+
'unstripnowiki',
45614569
'plain text',
45624570
'make code',
45634571
'killmarkers',
4572+
'longitem',
4573+
'longlink',
4574+
'strikethrough',
4575+
'underline',
4576+
'uuline',
4577+
'not a typo',
4578+
'text',
4579+
'var serif',
4580+
'double underline',
4581+
'nee',
4582+
'ne',
4583+
'left',
4584+
'right',
4585+
'center',
4586+
'centered',
4587+
'justify',
4588+
'smalldiv',
4589+
'bold div',
4590+
'monodiv',
4591+
'italic div',
4592+
'bigdiv',
4593+
'strikethroughdiv',
4594+
'strikethrough color',
4595+
'pbpe'//pt
45644596
];
45654597
zeros.forEach((k) => {
45664598
templates$b[k] = 0;
@@ -5176,6 +5208,13 @@
51765208
let data = parser(tmpl, ['text']);
51775209
return (data.text || '').replace(/[^0-9]/g, '')
51785210
},
5211+
'resize': (tmpl) => {
5212+
let { n, text } = parser(tmpl, ['n', 'text']);
5213+
if (!text) {
5214+
return n || ''
5215+
}
5216+
return text || ''
5217+
},
51795218
'last word': (tmpl) => {
51805219
let data = parser(tmpl, ['text']);
51815220
let arr = (data.text || '').split(/ /g);
@@ -5388,6 +5427,43 @@
53885427
let { cl, type } = parser(tmpl, ['cl', 'type', 'fmt']);
53895428
return `[[${cl}-class ${type} |''${cl}''-class]] [[${type}]]`
53905429
},
5430+
'center block': (tmpl) => {
5431+
let { text } = parser(tmpl, ['text']);
5432+
return text || ''
5433+
},
5434+
'align': (tmpl) => {
5435+
let { text } = parser(tmpl, ['dir', 'text']);
5436+
return text || ''
5437+
},
5438+
'font': (tmpl) => {
5439+
let { text } = parser(tmpl, ['text']);
5440+
return text || ''
5441+
},
5442+
'float': (tmpl) => {
5443+
let { text, dir } = parser(tmpl, ['dir', 'text']);
5444+
if (!text) {
5445+
return dir
5446+
}
5447+
return text || ''
5448+
},
5449+
'lower': (tmpl) => {
5450+
let { text, n } = parser(tmpl, ['n', 'text']);
5451+
if (!text) {
5452+
return n
5453+
}
5454+
return text || ''
5455+
},
5456+
'splitspan': (tmpl) => {
5457+
let list = parser(tmpl).list || [];
5458+
return (list[0] || '') + '\n' + (list[1] || '')
5459+
},
5460+
'bracket': (tmpl) => {
5461+
let { text } = parser(tmpl, ['text']);
5462+
if (text) {
5463+
return `[${text}]`
5464+
}
5465+
return '['
5466+
},
53915467

53925468

53935469
// https://en.wikipedia.org/wiki/Template:In_title
@@ -10403,7 +10479,7 @@
1040310479
const url = makeUrl(options);
1040410480
const headers = makeHeaders(options);
1040510481

10406-
return unfetch__default["default"](url, headers)
10482+
return unfetch(url, headers)
1040710483
.then((res) => res.json())
1040810484
.then((res) => {
1040910485
let data = getResult(res, options);
@@ -10422,7 +10498,7 @@
1042210498
})
1042310499
};
1042410500

10425-
var version = '10.1.4';
10501+
var version = '10.1.5';
1042610502

1042710503
/**
1042810504
* use the native client-side fetch function
@@ -10433,7 +10509,7 @@
1043310509
* @returns {Promise<any>} the response from fetch
1043410510
*/
1043510511
const request = function (url, opts) {
10436-
return unfetch__default["default"](url, opts).then(function (res) {
10512+
return unfetch(url, opts).then(function (res) {
1043710513
return res.json()
1043810514
}).catch((e) => {
1043910515
console.error('\n\n=-=- http response error =-=-=-');

builds/wtf_wikipedia.mjs

Lines changed: 86 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/*! wtf_wikipedia 10.1.4 MIT */
1+
/*! wtf_wikipedia MIT */
22
import unfetch from 'isomorphic-unfetch';
33

44
/**
@@ -1933,7 +1933,7 @@ const REDIRECT_REGEX = new RegExp('^[ \n\t]*?#(' + redirects.join('|') + ') *?(\
19331933

19341934
const isRedirect = function (wiki) {
19351935
//too long to be a redirect?
1936-
if (!wiki || wiki.length > 500) {
1936+
if (!wiki) {
19371937
return false
19381938
}
19391939
return REDIRECT_REGEX.test(wiki)
@@ -2661,6 +2661,8 @@ var literalAbbreviations = [
26612661
];
26622662

26632663
//split text into sentences, using regex
2664+
//@spencermountain MIT
2665+
26642666
const abbreviations = literalAbbreviations.concat('[^]][^]]');
26652667
const abbrev_reg = new RegExp("(^| |')(" + abbreviations.join('|') + `)[.!?] ?$`, 'i');
26662668
const acronym_reg = /[ .'][A-Z].? *$/i;
@@ -3480,6 +3482,10 @@ const keyMaker = function (arr, order) {
34803482
if (hasKey.test(str) === true) {
34813483
let res = parseKey(str);
34823484
if (res.key) {
3485+
// don't overwrite if empty
3486+
if (h[res.key] && !res.val) {
3487+
return h
3488+
}
34833489
h[res.key] = res.val;
34843490
return h
34853491
}
@@ -4150,7 +4156,10 @@ let aliases = {
41504156
'metrod': 'metro',
41514157
'fw': 'ferry',
41524158
'rws': 'stnlnk',
4153-
sclass2: 'sclass'
4159+
sclass2: 'sclass',
4160+
under: 'underline',
4161+
brackets: 'bracket',
4162+
raise: 'lower'
41544163
};
41554164

41564165
//multiple aliases
@@ -4448,7 +4457,7 @@ var hardcoded = {
44484457
"'": `'`,
44494458
'\\': ' /',
44504459
'`': '`',
4451-
bracket: '[',
4460+
// bracket: '[',
44524461
'[': '[',
44534462
'*': '*',
44544463
asterisk: '*',
@@ -4473,6 +4482,8 @@ var hardcoded = {
44734482
checked: '✔️',
44744483
'thumbs up': '👍',
44754484
'thumbs down': '👎',
4485+
'minusplus': '∓',
4486+
'plusminus': '±'
44764487
};
44774488

44784489
//grab the first, second or third pipe..
@@ -4483,6 +4494,7 @@ let templates$b = {
44834494
resize: 1, //https://en.wikipedia.org/wiki/'Resize',
44844495
lang: 1,
44854496
'rtl-lang': 1,
4497+
'line-height': 1,
44864498
l: 2,
44874499
h: 1, //https://en.wikipedia.org/wiki/'Hover_title',
44884500
sort: 1, //https://en.wikipedia.org/wiki/'Sort',
@@ -4549,10 +4561,34 @@ let zeros = [
45494561
'nowiki',
45504562
'nowiki2',
45514563
'unstrip',
4552-
'UnstripNoWiki',
4564+
'unstripnowiki',
45534565
'plain text',
45544566
'make code',
45554567
'killmarkers',
4568+
'longitem',
4569+
'longlink',
4570+
'strikethrough',
4571+
'underline',
4572+
'uuline',
4573+
'not a typo',
4574+
'text',
4575+
'var serif',
4576+
'double underline',
4577+
'nee',
4578+
'ne',
4579+
'left',
4580+
'right',
4581+
'center',
4582+
'centered',
4583+
'justify',
4584+
'smalldiv',
4585+
'bold div',
4586+
'monodiv',
4587+
'italic div',
4588+
'bigdiv',
4589+
'strikethroughdiv',
4590+
'strikethrough color',
4591+
'pbpe'//pt
45564592
];
45574593
zeros.forEach((k) => {
45584594
templates$b[k] = 0;
@@ -5168,6 +5204,13 @@ var functions = {
51685204
let data = parser(tmpl, ['text']);
51695205
return (data.text || '').replace(/[^0-9]/g, '')
51705206
},
5207+
'resize': (tmpl) => {
5208+
let { n, text } = parser(tmpl, ['n', 'text']);
5209+
if (!text) {
5210+
return n || ''
5211+
}
5212+
return text || ''
5213+
},
51715214
'last word': (tmpl) => {
51725215
let data = parser(tmpl, ['text']);
51735216
let arr = (data.text || '').split(/ /g);
@@ -5380,6 +5423,43 @@ var functions = {
53805423
let { cl, type } = parser(tmpl, ['cl', 'type', 'fmt']);
53815424
return `[[${cl}-class ${type} |''${cl}''-class]] [[${type}]]`
53825425
},
5426+
'center block': (tmpl) => {
5427+
let { text } = parser(tmpl, ['text']);
5428+
return text || ''
5429+
},
5430+
'align': (tmpl) => {
5431+
let { text } = parser(tmpl, ['dir', 'text']);
5432+
return text || ''
5433+
},
5434+
'font': (tmpl) => {
5435+
let { text } = parser(tmpl, ['text']);
5436+
return text || ''
5437+
},
5438+
'float': (tmpl) => {
5439+
let { text, dir } = parser(tmpl, ['dir', 'text']);
5440+
if (!text) {
5441+
return dir
5442+
}
5443+
return text || ''
5444+
},
5445+
'lower': (tmpl) => {
5446+
let { text, n } = parser(tmpl, ['n', 'text']);
5447+
if (!text) {
5448+
return n
5449+
}
5450+
return text || ''
5451+
},
5452+
'splitspan': (tmpl) => {
5453+
let list = parser(tmpl).list || [];
5454+
return (list[0] || '') + '\n' + (list[1] || '')
5455+
},
5456+
'bracket': (tmpl) => {
5457+
let { text } = parser(tmpl, ['text']);
5458+
if (text) {
5459+
return `[${text}]`
5460+
}
5461+
return '['
5462+
},
53835463

53845464

53855465
// https://en.wikipedia.org/wiki/Template:In_title
@@ -10414,7 +10494,7 @@ const fetch = function (title, options, callback) {
1041410494
})
1041510495
};
1041610496

10417-
var version = '10.1.4';
10497+
var version = '10.1.5';
1041810498

1041910499
/**
1042010500
* use the native client-side fetch function

changelog.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,11 @@
33
- **[new]** - fallbackTemplateFn handler #509
44
55
-->
6+
#### 10.1.5 [May 2023]
7+
- **[fix]** - support inline templates
8+
- **[change]** - dont overwrite duplicate props in infobox #530
9+
- **[update]** - deps
10+
611
#### 10.1.4 [Apr 2023]
712
- **[fix]** - #528 template runtime errors
813
- **[fix]** - remove stray console.log (thank you @mxunknown)

0 commit comments

Comments
 (0)