最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

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

programmeradmin1浏览0评论

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

I mean so that there is some indentation and code formatting. Currently i only got / 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.

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

I mean so that there is some indentation and code formatting. Currently i only got http://alexgorbatchev./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.

Share Improve this question edited Feb 27, 2011 at 13:26 Alex asked Feb 27, 2011 at 13:17 AlexAlex 9,4784 gold badges31 silver badges40 bronze badges 3
  • you are at the right place.. stack overflow does syntax highlighting.. why dnt u just flick that js code.. :D – Baz1nga Commented Feb 27, 2011 at 13:20
  • 1 Tools for syntax highlighting are much more mon than tools for code formatting. It may be easier to run an existing tool on the server and get the formatted version via AJAX. – user395760 Commented Feb 27, 2011 at 13:21
  • The AJAX idea is not bad. You know any good formatters? – Alex Commented Feb 27, 2011 at 13:31
Add a ment  | 

3 Answers 3

Reset to default 7

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./Giki/examples/wiki.html

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

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

Here is a open source mand 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 plete 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)

  1. 暂无评论