Last week, we had the author of TDD for a Shopping Website LiveProject. Friday at 11am Ranch time, Steven Solomon will be hosting a live TDD session just for us. See for the agenda and registration link

Leo Li-Fan Chen

Greenhorn
+ Follow
since Jul 17, 2012
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Leo Li-Fan Chen

Thanks for your info.
But as I am developing this algorithm on Android, I won't have access to any of the libraries you mentioned.
Another thing is, to avoid parsing through the same HTML content multiple times, we already have a parsing framework like so



so I need to stick to this rule to avoid traversing the content multiple times, therefore which explains why I can't use libraries.
So basically I have to implement parseURLLink(ch).
9 years ago

Winston Gutkowski wrote:

Leo Li-Fan Chen wrote:I have a requirement to write a function that accepts a String that contains html content (from webpage or email), transform every URL found into hyperlink, and return that String.


Right, just to make your requirements clear:
You want to search a piece of HTML text and convert all strings that are outside <a> tags to something like
<a href="{whatever}">{whatever}</a>
is that right?


Thanks for the prompt response.
Sorry I didn't make it very clear.

My task is to search a piece of HTML text and convert these URLs (www., http://, https://, rtps://) that is
1. within <body></body>
2. outside any html tags
3. not already enclosed by <a></a>, in other words, not hyperlinked
to <a href="{whatever}">{whatever}</a>.

The purpose is to make the URLS (www., http://, https://, rtps://) clickable when the HTML text is ultimately passed to WebView.

I'd prefer not to use any library though, need to minimize our app's footprint.
I believe point number 3 is the most difficult task.
e.g.
If I detect a URL (e.g. www.yahoo.com), how far before that URL should I scan for a possible <a> tag?

Anyone had experience writing this kind of algorithm?
9 years ago
Dear all,

I have a requirement to write a function that accepts a String that contains html content (from webpage or email), transform every URL found into hyperlink, and return that String.

e.g.
www.yahoo.com
becomes
<a href="http://www.yahoo.com">www.yahoo.com</a>

of course, if the URL is already embedded inside <a> tag, then it will be left as the way it is and I believe this is the most difficult requirement.

Does anyone know where I can get a sample code? Any open source?

thanks


9 years ago