WebsiteKevin_Jilissen at

SBCMS now includes a codeblock class with automatic syntax highlighter for Java, JavaScript, XML / HTML and PHP. More languages are coming soon. The highlighter uses regular expressions to highlight the keywords in the browser and shows line numbers before the code.

To use this new feature, you simply use the following HTML in your template:


<div id="Test" class="codeblock" data-plang="Java">
    <pre class="linenumbers"></pre>
    <pre class="code"><code>System.out.println("Hello World!");</code></pre>
    <script>Highlighter.onCreate()</script>
</div>

This feature may still contain a few bugs and will not work perfectly. The function is under development but I think it is good enough to publish already.

Here is another example showing a piece of Java code:


package nl.kevinjilissen;

public class HelloWorld {

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

        // Output all arguments
        for (int i = 0; i < args.length; i++) {
            System.out.println(i + ": " + args[i]);
        }
    }
}

Comments

Nobody has commented on this post yet. Be the first one to comment!

Post comment

Please log in in order to comment on the post.