michalbe / wiki-infobox

Simple Wikipedia infobox scraper
https://github.com/michalbe/wiki-infobox
MIT License
16 stars 8 forks source link

Text is ignored if there are links in the same field #37

Closed michalbe closed 9 years ago

michalbe commented 9 years ago

If there is text and link in one field, then text is ignored, and just link is returned. For instance getting MacGyver's nuber of episodes that looks like this in Wiki Markdown: num_episodes = 139 ([[List of MacGyver episodes|List of episodes]])<br />2 TV [[List of MacGyver episodes#TV Movies|films]] returns array of objects like this:

[ { type: 'link',
    text: 'List of episodes',
    url: 'http://en.wikipedia.org/wiki/List of MacGyver episodes' },
  { type: 'link',
    text: 'films',
    url: 'http://en.wikipedia.org/wiki/List of MacGyver episodes#TV Movies' } ]

If doesn't include text nodes there. Expected result should be:

[ 
  { type: 'text',
    text: '139' }, 
  { type: 'link',
    text: 'List of episodes',
    url: 'http://en.wikipedia.org/wiki/List of MacGyver episodes' },
  { type: 'text',
    text: '2 TV' }, 
  { type: 'link',
    text: 'films',
    url: 'http://en.wikipedia.org/wiki/List of MacGyver episodes#TV Movies' } ]

The change should be made in stringToObject function.

michalbe commented 9 years ago

Closed by @wojtekw92 in #40