------------------------------------------------------------------------------------------------
on write_to_file_overwriting(someText, targetFile)
try
set resultNumber to open for access targetFile with write permission
set eof of resultNumber to 0
write someText to resultNumber
close access resultNumber
on error errMsg number errNum
try
close access resultNumber
end try
error errMsg
end try
end write_to_file_overwriting
------------------------------------------------------------------------------------------------
try
set tempFile to "" & (path to temporary items from user domain) & "junk.html"
set _posixPath to quoted form of (POSIX path of tempFile)
set str to "The <letter>a</letter> quick <photo>12</photo> brown fox jumps <photo>150</photo> over the <mode>x</mode> lazy dog."
write_to_file_overwriting(str, tempFile)
set cmd to "tr '\\r' '\\n' " & _posixPath & ";
textutil -stdout -cat txt " & _posixPath
do shell script cmd
on error errMsg number errNum
set {cr, sep} to {return, "------------------------------------------"}
set e to sep & cr & "Error: " & errMsg & cr & sep & cr & "Error Number: " & errNum & cr & sep
beep
display dialog e
end try
------------------------------------------------------------------------------------------------