This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
DannySMc's profile picture

Lua file minifier?

Started by DannySMc, 25 May 2016 - 02:49 PM
DannySMc #1
Posted 25 May 2016 - 04:49 PM
Hey guys,

I have one other question, has anyone made a way an API (in lua) where I can give it a file and it will minify it, so removing extra whitespace, linebreaks and removing comments?

Thanks,
Danny
SquidDev #2
Posted 25 May 2016 - 05:14 PM
Howl comes with a minifier. You can always look at extracting out the minifier into a separate program (modify this line to be "howl/lexer/*" instead) then build it. Alternatively you can always use Howl :)/>.
Edited on 25 May 2016 - 03:14 PM
DannySMc #3
Posted 25 May 2016 - 05:33 PM
Howl comes with a minifier. You can always look at extracting out the minifier into a separate program (modify this line to be "howl/lexer/*" instead) then build it. Alternatively you can always use Howl :)/>/>.

Thanks for that!! How would I use it?
KingofGamesYami #4
Posted 25 May 2016 - 05:37 PM
I used this one on stitch.
DannySMc #5
Posted 25 May 2016 - 05:43 PM
I used this one on stitch.

Yes that is exactly what I am looking for, but just done in Lua :P/>.
SquidDev #6
Posted 25 May 2016 - 05:56 PM
Thanks for that!! How would I use it?

There is a pastebin of it (I made this for someone a while back and it isn't 100% up to date). If you load it with os.loadAPI then use <api>.Rebuild.minifyFile(in, out) or <api>.Rebuild.MinifyString(in).
apemanzilla #7
Posted 25 May 2016 - 06:38 PM
I used this one on stitch.

That one isn't perfect. I had (as a test) fed it one of my programs that was over 1000 lines long with 40 KB of code, and there was a syntax error in the result. I didn't bother looking for the problem.