Hi
Here is an alternative way off doing it going from ahk to css directly
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
; #SingleInstance [force|ignore|off]
header1 =<html><head><title>View AHK using Cascading Style Sheets </title><style type="text/css">`n
divno=1
Loop, read, %A_ScriptDir%\AHK_CSS.txt
{
Loop, parse, A_LoopReadLine, 〠
{
field%a_index%:=A_loopfield
}
; 0= open and close div 1= open only on this word 2= close only on this word 3= open and close but only if after `n(new line)
if (field3=0 or field3=1 or field3=3)
{
; only write if a new div
header2 = %header2%DIV%divno% %field2%`n
}
if (field3=0 or field3=2 or field3=3)
{
; only increment if end of div
divno+=1
}
}
header3 =</style></head><body>
foot =</body></html>
usep1 =%1%
if (usep1="")
{
usep1=%A_ScriptDir%\AHK_CSS.tmp
}
FileRead, AHK_CSS, %usep1%
if errorlevel
{
msgbox file %usep1% not found
}
gosub process
AHK_CSS =%header1% %header2%%header3%%AHK_CSS%%foot%
FileDelete,%A_ScriptDir%\AHK_CSS.html
FileAppend, %AHK_CSS%, %A_ScriptDir%\AHK_CSS.html
runwait "%A_ScriptDir%\AHK_CSS.html"
return
process:
; process ahk scipt here in field AHK_CSS
Transform,AHK_CSS, HTML, %AHK_CSS% ,1
loop 3
{
; double space should not be allowed in html unless specified
StringReplace, AHK_CSS, AHK_CSS,%A_space%%A_space%,%A_space%,1
; clear manual formatting to allow this formatting to work better
StringReplace, AHK_CSS, AHK_CSS,%A_tab%%A_tab%,%A_tab%,1
}
divno=1
Loop, read, %A_ScriptDir%\AHK_CSS.txt
{
Loop, parse, A_LoopReadLine, 〠
{
field%a_index%:=A_loopfield
}
if field3=0
{
StringReplace, AHK_CSS,AHK_CSS,%field1%,<DIV%divno%>%field1%</DIV%divno%>,1
}
if field3=3
{
StringReplace, AHK_CSS, AHK_CSS,`n%field1%,`n<DIV%divno%>%field1%</DIV%divno%>,1
StringReplace, AHK_CSS, AHK_CSS,`n%a_tab%%field1%,`n<DIV%divno%>%field1%</DIV%divno%>,1
StringReplace, AHK_CSS,AHK_CSS,`n%a_space%%field1%,`n<DIV%divno%>%field1%</DIV%divno%>,1
}
if field3=1
{
StringReplace, AHK_CSS, AHK_CSS ,`n%field1%,`n<DIV%divno%>%field1%,1
StringReplace, AHK_CSS, AHK_CSS ,`n%a_tab%%field1%,`n<DIV%divno%>%field1%,1
StringReplace, AHK_CSS, AHK_CSS ,`n%a_space%%field1%,`n<DIV%divno%>%field1%,1
}
if field3=2
{
StringReplace, AHK_CSS, AHK_CSS ,`n%field1%,%field1%</DIV%divno%>`n,1
StringReplace, AHK_CSS, AHK_CSS ,%a_tab%%field1%,%field1%</DIV%divno%>`n,1
StringReplace, AHK_CSS, AHK_CSS ,`n%a_space%%field1%,%field1%</DIV%divno%>`n,1
}
if (field3=0 or field3=2 or field3=3)
{
divno+=1
}
}
return
guiclose:
exitapp
and this file AHK_CSS.txt holds the keywords , the CSS format command and the rule type
GuiControl〠{color:#aacc22;}〠3
Gui〠{color:#33cc33;}〠3
A_〠{font-size:150%; color:#666600;}〠0
:〠{font-size:150%; color:#e83399;}〠0
=〠{color:#e33399;}〠0
Gosub〠{color:#ff9900;}〠0
Return〠{position:relative;left:30%; color:#ff9900; font-weight:bold;}〠3
Run〠{font-size:150%; color:#bf0000;}〠3
If〠{color:#ff33cc;}〠3
Else〠{color:#ff33cc;}〠3
Loop〠{font-size:150%; color:#cc0066;}〠3
Font〠{color:#cc00ff;}〠3
Send〠{font-size:150%; color:#cc0000;}〠3
Menu〠{color:#9966ff;}〠3
File〠{color:#33cccc;}〠3
;〠{font-size:150%; color:#cc00cc;}〠3
,〠{font-size:150%; color:#0400ff;}〠0
{〠{color:#993399; position:relative;left:20px;}〠1
}〠〠2
(〠{color:red;}〠0
)〠{color:red;}〠0
[〠{color:blue;}〠0
]〠{color:blue;}〠0
---------〠-------
I would not recommend it to do every keyword as it would be to slow but its good just to tidy up and it does indent loop brackets and you have full control
I also am sure it could be made faster by all you clever guys
hope it helps
ps Unicode version