lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Hi, I wrote an interactive tokenizer, automatic indenter and syntax
highlighter for lua in WoW a while ago, for in game lua editing.
This code was of course written in lua itself.
While the code was written for wow, it is fairly easy to use it
standalone to insert tags for syntax highlighting or just add proper
indentation.
I handles multiline strings and comments and should correctly tokenize
all 5.1.x lua code

Note that it will preserve line breaks as is and not split up long
lines into several lines.

You can find the utility here:
http://www.wowinterface.com/downloads/info4895-ForAllIndentsAndPurposes.html

The following is a snippet I used to run it as a stand alone program
-- usage: lua run.lua input.lua > output.lua
require "indent"
local lib = IndentationLib

local filename = ...
local file = io.open(filename, "r")
local s = file:read("*a")

local indented_s = lib.indentCode(s, 2)
print(indented_s)


On Fri, May 23, 2008 at 10:04 PM, Bertrand Mansion <golgote@mamasam.com> wrote:
> Hi,
>
> Is there a lua snippet that can "beautify" lua source code, especially
> indentation?
> This one <http://lua-users.org/wiki/SciteIndentation> doesn't work well,
> it's missing a lot of things code snippets within multiline comments for
> example.
>
> Thanks for your help,
>
>
> --
> Bertrand Mansion
> Mamasam
> Work : http://www.mamasam.com
> Blog : http://golgote.freeflux.net
>
>
>