Skip to content

Commit

Permalink
fix for #530
Browse files Browse the repository at this point in the history
  • Loading branch information
spencermountain committed May 11, 2023
1 parent 6c3243b commit 4251e8c
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 2 deletions.
15 changes: 13 additions & 2 deletions scratch.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,20 @@ wtf.plugin(plg)

// let str = `{{float |top=2.0em |left=2px |width=10em | the content to float}}.`
// let str = `{{splitspan|foo|bar}}`
let str = ` {{font|text=也可以只選用其中一項選項。|size=25px}} `
// let str = ` {{font|text=也可以只選用其中一項選項。|size=25px}} `
// let doc = wtf(str)
// console.log(doc.text())


let str = ` {{Infobox officeholder
| name = Dr. Rajesh Sonkar
| office = [[President Bhartiya Janta Party(BJP) Indore, Madhya Pradesh]]
| term_start = 10 May 2020
| Office =
}}`
let doc = wtf(str)
console.log(doc.text())
console.log(doc.infobox().json())


// wtf.fetch("Formula One drivers from Finland", "en")
// trunc
Expand Down
4 changes: 4 additions & 0 deletions src/template/parse/toJSON/02-keyMaker.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@ const keyMaker = function (arr, order) {
if (hasKey.test(str) === true) {
let res = parseKey(str)
if (res.key) {
// don't overwrite if empty
if (h[res.key] && !res.val) {
return h
}
h[res.key] = res.val
return h
}
Expand Down
13 changes: 13 additions & 0 deletions tests/integration/infobox.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,3 +133,16 @@ test('slash-in-infobox', function (t) {
t.equal(json['jr/sr3'].text, 'United States Senator', 'slash')
t.end()
})

test('double-prop-infobox', function (t) {
let str = ` {{Infobox officeholder
| name = Dr. Rajesh Sonkar
| office = [[President Bhartiya Janta Party(BJP) Indore, Madhya Pradesh]]
| term_start = 10 May 2020
| Office =
}}`
let doc = wtf(str)
let json = doc.infobox().json()
t.equal(json['office'].text, 'President Bhartiya Janta Party(BJP) Indore, Madhya Pradesh', 'office')
t.end()
})

0 comments on commit 4251e8c

Please sign in to comment.