Well, I am doing things a bit differently. I'm taking text straight from a text view as user input, putting in backslashes in the appropriate places to make it easier red by terminal, and just righting it to the HTML file with echo. Here is my code —
on runCode_(sender)
set htmlcode to codeBox's |string|()
set htmlcode to htmlcode as text
set invalidList to {"<", ">", "/"}
repeat with charReplace in invalidList
set htmlcode to replace_chars(htmlcode, charReplace, "\\" & charReplace)
end repeat
set lines1 to paragraphs of htmlcode
-- choose from list lines1
set newlist to {}
repeat with theitem in lines1
set newval to ((theitem) as text)
set end of newlist to newval
log newval
end repeat
--choose from list newlist
set htmlcode to newlist as string
display alert htmlcode
do shell script"echo "&htmlcode&" > ~/library/Application\\ Support/HTMLCode.html"
-- do shell script "textutil -convert html ~/library/Application\\ Support/HTMLCode.txt"
tellapplication"Safari"toopen location "/Users/"&whoami&"/Library/Application Support/HTMLCode.html"
end runCode_
Note that the commented lines are lines that I was previously using, and have disabled for future convenience. I have tried textutil to instead save the htmlcode variable to a txt file and use the textutil line to convert it to html. Even doing that, the HTML tags still seem to be used as formatting. The Safari end looks nice, but a blank HTML file is all that I get... Isn't this fun... 😀