Tuesday, January 10, 2017

Syntax highlighting

When I was programming in high school in college... you get a text editor. That's it. NO syntax highlighting. Forgot to close a comment block? It will be a while before you find out. Now editors even shows you error as you type like a word processor. Great stuff.

The first IDE I saw that has syntax highlighting was Visual C++ 1.0. Wow that's great. Then everyone is spoiled and just about every tool has it.

Ok, how do you do that in your own little html page. Yes you can insert <font color="green"> for your comments... and <b> every keyword but that's time consuming right? Sure you can write your own little lexical processor and figure out your syntax and write your own little syntax formatting.

Or you can tap onto somebody else's library. This one is awesome: http://alexgorbatchev.com/SyntaxHighlighter/manual/installation.html

Boring:

// Simple java code highlighted!
public class HelloWorld {

    public static void main(String[] args) {
        System.out.println("Hello, World");
    }

}

A lot better:

// Simple java code highlighted!
public class HelloWorld {

    public static void main(String[] args) {
        System.out.println("Hello, World");
    }

}

No comments: