Add Pretty Print button for blogger editor


/ Published in: JavaScript
Save to your folder(s)

Add easily pre.prettyprint element for you code in the editor for blogger.
Only ejecute this script when you manage your post.

Note: version alpha.


Copy this code and paste it in your HTML
  1. _bt = document.createElement('button');
  2. document.body.appendChild(_bt);
  3. _bt.innerHTML='>Pretty Print!<';
  4. _bt.style.top='100px';
  5. _bt.style.position='absolute';
  6. _bt.onclick=function(){
  7. var range = document.getElementById('postingComposeBox').contentDocument.getSelection().getRangeAt(0),
  8. content = range.extractContents(),
  9. pre = document.createElement('pre');
  10.  
  11. pre.innerHTML = content.textContent;
  12. pre.className = 'prettyprint';
  13. var htmlContent = pre.innerHTML;
  14.  
  15. range.insertNode(pre);
  16. };

URL: http://porquero.blogspot.com

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.