Skip to main content

Posts

Showing posts with the label syntaxhighlighter

SyntaxHighlighter Test

This blogs is a part-2 of How to add SyntaxHighlighter to Blogger where I will be testing the syntax highlighting abilities of this library. SyntaxHighlighter provides various configuration parameters to be used with the <pre> tag. Java (With Rulers -- not working?) <pre code="brush: java; ruler: true;"> import java.io.*; public class HelloWorld{ public static void main(String[] args){ System.out.println("Hello World!"); } } </pre> import java.util.*; import java.io.*; public class HelloWorld{ public static void main(String[] args){ System.out.println("Hello World!"); } } Python (With the first line number set to 100) <pre class="brush: python; first-line: 100"> import os import sys import time class Box: def method1(self, x, y): try: print x, y except: pass </pre> import os import sys import time class Box: def method1(self, x, y): try: ...

How to add SyntaxHighlighter to Blogger

SyntaxHighlighter is a code syntax highlighter developed in Javascript. It can be used to highlight code snippets in your blogs to improve the readability. This blog looks at how SyntaxHighlighter can be installed in Blogger. As per the official website , the installation instructions are as follows: 1. Install the base files: * https://alexgorbatchev.com/pub/sh/current/scripts/shCore.js * https://alexgorbatchev.com/pub/sh/current/styles/shCore.css 2. Install the theme * https://alexgorbatchev.com/pub/sh/current/styles/shThemeDefault.css 3. Install the brushes you want * https://alexgorbatchev.com/pub/sh/current/scripts/shBrushBash.js * https://alexgorbatchev.com/pub/sh/current/scripts/shBrushPlain.js * https://alexgorbatchev.com/pub/sh/current/scripts/shBrushPython.js 4. Invoke SyntaxHighlighter during page load and execute the following functions for blogger: * SyntaxHighlighter.config.bloggerMode = true; * SyntaxHighlighter.all(); The resulta...