How to pretty print the source code of common languages โ€‹โ€‹in a browser HTML file with javascript?

How to pretty print the source code of common languages โ€‹โ€‹in a browser HTML file with javascript?

I mean, there are some indentation and code formatting. Currently, I only got http://alexgorbatchev.com/SyntaxHighlighter/ for syntax coloring. But I would also like padding and other formatting.

Example: a user enters some code. system formats and highlights the code in the browser view. so-> is there a common code formatting code? best in javascript

I am grateful for any help.

+4
source share
3 answers

SyntaxHighlighter is probably the most popular. But you have a choice, check out 16 free Javascript code syntax shortcuts for better programming

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

JS-CodeEdit is a JavaScript editor that converts your HTML text fields into a code editor with real-time syntax highlighting . If you added to the form, the content may be submitted, for example. to write to a file. The good thing is that you can add as many editors as you want in the HTML page.

But it supports a slightly limited list of languages: JavaScript, PHP, Perl, HTML, CSS, XML, SQL (this list grows with each version).

+6
source

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

Its real-time syntax syntax is very easy to configure.

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

+1
source

Here I have a command line program that can be formatted and highlighted ok. 100 programming languages

http://www.andre-simon.de/dokuwiki/doku.php?id=en:supported_languages

with customizable color themes and outputs in HTML, XHTML, RTF, TeX, LaTeX, terminal escape sequences, SVG and BBCode format.

http://www.andre-simon.de/dokuwiki/doku.php?id=en:features

http://www.andre-simon.de/doku/highlight/en/highlight.html

Mac OS Quick View Plugin is also available. This is not Javascript, but you can do ex things. through ajax.

+1
source

Source: https://habr.com/ru/post/1341516/


All Articles