ColorizeScript challenge
Richard Gaskin
ambassador at fourthworld.com
Fri Apr 28 01:51:08 CDT 2006
I've been playing with the scripts suggested here, and I may have found
a way to modify Geoff's so that it handles function names with
parentheses as gracefully as it handles everything else:
on colorizeScript -- GC
global gREVScriptHTMLColors
--
if the optionKey is "down" then
colorizeScript_D
exit colorizeScript
end if
--
if gREVScriptHTMLColors["if"] is empty then SetupHTMLColors
SetupHTMLColors
put the scroll of fld "Editor Field" into tSaveScroll
put fld "Editor Field" into tScript
------
replace "&" with "&" in tScript
replace "<" with "<" in tScript
replace ">" with ">" in tScript
repeat for each line L in tScript
put 0 into i
repeat for each word W in L
add 1 to i
put token 1 of W into tToken
if gREVScriptHTMLColors[tToken] is not empty then
put gREVScriptHTMLColors[tToken] into token 1 of word i of L
add 1 to i
else if char 1 of W is "#" or char 1 to 2 of W is "--" then
put "<font color=gray60>" before word i of L
put "</font>" after L
exit repeat
end if
end repeat
put "<p>" & L & "</p>" & cr after tReturn
end repeat
--
set the htmlText of fld "Editor Field" to tReturn
set the scroll of fld "Editor Field" to tSaveScroll
unlock screen
end colorizeScript
So all I'm doing is just evaluating token 1 of the word, and replacing
token 1 of the word if needed.
In brief testing it seems okay so far -- is it?
--
Richard Gaskin
Managing Editor, revJournal
_______________________________________________________
Rev tips, tutorials and more: http://www.revJournal.com
More information about the metacard
mailing list