Show Source Code on Web


Sometime it is helpful to show source code on the website or blog. One way to do it is to write your code in rst or markdown format, and then convert the rst or markdown document to html. Another way is to use online source code to html coverter. Google search "source code to html". I found [1] is the best online converter:

Demo (with line numbers):

1
2
3
4
5
6
7
#include <stdio.h>

int main() {
  printf("hello world\n");

  return 0;
}

Demo (without line numbers):

#include <stdio.h>

int main() {
  printf("hello world\n");

  return 0;
}

References:

[1]Source code beautifier / syntax highlighter – convert code snippets to HTML « hilite.me

More silimar online converters:

[2]Online syntax highlighting
[3]Code2HTML
[4]Convert Code Online
[5]Online syntax highlighter like TextMate
[6]Quick Highlighter: A simple to use code syntax highlighter