0

Is there an open source project out there (written in Java Script or otherwise, for formatting code samples for well-known programming langauges?

I'm trying to create a documentation website that includes code samples. Here is an example of what my html looks like:

<pre><code>//example c#/html/etc code here</code></pre>

I'm using MarkDownSharp to format and encode the sample code, but Markdown doesn't handle the coloring. I notice when adding code samples to Stack Overflow, it automatically colors it in, making it much more readable.

Is this a proprietary technology that SO uses, or is that available somewhere?

Nathan A
  • 11,059
  • 4
  • 47
  • 63

3 Answers3

1

I think CodeMirror is the one you need.

jsfiddle is using this libary as well

Friedrich
  • 2,211
  • 20
  • 42
  • Thanks for the lead. I notice that's its presented as a code editor. I'm looking for a display-only solution. Can CodeMirror be configured for that? – Nathan A May 22 '14 at 17:37
  • Yes I am sure that is possible. I even think there is a CSS-only solution. – Friedrich May 22 '14 at 17:42
0

Igor Russkih (Cail Lomecb) created Colorer library, see http://colorer.sourceforge.net which has syntax highlighters for many programming languages and formats.

It is available as plugin into Far Manager or as standalone easy to use command line tool.

...running colorer -h -ei UTF-8 -eo UTF-16BE -o NAME.HTML yoursource.cpp will cause highlighted html generation of yoursource.cpp file with output name NAME.HTML, using UTF-8 as input encoding and UTF-16BE as encoding of result file...

Source: http://colorer.sourceforge.net/consoletools.html

Community
  • 1
  • 1
xmojmr
  • 8,073
  • 5
  • 31
  • 54
0

For JavaScript (your expressed preference), the two most popular are Prism and highlight.js

Stephen Thomas
  • 13,843
  • 2
  • 32
  • 53