• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: [OT] Anti-Spam solution for web pages.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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, "<", "&lt;")
set text2html to replaceFn(text2html, ">", "&gt;")
set text2html to replaceFn(text2html, "\"", "&quot;")
set text2html to replaceFn(text2html, ":", "&#58;")
-- lots more lines of strange entities that have built up
set text2html to replaceFn(text2html, "ampersandreplace", "&amp;")
set text2html to replaceFn(text2html, "semicolreplace", "&#59;")
set text2html to replaceFn(text2html, "hashmarkreplace", "&#35;")
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.

  • Follow-Ups:
    • Re: [OT] Anti-Spam solution for web pages.
      • From: Emmanuel <email@hidden>
References: 
 >Re: [OT] Anti-Spam solution for web pages. (From: Jon Pugh <email@hidden>)

  • Prev by Date: Script editor hangs
  • Next by Date: Re: [OT] Anti-Spam solution for web pages.
  • Previous by thread: Re: [OT] Anti-Spam solution for web pages.
  • Next by thread: Re: [OT] Anti-Spam solution for web pages.
  • Index(es):
    • Date
    • Thread