Hi there,
Is there a translationscript for Text to HTML like in BBEdit (Translate) and ignore < and /> ? Example: ö -> ö
That would be great.
thanks, Detlef Hoge
Detlef Hoge info@detlefhoge.de wrote:
Hi there,
Is there a translationscript for Text to HTML like in BBEdit (Translate) and ignore < and /> ? Example: ö -> ö
If this can help you : years ago, I was using this AppleScript (Copy-Launch Script-Paste)
8<-- considering case
set Original to {"à", "À", "á", "Á", "â", "Â", "ä", "Ä", "ã", "Ã", "å", "Å", "æ", "Æ", "ç", "Ç", "è", "È", "é", "É", "ê", "Ê", "ë", "Ë", "ì", "Ì", "í", "Í", "î", "Î", "ï", "Ï", "ñ", "Ñ", "Ò", "Ò", "ó", "Ó", "ô", "Ô", "ø", "Ø", "œ", "Œ", "ù", "Ù", "ú", "Ú", "û", "Û", "ü", "Ü", "ÿ", "Ÿ", "ß", "€", "©", "®"}
set Modifie to {"à", "À", "á", "Á", "â", "Â", "ä", "Ä", "ã", "Ã", "å", "Å", "æ", "Æ", "ç", "Ç", "è", "È", "é", "É", "ê", "Ê", "ë", "Ë", "ì", "Ì", "í", "Í", "î", "Î", "ï", "Ï", "ñ", "Ñ", "Ò", "Ò", "ó", "Ó", "ô", "Ô", "ø", "Ø", "œ", "Œ", "ù", "Ù", "ú", "Ú", "û", "Û", "ü", "Ü", "ÿ", "Ÿ", "ß", "€", "©", "®}
set ull1 to the clipboard
set ull2 to "" repeat with i from 1 to (the number of characters of ull1) set mychar to character i of ull1 repeat with j from 1 to (count items of Original) if item j of Original = character i of ull1 then set mychar to (item j of Modifie) end if end repeat set ull2 to ull2 & mychar end repeat
set the clipboard to ull2 as text end considering
8<--
On Nov 26, 2004, at 18:38, Detlef Hoge wrote:
Is there a translationscript for Text to HTML like in BBEdit (Translate) and ignore < and /> ? Example: ö -> ö
Here's a command that will convert the TM_SELECTED_TEXT variable to entities but leave the lower-than/greater-than symbols:
php -r '$a1 = array(); foreach(explode("<", stripslashes($_ENV["TM_SELECTED_TEXT"])) as $s1) { $a2 = array(); foreach(explode(">", $s1) as $s2) array_push($a2, htmlentities($s2, 0, "UTF-8")); array_push($a1, implode(">", $a2)); } echo implode("<", $a1);'
Go to Commands -> Edit Commands… press the + symbol, give it a name (and possible hotkey) and paste the string above -- it must be one long line w/o line breaks.
Then selecting text and choosing this new command from the menu will convert the selection as requested.
On Nov 26, 2004, at 19:39, Allan Odgaard wrote:
php -r '$a1 = array(); foreach(explode("<", stripslashes($_ENV["TM_SELECTED_TEXT"])) as $s1) { $a2 = array(); foreach(explode(">", $s1) as $s2) array_push($a2, htmlentities($s2, 0, "UTF-8")); array_push($a1, implode(">", $a2)); } echo implode("<", $a1);'
Here's an update which takes text from stdin instead of using the TM_SELECTED_TEXT variable:
php -r '$a1 = array(); foreach(explode("<", file_get_contents("/dev/stdin")) as $s1) { $a2 = array(); foreach(explode(">", $s1) as $s2) array_push($a2, htmlentities($s2, 0, "UTF-8")); array_push($a1, implode(">", $a2)); } echo implode("<", $a1);'
I prefer this due to the apparent slash-mangling that PHP does and that it then is more like a filter, e.g. the 'standard input' can be changed to entire document etc.