Automatic tagging of text

Jim Ault JimAultWins at yahoo.com
Thu Jan 4 10:47:59 EST 2007


On 1/4/07 4:58 AM, "Jesse Sng" <jsng at wayoflife.org> wrote:
> I'm trying to automate something very repetitive here and I'm
> wondering if anyone has an example stack that does automatic
> generation of html anchor tags for email addresses and URLs?
> 
> I would assume that this would include ensuring that the resulting
> email address and URIs are properly formed and that checking is done
> in case some tags are already there - properly dealing with cases
> like: http://www.runrev.com/ vs www.runrev.com and then taking the
> appropriate action to <a
> href="http://www.runrev.com/">http://www.runrev.com/</a>
> 
> Has anyone done this yet? We have a situation where we get long text
> articles and this automatic capability will help tremendously in
> helping us eliminate the amount of work by hand.

This is a basic start for you since your source text may have a few gotchas.
(not tested, just typed, so watch for any typos and as usual, your mileage
may vary.)

put incomingText into linkList
replace cr with empty in linkList -- kill returns
replace ".com" with ".com"&cr in linkList
--if there were 5 links, you now have 6 lines in linkList
delete line -1 of linkList
repeat for each line LNN in linkList
  put word -1 of LNN &cr after newLinkList
end repeat
delete last char of newLinkList
put newLinkList into linkList
put empty into newLinkList
replace "http://" with empty in linkList
replace "www." with empth in linkList
--now we should only have the base URL for all lines
put quote into q
repeat for each line LNN of newLinkList
   get ("<a href="&q&"http://www."&LNN&"/ "&q)
   get it & (">http://www."&LNN&"/</a>")
   put it & cr after newLinkList
end repeat
delete last char of newLinkList

use the same approach for the emails by
put incomingText into emailList
replace cr with empty in emailList
replace "@" with "@"& cr  in emailList
repeat with x = 1 to the number of lines in emailList
   put word -1 of line x & word 1 of line x+1 & cr after newEmailList
end repeat
delete last char of newEmailList

Jim Ault
Las Vegas






More information about the use-livecode mailing list