Header Ads

Adding Specific Code Syntax Highlighter For Blogger

Adding Specific Code Syntax Highlighter For Blogger

code format


An embeddable script that makes source-code snippets in HTML prettier.
  • Works on HTML pages.

  • Works even if code contains embedded links, line numbers, etc.
  • Simple API: include some JS & CSS and add an onload handler.
  • Lightweights: small download and does not block page from loading while running.
  • Supports all C-like, Bash-like, and XML-like languages. No need to specify the language.
  • Extensible language handlers for other languages. You can specify the language.

Setup

  • Include the script tag below in your document:
<script src="https://cdn.rawgit.com/google/code-prettify/master/loader/run_prettify.js"></script>

Usage

Put code snippets in <pre class="prettyprint">...</pre> or <code class="prettyprint">...</code> and it will automatically be pretty-printed.
<pre class="prettyprint">class Voila {
public:
  // Voila
  static const string VOILA = "Voila";

  // will not interfere with embedded <a href="#voila2">tags</a>.
}</pre>
<pre class="prettyprint"><code class="language-java">...</code></pre>

class Voila {
public:
  // Voila
  static const string VOILA = "Voila";

  // will not interfere with embedded tags.
}

private int partition(int array[], int low, int high) {

        int pivot = array[high];
        int i = low - 1;
        for(int j = low; j < high; j++) {
            if(array[j] <= pivot ) {
                i++;

                int temp = array[i];
                array[i] = array[j];
                array[j] = temp;
            }
        }

        int temp = array[i + 1];
        array[i + 1] = array[high];
        array[high] = temp;

        return i+1;
    }

    /***
     * QuickSort Library
     * @param array
     * @param low
     * @param high
     */
    public void quickSort(int array[], int low, int high) {

        if(low < high) {
            int pi = partition(array, low, high);

            quickSort(array, low, pi -1);
            quickSort(array, pi + 1, high);
        }
    }

No comments