How can I display code better on my blogger blog?

Viewed 9451

These days, in any site where they show a code fragments (even in Stackoverflow), the code is nicely wrapped around a GUI element which highlights syntax elements, provides line numbers, etc. I want to show some ruby on rails code in my blog and I want those visual elements in my blog.

How can I accomplish this on my blogger blog?

7 Answers

To display code in an article or to highlight code in blogger or in any other blogging platform you can use Github Gist, I found this way is very easy which doesn't depend on any external highlighting javascript library.

Here you can create any public gist for code snippet for javascript (.js), Csharp(.cs), shell script (.sh) etc So it can be loaded in article.

enter image description here

Once you saved gist file one link or Embed option is displayed on a gist as per above screenshot and you have to just paste in an article here I have attached a screenshot for blogger below

enter image description here

Once you have added embed script in blogger article you can see a preview of code snippet which rendered as below screenshot.

enter image description here

Related