Convert Wikipedia Page Section to NSString Objective-C - objective-c

I'm working on some code that retrieves a section of a Wikipedia page as an NSString. I've found a constructed link online that returns the raw data of a section. For instance, to get the first section of the Wikipedia page on 'Boston', you would go to:
http://en.wikipedia.org/w/index.php?title=Boston&action=raw&section=0.
And what I'm trying to achieve, is to convert that raw data into what can be seen on the normal Wikipedia page: http://en.wikipedia.org/wiki/Boston.
Now, at first, I thought I'd use regular expressions to parse out blocks that start with {{ and end with }}. However, this proved to be problematic, and it deleted necessary text.
Then, I thought I could somehow find a wiki markup to html converter (present everywhere online) for Objective-C, but I had no luck there.
There are several similar questions on SO, but none of them seem to be clearly resolved: Getting Wikipedia Article Summary using NSScanner Problem.
So, to resume, does anyone know how to parse a wiki page into an NSString?
Thank you in advance.

Use a PEG WikiText parser such as kiwi: https://github.com/AboutUs/kiwi
You can find kiwi's parsing output rules here: https://github.com/AboutUs/kiwi/blob/master/src/syntax.leg
You will need to download peg/leg to compile the leg file: http://piumarta.com/software/peg/

Related

What format does PrintDocument.getData() return?

I'm looking into what it takes to develop a PrintService on android. After reading some on-line docs I'm not quite clear on the format of data returned by PrintDocument.getData() method. I'd expect that in the case of PrintDocumentInfo.CONTENT_TYPE_PHOTO the returned data will be an image (I'm not quite sure about this). However, what can I expect when content type is CONTENT_TYPE_DOCUMENT?
There is a sample of PrintDocumentInfo that uses a builder to build a pdf file. Is this always the case? That is, is content of CONTENT_TYPE_DOCUMENT always in pdf format?
I'd appreciate any suggestions and/or pointers to relevant on-line docs.
Thanks.
It is always PDF for CONTENT_TYPE_DOCUMENT.

Clarification needed for Jade Syntax

I'm working with Huge's new Styleguide templates and am starting to wrap my head around Jade syntax. That said, I can't seem to find any documentation related to how the author created image paths. The syntax used is:
img.huge-sidebar__logo.clearfix(src='styleguide/assets/images/#{public.styleguide._data.logoImage}')
The part I'm not getting is the section of the path that appears to be an include:
#{public.styleguide._data.logoImage}
Can anyone shed some light on what this is called and what it's doing?
What you are seeing is an interesting application of Jade's interpolation functionality, which can be used on plaintext strings, such as is the case with src='...'.
It looks different (with the dots) because it's using a multidimensional JavaScript Object rather than simply a variable.

Gracenote API: Search and fetch contents in specific language

I'm wondering if there is a way to get data in specific language when using gracenote series_search or series_fetch methods.
It turns out that using ger field is useless... I still get data in english ...
If someone could help resolving this, that would be great! =)
Gracenote uses 3-letter ISO 639-2 codes to specify languages. The format is described at http://en.wikipedia.org/wiki/List_of_ISO_639-2_codes - Gracenote supports most major languages.
Thanks to your suggestion, we've added this documentation to our page at: https://developer.gracenote.com/eyeq

XCode RSS Feed Won't parse properly

I followed a tutorial (which I'll link at the bottom) that I got from an old StackOverflow answer to parse an RSS feed into a UITableView. The tutorial is a bit outdated, but only a few methods were deprecated, and I replaced them with (what I hope are) the appropriate newer methods. However, I'm running into some trouble, not with the replaced methods, but with the parser not starting the parsing process. There are some NSLogs sprinkled throughout to give clues as to what is going on, and my parser isn't calling parseDidStartDocument:, it's just running and returning the last two NSLogs ("All Done!" and "stories array has %d items"). If someone could take a look at the code and tell me why it's not parsing, I would be very grateful. If you need to see some of my code, just let me know which parts you'd like to see, and I'd be happy to edit it in.
http://gigaom.com/apple/tutorial-build-a-simple-rss-reader-for-iphone/
oooh that tutorial is way out of date - written in 2008!
Try this tutorial, written for iOS5 instead.

How to parse a web page source to get the values for an array

I am trying to implement a lotto game on the ipod and i need to parse the actual lotto page to get the winning numbers and to put them in an array to compare them with the numbers that the user had entered and find out if he is a winner or not. Can anyone help me with it because
really am stuck with it?
Thanks in advance! :)
What you need is a DOM parser, such as Apple's NSXMLParser.
Specifically you'd want to use XPath parsing to read the value of a specific DOM node on your lotto page's DOM tree.
As iOS does not come with NSXMLDocument (which supports XPath), you'd probably need to do as described here:
Using libxml2 for XML parsing and XPath queries in Cocoa
Other solutions for parsing XML/HTML:
How To Choose The Best XML Parser for Your iPhone Project