`` Light `` (c) 2004-2005 By D.G. Sureau - www.scriptol.com `` Convert a "pure" xml document, with angle-brackets `` into "light" xml, ready to be used as a Scriptol source `` and conversely include "path.sol" include "libphp.sol" void usage() print "Light (c) 2004-2005 Scriptol - www.scriptol.com" print "Converts a xml file into a light xml source." print "Syntax: light [-u] sourcefile [targetfile]" print "- The -u (unlight) option converts light source into standard xml." print "- Source is an xml document or a .sol light source." print "- Target will be a file in the other format," print " if name omitted, source's name with other extension." exit(0) return `` Light, converts standard xml file into light xml source. void light(text source, text target) file so = fopen(source, "r") file ta = fopen(target, "w") boolean incode = false text c text outline while not so.eof() text line = so.readLine() if line = nil continue outline = "" for int i in 0 -- line.length() c = line[i] if incode if c <> "?" continue if (i + 1) < line.length() if line[i + 1] = ">" incode = false i + 1 continue /if /if /if if c = "<" if (i + 1) < line.length() if line[i + 1] = "?" incode = true i + 1 continue /if /if continue /if if c = ">" continue /if outline[i] = line[i] /for if outline.length() > 0 let ta.write(outline) /while so.close() ta.close() return `` Unlight, converts light xml source into standard xml file. void unlight(text source, text target) file so = fopen(source, "r") file ta = fopen(target, "w") boolean incode = false text c text outline boolean DATA = false boolean COMMENT = false boolean PROPERTY int i, j, l while not so.eof() text line = so.readLine() if line = nil continue line = line.rTrim() ` Processing data outline = line.lTrim() if DATA if outline[0 .. 1] = "~~" DATA = false continue /if ta.write(outline + "\n") continue /if if outline[ 0 .. 1] = "~~" DATA = true /if if outline[0] = "\"" outline = outline[1 .. -1] ta.write(outline) continue /if ` Processing comments if COMMENT if outline[0 .. 1] = "*/" ta.write("-->\n") COMMENT = false continue /if ta.write(outline + "\n") continue /if if outline[ 0 .. 1] = "/*" COMMENT = true outline[0..1] = "