Wiki

Clone wiki

info.bliki.wiki / SourceCode2HTML

Sourcecode to syntax highlighted HTML converter

A syntax highlighter is available for the languages: ABAP (SAP R/3), C#, Groovy, Java, JavaScript, PHP, Python, SQL XML(HTML).

A conversion from Java to syntax highlighted HTML looks like this:

#!java
import info.bliki.wiki.tags.code.JavaCodeFilter;
import info.bliki.wiki.tags.code.SourceCodeFormatter;

public class HelloWorld {

    public static void main(String[] args) {
        String javaCode = "public class HelloWorld {\n" +
                "   public static void main(String[] args) {\n" +
                "       System.out.println(\"Hello World\");\n" +
                "   }\n" +
                "}\n" +
                "";
        SourceCodeFormatter f = new JavaCodeFilter();
        String result;
        String coding1 = "<pre class=\"java\" style=\"border: 1px solid #b4d0dc; background-color: #ecf8ff;\">";
        String coding3 = "</pre>";
        result = f.filter(javaCode);
        result = coding1 + result + coding3;
        System.out.println(result);
    }
}

You can use the source code to syntax highlighted HTML converter online here:

Updated