spencermountain / wtf_wikipedia

a pretty-committed wikipedia markup parser
https://observablehq.com/@spencermountain/wtf_wikipedia
MIT License
770 stars 129 forks source link

Blockquote is not parsed correctly when `1=` is used instead of `text=` #484

Closed p-himik closed 2 years ago

p-himik commented 2 years ago

E.g. this page https://en.wikipedia.org/wiki/David_Berkowitz results in:

TypeError: Cannot read properties of undefined (reading '0')
    at Object.blockquote (functions.js:374:31)
    at exports.default (index.js:81:17)
    at parseNested (index.js:31:24)
    at eval (index.js:56:26)
    at Array.forEach (<anonymous>)
    at allTemplates (index.js:56:10)
    at exports.default (index.js:73:7)
    at new Section (Section.js:73:5)
    at exports.default (index.js:82:19)
    at new Document (Document.js:93:22)

At this line https://github.com/spencermountain/wtf_wikipedia/blob/master/src/template/custom/text-and-data/functions.js#L345 the value of obj becomes {1: "... the blockquote text ...", template: "blockquote"}. So perhaps the code should check for obj[1] in addition to obj.text.

spencermountain commented 2 years ago

whoa! been a while since we've had a runtime error. happy to fix this today. PR welcome, if you've got it figured out. thanks

p-himik commented 2 years ago

Yeah, I'm not entirely sure I got it figured out since I've just started using the library. :)

spencermountain commented 2 years ago

fixed in 10.0.1 thanks