Showing posts with label js. Show all posts
Showing posts with label js. Show all posts

Thursday, October 15, 2015

Easy formatting of source code in blogger: inlined and blocks

Add wiki-like code blocks and inlined code snippets in your blogger posts

Posting pieces of code to blogger is annoying. Reverting to HTML editor mode to insert special tags is not fun at all, and prone to inconsistency. I tried using external code-formatting libraries, such as the very nice SyntaxHighlighter, but it is very heavy and makes your site slow to load imho.

So here is a short hack to handle simple pieces of codes. Moreover it handles angled brackets completely transparently (resp. the < and > symbols), that often pollutes copy/pasted codes.

It only requires twenty lines of javascript and CSS to be copy/pasted in your blog.