- Copy the below code;
<!--SYNTAX HIGHLIGHTER BEGINS--> <link href='http://alexgorbatchev.com/pub/sh/current/styles/shCore.css' rel='stylesheet' type='text/css'/> <link href='http://alexgorbatchev.com/pub/sh/current/styles/shThemeRDark.css' rel='stylesheet' type='text/css'/> <script src='http://alexgorbatchev.com/pub/sh/current/scripts/shCore.js' type='text/javascript'/> <script src='http://alexgorbatchev.com/pub/sh/current/scripts/shBrushBash.js' type='text/javascript'/> <script src='http://alexgorbatchev.com/pub/sh/current/scripts/shBrushCpp.js' type='text/javascript'/> <script src='http://alexgorbatchev.com/pub/sh/current/scripts/shBrushCSharp.js' type='text/javascript'/> <script src='http://alexgorbatchev.com/pub/sh/current/scripts/shBrushCss.js' type='text/javascript'/> <script src='http://alexgorbatchev.com/pub/sh/current/scripts/shBrushJava.js' type='text/javascript'/> <script src='http://alexgorbatchev.com/pub/sh/current/scripts/shBrushJScript.js' type='text/javascript'/> <script src='http://alexgorbatchev.com/pub/sh/current/scripts/shBrushPhp.js' type='text/javascript'/> <script src='http://alexgorbatchev.com/pub/sh/current/scripts/shBrushPython.js' type='text/javascript'/> <script src='http://alexgorbatchev.com/pub/sh/current/scripts/shBrushRuby.js' type='text/javascript'/> <script src='http://alexgorbatchev.com/pub/sh/current/scripts/shBrushSql.js' type='text/javascript'/> <script src='http://alexgorbatchev.com/pub/sh/current/scripts/shBrushVb.js' type='text/javascript'/> <script src='http://alexgorbatchev.com/pub/sh/current/scripts/shBrushXml.js' type='text/javascript'/> <script src='http://alexgorbatchev.com/pub/sh/current/scripts/shBrushPerl.js' type='text/javascript'/> <script language='javascript'> SyntaxHighlighter.brushes.Clojure = function() { // Contributed by Travis Whitton var funcs = ':arglists :doc :file :line :macro :name :ns :private :tag :test new add-hook alias alter and apply assert class cond conj count def defmacro defn defun defstruct deref do doall dorun doseq dosync eval filter finally find first fn gen-class gensym if import inc keys let list loop map ns or print println quote rand recur reduce ref repeat require rest send seq set setq sort str struct sync take test throw trampoline try type use var vec when while'; this.regexList = [ { regex: new RegExp(';[^\]]+$', 'gm'), css: 'comments' }, { regex: SyntaxHighlighter.regexLib.multiLineDoubleQuotedString, css: 'string' }, { regex: /\[|\]/g, css: 'keyword' }, { regex: /'[a-z][A-Za-z0-9_]*/g, css: 'color1' }, // symbols { regex: /:[a-z][A-Za-z0-9_]*/g, css: 'color2' }, // keywords { regex: new RegExp(this.getKeywords(funcs), 'gmi'), css: 'functions' } ]; this.forHtmlScript(SyntaxHighlighter.regexLib.aspScriptTags); } SyntaxHighlighter.brushes.Clojure.prototype = new SyntaxHighlighter.Highlighter(); SyntaxHighlighter.brushes.Clojure.aliases = ['clojure', 'Clojure', 'clj', 'lisp']; </script> <script language='javascript'> SyntaxHighlighter.config.bloggerMode = true; SyntaxHighlighter.config.clipboardSwf = 'http://alexgorbatchev.com/pub/sh/current/scripts/clipboard.swf'; SyntaxHighlighter.config.strings.expandSource = 'show source'; SyntaxHighlighter.config.strings.viewSource = 'view source'; SyntaxHighlighter.all(); </script> <!--SYNTAX HIGHLIGHTER ENDS-->
- Note that i have a custom hightlighter in this set for lisp (emacs configs etc)
- Go to Blogger Dashboard > Layout > Edit HTML.
- Press CTRL+F to find the code </html>.
- Add the code to the location before the final </b:section-contents>. This depends highly on what blogger template you have, so you may need to experiment with it a bit. You want to add the syntax highlighter to the end of the page because if the 3rd party site providing javascript is down or under heavy load your blog wont load its content.
- You can alter the Color Theme from "shThemeRDark.css" with different ones as explained here
http://alexgorbatchev.com/SyntaxHighlighter/manual/themes/
- Then to highlight a section of code add the following around it in the blogger edit/new posts screen.
<pre class="brush:cpp"> //code here </pre>
The item after the "brush:" is altered to match your code syntax. The possibles are listed here; http://alexgorbatchev.com/SyntaxHighlighter/manual/brushes/. Of course you need to check that you have installed the brush to get the highlight working.
Other Refs;
No comments:
Post a Comment