1
0
mirror of https://github.com/elua/elua.git synced 2025-01-08 20:56:17 +08:00
elua/doc/wb/js2lua.lua
Dado Sutter 6137c01714 New HTML doc structure still under evaluation and development.
Please read file readme.txt on /doc for more info.
2009-02-02 21:08:31 +00:00

29 lines
686 B
Lua
Executable File

-- Convert JavaScript into Lua
if (not arg[1]) then
error("Javascript filename must be passed as a parameter.")
end
if (not arg[2]) then
error("Lua filename must be passed as a parameter.")
end
print("Converting...")
local js_filename = arg[1]
local file = io.open(js_filename)
local wb_lua = file:read("*a")
file:close()
wb_lua = string.gsub(wb_lua, ":", "=")
wb_lua = string.gsub(wb_lua, "http=", "http:")
wb_lua = string.gsub(wb_lua, ";", " ")
wb_lua = string.gsub(wb_lua, "%[", "{")
wb_lua = string.gsub(wb_lua, "%]", "}")
local lua_filename = arg[2]
local file = io.open(lua_filename, "w")
file:write(wb_lua)
file:close()
print("Done.")