I was just reading how can you tell whether you're ready to start your own blog. The answers are so good and inspiring that I made rush to start my own blog using blogger [1] and stopped right in my tracks. I looked on the menu bar as I was creating my first post, and duh, there's no nice "code sample" formatting option like the one on Stackoverflow.
Does this exist on any of the standard blogging options (blogger/wordpress/livejournal) or is this something I'm going to have to code up myself?
Edit: Using the knowledge I have garnered from this post, I have started a blog using Wordpress [2] entitled //Coding Without Comments [3]. My first post states my reasons for starting a blog, experience in working with wordpress, and summarizes the best Code Formatting options. I will continue to update my post as more answers come in.
To the best of my knowledge, none of the mainstream blogging services have this built in. It is a function of design and template. I would go with Wordpress [1] because it is the best. For code formatting:
Note: If you want to have the most flexibility for constructing your blog template and functionality as you want it to be, you would need to use Self-hosted WordPress.org [7], not the hosted WordPress.com [8].
[1] http://Wordpress.org[sourcecode]
tags - Thomas Levesque
I was just looking at the Wordpress Plugins [1] and came across the WP-Syntax plugin [2].
[1] http://wordpress.org/extend/plugins/WP-Syntax provides clean syntax highlighting using GeSHi -- supporting a wide range of popular languages. It supports highlighting with or without line numbers and maintains formatting while copying snippets of code from the browser.
In my opinion, Blogger is the best hosted blog solution. It's free, you can have your own domain name, and you can totally customize the template. I'd check out the SytaxHighlighter like several other people here have mentioned. If you need a place to host js and other files, get an Amazon S3 [1] account, and use the S3 Organizer FireFox plugin [2].
Steer clear of hosted Wordpress. It is terrible. You cannot customize anything without paying for it.
One more thing that not many people pay attention to: If you want to have the best template to show code, I'd find one with a liquid layout. That way your code "box" can grow larger when the reader resizes their browser.
[1] http://aws.amazon.com/s3Thomas Levesque hinted at the answer in his comment on the "correct answer", but it wasn't really clear.
Maybe this will help others:
The following works perfectly in WordPress on a free blog with no plugins, scripts, or hassle.
[code lang="vbnet"]
Dim things As New List(Of Thing)
[/code]
Alternately, this also works:
[sourcecode language="vbnet"]
Dim things As New List(Of Thing)
[/sourcecode]
I suppose you're a programmer if you're lurking here :-) Then I would advise to host Wordpress (or any other blog software) yourself. Not at home, mind you, but on any of the cheap hosting companies around. I won't recommend mine as it's in France, a bit too far away.
There are two main reasons:
A few links on the subject:
Cheers
[1] http://www.problogger.net/archives/2006/02/15/choosing-a-blog-platform/You can convert the code into html with syntax highlighting before posting it to your blog. For example in vim you can use the :TOhtml [1] command.
Also you can use GeSHi [2] . The WordPress plugin WP-Syntax [3] uses GeSHi, but you can also use GeSHi offline.
[1] http://tips.webdesign10.com/how-to-convert-code-to-html-with-vimM-x htmlfontify-buffer
to achieve the same effect. It uses your Emacs color scheme by default, but should be easy to customize because it uses css for the actual styling. - Tikhon Jelvis
As a few people have already mentioned, I use SyntaxHighlighter [1] on my blog. The only issue I had with it is that my markup wouldn't be valid if I followed the instructions from the SyntaxHighlighter usage wiki. To fix this problem I added some simple jQuery code before SyntaxHighlighter scans my document:
$(document).ready(function() {
$('pre.code').attr('name', 'code').removeClass('code');
dp.SyntaxHighlighter.ClipboardSwf = 'clipboard.swf URL';
dp.SyntaxHighlighter.HighlightAll('code');
});
Instead of adding the name="code" attribute to my <pre/> tags, I add a 'code' class to my pre tags before I add my language attribute so my class attribute looks like this:
<pre class="code css">
</pre>
And my javascript code adds the 'name' attribute and removes the 'code' class dynamically so that my markup validates and works flawlessly with SyntaxHighlighter.
[1] http://code.google.com/p/syntaxhighlighter/Mango Blog [1] and BlogCFC [2] both support code blocks out of the box, using the code tag:
<code></code>
Both are CFML applications, so you'll either have to get some ColdFusion hosting, or run one of the open source alternative engines: Railo [3], OpenBD [4], (and it's there, but probably not full-featured enough to run these apps: The Smith Project [5])
[1] http://mangoblog.org/I use and recommend WordPress. You can start off with a hosted WordPress blog and move it off to another hosting provider if you want to take advantage of the great number of plug-ins available. With a hosted blog, you can only use the plug-ins that WordPress makes available to you.
...and use Windows Live Writer for writing/publishing. There are several nice code formatting plug-ins available for WLW.
I use WordPress with the "Code Markup" plugin. It has worked really well. You just surround the code in your posts with
<pre><code>code here</code></pre>
I use Gist [1] on my wordpress site. I tried the other Syntax highlighting plugins, but they never quite worked as well as I wanted.
[1] https://gist.github.com/It doesn't exist as standard, being somewhat niche, but there are plenty of nice scripts out there to help format. The best one I've seen (which is what Yahoo! use on their YUI pages) is SyntaxHighlighter [1].
Of course, given how nice the Stack Overflow boxes are for doing code, you might want to look at how they do things and "port" it to Blogger ;)
[1] http://code.google.com/p/syntaxhighlighter/I second Yaakov Ellis [1] - I personally use Windows Live Writer and Insert Code.
[1] http://stackoverflow.com/questions/9051/what-is-best-blogging-host-for-programmerscode-formatting#9057I really got into PHP programming thanks to Wordpress and would recommend it in a heartbeat. Active developer community, plugins and tutorials galore and it's a cinch to install.
copy and paste into word from visual studio. Then from word, copy and paste into your blog.
I use Chyrp [1] because it's lightweight and easy to use. For code formatting you can use the Geshify [2] module or my own code feather [3].
[1] http://chyrp.netCodeHTMLer [1] is a simple program that translates plain text code into a colorized HTML version of the code.
[1] http://puzzleware.net/codehtmler/default.aspxIf you use TextMate in Mac OSX, BitButter has a great post [1] on how to display your TextMate code (formatting included) in WordPress.
[1] http://www.bitbutter.com/displaying-textmate-code-in-your-wordpress-blog/13Code Markup [1] is another Wordpress Plugin.
[1] http://www.thunderguy.com/semicolon/wordpress/code-markup-wordpress-plugin/Squarespace [1] has a really nice admin interface, the best in the industry as far as I am concerned.
[1] http://www.squarespace.com/I just want to add CodeColorer [1] plugin for wordpress. It works really well. It has an option for escaping html entities and supports a lot of languages. Check you can see it in action on this post [2]
[1] http://wordpress.org/extend/plugins/codecolorer/