News : The level of daily SPAM has reached insane proportions, all registrations are now manual. I ask you to send me an e-mail (john (at) murga (dot) org), to confirm that you want me to create an account for you.

Post Reply  Post Thread 
murgaLua to html
Author Message
Senior Member

Posts: 522
Group: Registered
Joined: Apr 2007
Status: Offline
Reputation: 5
Post: #1
RE: murgaLua to html

Made a few improvements to it this morning.
It's still sloppy, but the results are better than before.
I'm hoping it will eventually create w3c compliant HTML, but that will be a last step. First I need to deal with setting the output filename dynamically (just haven't bothered to fix that yet) and try to work out nested/multiline stuff.

rc="#FFFF00" -- color for reserved words
pc="#00FFFF" -- "name.function" functions
fc="#00FFFF" -- lua functions
sc="#FF0000" -- strings
nc="#FF0000" -- numbers
mc="#00FF00" -- methods
wc="#FF00FF" -- FLTK classes
ec="#FF0000" -- FLTK constants
cc="#0000FF" -- comments

reserved={ "and","break","do","else","elseif","end","false","for","function","if","in",
           "local","nil","not","or","repeat","return","then","true","until","while" }
package={ "copas","coroutine","debug","fltk","gzip","io","lfs","lzo","math","md5","mime",
          "murgaLua","os","package","random","socket","sqlite3","string","table","zlib" }
funk={ "_G","_VERSION","assert","collectgarbage","dofile","error","getfenv","getmetatable",
       "tostring","type","unpack","xpcall" }

function parse_table(tab,color,pre,post)
for i=1,table.getn(tab) do
  mystring=string.gsub(mystring,[i],"%1<font color="..color..">%2</font>%3")
if input then
print("<html><head><title>"..filename.."</title></head><body bgcolor=black text=white><pre>")
for line in io.lines(filename) do
mystring=" "..line.." " -- spaces allow %W to work with beginning/end of string
mystring=string.gsub(mystring,"(%D*)(%d+)(%D)","%1<font color="">%2</font>%3") -- digits (do this before any colors are defined)
mystring=string.gsub(mystring,'(".-")',"<font color="">%1</font>") -- quotes
mystring=string.gsub(mystring,"(%:%l.-)(%()","<font color="">%1</font>%2") -- methods
mystring=string.gsub(mystring,"(%W)(fltk%:Fl[_%w]*)(%W)","%1<font color="..wc..">%2</font>%3") -- fltk:Fl_*
mystring=string.gsub(mystring,"(%W)(fltk%.FL[_%u]*)(%W)","%1<font color="">%2</font>%3") -- fltk constants

-- wipe out formatting from "--" comments
if commentstart then
  if commentstart == 1 then
    mystring="<font color="">"..mystring.."</font>"
    mystring=firststring.."<font color="">"..secondstring.."</font>"


This post was last modified: 03-10-2008 05:55 AM by mikshaw.

03-10-2008 05:44 AM
Find all posts by this user Quote this message in a reply
Post Reply  Post Thread 

Messages In This Thread
murgaLua to html - mikshaw - 03-09-2008, 05:42 AM
RE: murgaLua to html - iGame3D - 03-09-2008, 06:52 AM
RE: murgaLua to html - mikshaw - 03-09-2008, 07:56 AM
RE: murgaLua to html - mikshaw - 03-09-2008, 08:31 AM
RE: murgaLua to html - mikshaw - 03-10-2008 05:44 AM
RE: murgaLua to html - mikshaw - 03-12-2008, 04:59 AM
RE: murgaLua to html - mikshaw - 03-13-2008, 03:47 AM
RE: murgaLua to html - iGame3D - 03-13-2008, 10:10 AM
RE: murgaLua to html - mikshaw - 03-13-2008, 10:34 AM
RE: murgaLua to html - mikshaw - 03-13-2008, 12:01 PM

View a Printable Version
Send this Thread to a Friend
Subscribe to this Thread | Add Thread to Favorites

Forum Jump: