Search This Blog

Thursday, November 9, 2017

Code Snippet on your Blog



Hello :)

While writing my previous post i was unaware how to copy code snippets (as their alignment have to be correct).

So here is how you do it

Go to HTML view of your blog and then add this at the header or at the top

<script language="javascript" src="https://google-code-prettify.googlecode.com/svn/trunk/src/prettify.js" type="text/javascript">
<script language='javascript' type='text/javascript' src='https://google-code-prettify.googlecode.com/svn/trunk/src/lang-css.js' />

<script type='text/javascript'>
function addLoadEvent(func) {
  var oldonload = window.onload;
  if (typeof window.onload != 'function') {
    window.onload = func;
  } else {
    window.onload = function() {
      if (oldonload) {
        oldonload();
      }
      func();
    }
  }
}
addLoadEvent(prettyPrint);
</script>


and then paste your code snippet between the below mentioned tag

<pre class="prettyprint">
---your code here---
</pre>

No comments:

Post a Comment