# Support Wikipedia anchors in onebox

**URL:** <https://meta.discourse.org/t/support-wikipedia-anchors-in-onebox/19664>\
**Category:** Feature\
**Created:** [September 5, 2014, 5:43am UTC](https://meta.discourse.org/t/support-wikipedia-anchors-in-onebox/19664 "2014-09-05T05:43:23Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![Lid](https://avatars.discourse-cdn.com/v4/letter/l/2bfe46/32.png) [@Lid](https://meta.discourse.org/u/Lid)\
**Post date:** [September 5, 2014, 10:20am UTC](https://meta.discourse.org/t/support-wikipedia-anchors-in-onebox/19664/2 "2014-09-05T10:20:37Z")

</div>

for fun and giggles  
**[jsFiddle Experiment | Getting wikipedia section content with ajax](http://jsfiddle.net/lid0/m320cwuz/3/embedded/result/)**

> **[Edit fiddle - JSFiddle - Code Playground](https://jsfiddle.net/lid0/m320cwuz/)**
>
> JSFiddle - Test your JavaScript, CSS, HTML or CoffeeScript online with JSFiddle.

utilizing the Wikipedia API ( [API:Action API - MediaWiki](http://www.mediawiki.org/wiki/API:Main_page) ).

To retrieve the section content with this approach I had to make 2 requests

1. get a list of all the sections of an article to identify its numeric id (needed for the 2nd request)
2. request of a particular section content based on the id.

The bad  
The solution return the entire section and not just the first paragraphs as onebox appears to do.  
I was thinking that using the wiki api might make the process more efficient at least, but it is not  
additional processing is required to fix relative a tags

- it also return some nonsense [edit] text

my conclusion is that is probably better to just go with the current approach and use Nokogiri for section parsing 😄

---

_[View the full topic](https://meta.discourse.org/t/support-wikipedia-anchors-in-onebox/19664)._
