parsoid/lib/wt2html/tokenizer.utils.js has an annoying throw statement
for (var i = 0; i < e.length; i++) { var v = e[i]; if (Array.isArray(v)) { // Change in assumption from a shallow array to a nested array. if (res === null) { res = e.slice(0, i); } internalFlatten(v, res); } else if (v !== null && v !== undefined) { if (res !== null) { res.push(v); } } else { throw new Error("falsy " + e); } }
Because of it, pegTokenizer.pegjs has a bunch of r:something { return r; }, making the compiled WikiPEG code inefficient.
We should just comment out the throw statement and remove { return r; } or similar code in pegTokenizer.pegjs if return tu.flattenStringlist(r); is called in downstream code.