How do I determine pagination to ensure that a keyword appears in the center of the page - objective-c

I'm not looking for finished code but more of a place to start; I am a bit stuck!
I have a long text document and and a collection of keywords that appear in this document. I know the location where each keyword appears in the document. I'm looking for a way to display this keyword half way down in a non-scrollable UIWebView along with as much of its surrounding text that will fit into the UIWebView. In other words, I would like to calculate the pagination character boundaries.

You can use core text to find this kind of information, but it's quite complex. You might just generate an HTML document with anchor tags at each keyword, and then use javascript or fragment identifiers to move the web view around.
Edit: For example, the HTML might look like:
My text blah blah <a name="keyword-super-1">super</a> more blah blah and then use javascript like JavaScript - Jump to anchor.

Related

Wikipedia API - How to get rid of Wikipedia hyperlinks/junk

I'm currently using Wikipedia API to get some content that I can use on my website. At the moment when I get content it is all in html or wikitext (both containing Wikipedia hyperlink and a lot of junk in the text). Is there a way around this to just get plain text without having all this junk?
I have tried calling HTML and converting it into plain text but that still contains all of the wiki junk. I want to try and create a universal method that can remove all the junk as I want to be able to call multiple different Wikipedia pages and get plain text for all of these.
HTML:
https://en.wikipedia.org/w/api.php?action=parse&format=json&page=Game_of_Thrones_(season_3)&prop=text&section=1&disabletoc=1
Wikitext:
https://en.wikipedia.org/w/api.php?action=parse&format=json&page=Game_of_Thrones_(season_3)&prop=wikitext&section=1&disabletoc=1
I hope this makes sense, any advice/guidance is greatly appreciated.

How Can I Format a Tumblr Title

Is there a way to format part of a Tumblr title? For example, I'd like to be able to italicize one word in a title. Anyway to do that?
Tumblr reads titles using the {Title} tag, so how it is rendered is determined all at once not word for word. This means that the style of your titles universally depends on the CSS used around them in the hard coding. If you use the traditional manner of titling your posts which is placing the title in the "Title" area, then no this is not possible. An alternative method is to not put a title in that area and instead just post all information into the body.
You would then use the "html" view to code the header as you wish to see it. Default tumblr layouts use h1 /h1 around their headers so this is generally what you would want to use. The reason you are going into html view is because there is no option currently on default tumblr to increase the font size outside of html view.
The very first coding in the html view should be similar to this:
<h1>Title with one word in <i>italics</i></h1>
Once done, turn off html view, press enter to get off of the title line and continue your post.

Tumblr Description <table>

I'm writing some code that will go into the description box of a Tumblr page, in order to set a small tagline on the left of the header, and a search box of the right side of the same line. I've been trying to use a table with two cells and the width of the page to achieve this. However, it seems that the description box doesn't accept the <table> tag (it appears to work in the preview but not in the actual page).
Is there any other way to achieve inline content, with one justified left and the other right?
It is possible to include HTML elements in your Tumblr description.
There are two ways to achieve this:
Escape any HTML you are adding to the description box. This tool can help.
Modify the themes HTML and take advantage of Variable Transformations. In this scenario the {Description} tag would be replaced with {PlaintextDescription}
Either method should allow you to add HTML elements.
Also, I would take the advice of the comment made above. There is no need to use a table for the layout your trying to achieve.

Get text from a section on some page

I know how to make an API call to get me the text of the whole page, like this, but is there a way (without having to parse through the wiki markup) to only get the text from a certain section?
If you look at the documentation for the revisions module, you'll notice that it has a prameter rvsection, which is exactly what you want. So, for example, to retrieve the lead section, use
http://en.wikipedia.org/w/api.php?format=xml&action=query&titles=Stack%20Overflow&prop=revisions&rvprop=content&rvsection=0

parsing html data iphone xpath

have this webpage http://www.westminster.ac.uk/schools/computing/undergraduate . I'm using hpple to retrieve data (just started learning about it). I want to specifically retrieve the href from he main page, how can i do this?
I have this line - "NSArray *elements = [xpathParser search:#"//a"];" is able to retrieve all of the href links within the page however how can i retrieve just the ones in the main content? e.g. "BSc Honors Busniess Information Systems"? whats the syntax for it?
It looks like all of the "main content" stuff is found underneath elements with id attributes like "content_div_XXXX" where XXXX is some randomly generated sequence. You might be able to get at what you want using an XPath that looks something like:
//div[starts-with(#id,'content_div')]//a
You should be able to get something like this working, although you'd have to try it out and perhaps tweak it a bit to make it work precisely as you want. Refer to W3Schools XPath page for a good set of XPath tutorials