Re: [OT] Anti-Spam solution for web pages.
Re: [OT] Anti-Spam solution for web pages.
- Subject: Re: [OT] Anti-Spam solution for web pages.
- From: David Hood <email@hidden>
- Date: Sun, 19 Oct 2003 19:57:10 +1300
I've been using a variation of this to encode various entities in
copied text that should be tidied up before being webified (greater
than/ less than/ semicolons/ etc).
set nl to (ASCII character 10) --unix newline ending
set cr to (ASCII character 13) --mac newline ending
set text2html to (the clipboard) as text
set text2html to replaceFn(text2html, "&", "ampersandreplace")
--placeholder
set text2html to replaceFn(text2html, ";", "semicolreplace")
--placeholder
set text2html to replaceFn(text2html, "#", "hashmarkreplace")
--placeholder
set text2html to replaceFn(text2html, "<", "<")
set text2html to replaceFn(text2html, ">", ">")
set text2html to replaceFn(text2html, "\"", """)
set text2html to replaceFn(text2html, ":", ":")
-- lots more lines of strange entities that have built up
set text2html to replaceFn(text2html, "ampersandreplace", "&")
set text2html to replaceFn(text2html, "semicolreplace", ";")
set text2html to replaceFn(text2html, "hashmarkreplace", "#")
set text2html to replaceFn(text2html, nl, ("<BR>" & nl))--optional
paragraph break HTML
set text2html to replaceFn(text2html, cr, ("<BR>" & cr)) --optional
paragraph break HTML
set the clipboard to text2html
beep
on replaceFn(givenText, replaceFrom, replaceWith)
set AppleScript's text item delimiters to the replaceFrom
set the listOfChars to every text item of givenText
set AppleScript's text item delimiters to the replaceWith
set givenText to the listOfChars as string
set AppleScript's text item delimiters to ""
return givenText
end replaceFn
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.