开发者

What's a good command line JavaScript code beautifier?

I recently asked a question about formatting JavaScript code in Vim. And I've also noticed this question, and did some Google searching. Nonetheless, my quest continues.

I've given up on a Vim plugin that will properly format contemporary JS code. But maybe there's a command line tool I could call from within Vim. Here are my desiderata:

  • Just 开发者_开发百科one thing to install. Ideally just a script I can drop into my ~/bin dir. Doesn't require a supporting interpreter that I probably don't have on my OS X or Linux systems and that I would have to install just to use this one little tool.

  • Written in something commonplace like Perl, C, Ruby, the bash shell scripting language, or even Java.

  • I'm not super picky about exactly how it formats the code as long as it does something reasonable and doesn't choke on jQuery-style JavaScript.


There's a tool written in perl that can do it: JavaScript::Beautifier

I would give GNU indent a go. It has a lot of options and if you use the right ones you might be able to get exactly what you want.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜