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.