admin管理员组文章数量:1341026
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
3 Answers
Reset to default 7Probably 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.
版权声明:本文标题:how to pretty print source code of common languages in browser html output with javascript? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1743662495a2518181.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论