Remove html code from file
I've got an AppleScript but it doesn't remove all the code
<code>
on run {}
copy (choose file with prompt "Remove markup from which file:") to the_file
prompt user(thefile)
end run
on open (the_file)
if length of the_file > 1 then
display dialog "Please drop only one file on me at a time."
else
prompt user(thefile)
end if
end open
on prompt user(afile)
copy (read a_file) to message_text
copy (open for access file ((path to desktop as text) & "Markup Removed") with write permission) to new fileID
write remove markup(messagetext) starting at eof to new fileID
close access new fileID
end prompt_user
on remove markup(thistext)
set copy_flag to true
set the clean_text to ""
repeat with this_char in this_text
set this_char to the contents of this_char
if this_char is "<" then
set the copy_flag to true
else if the copy_flag is true then
set the clean_text to the clean_text & this_char as string
end if
end repeat
return the clean_text
end remove_markup
</code>