如何使用javascript在浏览器html输出中漂亮地打印常用语言的源代码? [英] how to pretty print source code of common languages in browser html output with javascript?
问题描述
如何使用 javascript 在浏览器 html 输出中漂亮地打印常用语言的源代码?
how to pretty print source code of common languages in browser html output with javascript?
我的意思是有一些缩进和代码格式.目前我只有http://alexgorbatchev.com/SyntaxHighlighter/为语法着色.但我也想要一些缩进和其他格式.
I mean so that there is some indentation and code formatting. Currently i only got http://alexgorbatchev.com/SyntaxHighlighter/ for coloring the syntax. But i would also like some indentation and other formatting.
示例:用户输入一些代码.系统格式化并在浏览器视图中突出显示代码.so-> 是否有用于格式化代码的通用代码格式化程序?最好的javascript
Example: user puts in some code. system formats and highlights code in the browser view. so-> is there a general code formatter for formatting code? best in javascript
我很感激任何帮助.
推荐答案
可能 SyntaxHighlighter 是最受欢迎的.但是你有一个选择,看看 16 个免费的 Javascript 代码语法高亮工具,用于更好的编程
Probably SyntaxHighlighter is the most popular. But you have a choice, have a look at 16 Free Javascript Code Syntax Highlighters For Better Programming
如果你的意思是实时语法高亮,你也可以试试 JS-CodeEdit:
If you mean real time syntax highlighter, you can also try JS-CodeEdit:
JS-CodeEdit 是一个 JavaScript 编辑器将您的 HTML textareas 转换为具有实时语法的代码编辑器突出显示.如果添加到表单中,可以提交内容,例如至写入文件.一件好事是您可以添加尽可能多的编辑器您想要在 HTML 页面中.
JS-CodeEdit is a JavaScript editor that converts your HTML textareas into a code editor with realtime syntax highlighting. If added into a form, the content can be submitted e.g. to be written to a file. A nice thing is that you can add as many editors as you want within a HTML page.
但它支持的语言列表有点有限:JavaScript、PHP、Perl、HTML、CSS、XML、SQL(每个版本都会增加此列表).
But it support a bit limited list of languages: JavaScript, PHP, Perl, HTML, CSS, XML, SQL (this list is increased with each release).
这篇关于如何使用javascript在浏览器html输出中漂亮地打印常用语言的源代码?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!