开发者

how to pretty print source code of common languages in browser html output with javascript?

how to pretty print sour开发者_如何学Cce code of common languages in browser html output with javascript?

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.

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

I am grateful for any help.


Probably SyntaxHighlighter is the most popular. But you have a choice, have a look at 16 Free Javascript Code Syntax Highlighters For Better Programming

If you mean real time syntax highlighter, you can also try JS-CodeEdit:

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.

But it support a bit limited list of languages: JavaScript, PHP, Perl, HTML, CSS, XML, SQL (this list is increased with each release).


You might want to check out Giki : http://guyht.github.com/Giki/examples/wiki.html

Its a real time syntax highlighter, very easy to customise.

GitHub Repo: https://github.com/guyht/Giki


Here is a open source command line program, with optional GUI, which can format and highlight approx. 100 programming languages, with configurable colour themes and output as HTML, XHTML, RTF, TeX, LaTeX, terminal escape sequences, SVG and BBCode format. See the complete feature list, examples, screenshots and screencast.

There is also a macOS quick view plugin available, too. This is not Javascript but you can do the stuff ex. via AJAX.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜