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