spencermountain / wtf_wikipedia

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

Template transclusion #223

Open GitterHubber opened 5 years ago

GitterHubber commented 5 years ago

Hello!

Node v10.14.2 OS Windows7, 64bit

I'm running this code

var wtf = require('wtf_wikipedia');

wtf.fetch('Copper').then(doc => {
console.log(doc.infobox(0).json());
});

But unable to get any output. There is as infobox present on that page.

spencermountain commented 5 years ago

hi, oh yeah, this is annoying. The Copper infobox is 'transcluded', which means that it is actually here, and not on the copper page

you can retrieve it like this:

(async () => {
  var doc = await wtf.fetch('Template:Infobox copper');
  console.log(doc.infoboxes(0).json());
})();

cheers