javascript 代码格式化程序和荧光笔

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/8471556/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-26 03:33:17  来源:igfitidea点击:

javascript code formatter and highlighter

javascriptjqueryformatting

提问by

I am looking for a jQuery plugin that can take a string of code as input and will apply formatting and Highlights to make the code easily understandable. Just like jsfiddle.net.
As of now I have found many sites like jsbeautifier.org.. But I need a standalone jquery plugin which can process my code
Please help me on this.

我正在寻找一个 jQuery 插件,它可以将一串代码作为输入,并将应用格式和突出显示以使代码易于理解。就像 jsfiddle.net 一样。
到目前为止,我已经找到了很多像 jsbeautifier.org 这样的网站。但是我需要一个独立的 jquery 插件来处理我的代码
请帮我解决这个问题。

采纳答案by dxh

9 useful Javascript syntax highilghting scripts. There, I googled it for you. 3 of them are jQuery-based.

9 个有用的 Javascript 语法高亮脚本。在那里,我为你搜索了它。其中 3 个是基于 jQuery 的。

回答by Shree

i am using codemirror.
http://codemirror.net/

我正在使用代码镜像。
http://codemirror.net/

its easy and cool.

它简单而酷。

回答by demas

回答by Stofkn

If you want to change the syntax in a specific style or just check the style than take a look at code painter

如果您想更改特定样式的语法或只是检查样式,请查看代码画家

A JavaScript beautifier that can both infer coding style and transform code to reflect that style. You can also set style preferences explicitly in a variety of ways.

一种 JavaScript 美化器,可以推断编码风格并转换代码以反映该风格。您还可以通过多种方式明确设置样式首选项。

回答by Richard Harris

I have checked the pages linked by other answers and found them very lacking.

我检查了其他答案链接的页面,发现它们非常缺乏。

After a bit of research and scouring the web, I found onethat I think clearly is superior to the rest.

经过一番研究和网上搜索,我发现一个我认为明显优于其他的。

Snippitis jQuery based, including "copy" feature (with clipboard plugin), line-numbers, custom styles, etc.

Snippit基于 jQuery,包括“复制”功能(带有剪贴板插件)、行号、自定义样式等。

Let me know what you think.

让我知道你的想法。

回答by Chamika Sandamal

you can use jstidyfor this. and if you are using visual studio, you can directly copy code and paste in to the designer view. it will generates the required styles.

您可以为此使用jstidy。如果您使用的是visual studio,您可以直接复制代码并粘贴到设计器视图中。它将生成所需的样式。