Slashdot Mirror


Best Weblog Application for Posting Source Code?

BrewerDude asks: "I've set up a blog about programming (URL withheld: this isn't about self-promotion). I'm currently using one of the popular blog hosting services, but find it lacking when it comes to handling source code snippets in posts. It's even worse when it comes to dealing with code snippets that people include in their comments. At this point I'm frustrated enough that I'm ready to move from that service to something else. Ideally, I'm looking for something that will handle syntax highlighting for a variety of languages and do this for both the posts and the comments. I'd prefer a hosted solution, but am not opposed to installing and maintaining my own instance of a blog application if necessary. What have you found to be the best blog application when it comes to supporting posts and comments that include source code?"

75 comments

  1. Google... by jginspace · · Score: 2, Informative

    Top result: http://www.google.com/search?q=coding+blog is powered by something I'd never heard of called Community Server http://communityserver.org/.

    I'm currently using one of the popular blog hosting services, but find it lacking when it comes to handling source code snippets in posts.

    I can see what you mean after swiftly browsing some of the other sites that came near the top of the above search... I would have thought WordPress would have a plugin though...

    1. Re:Google... by stoborrobots · · Score: 1

      I've heard of Community Server, as it also powers The Daily WTF.

      Unfortunately, the readers of the site are generally of the opinion that "The real WTF is this forum software" because "the forum software sucks" ...

      For what it's worth, it appears to be great as a blogging tool; Alex seems to like the way it works for the blogging functions, but the forum functions are what are generally found to be "quirky"...

    2. Re:Google... by masklinn · · Score: 1
      Community server is above average for displaying code (compared to most blogging softwares who don't give you much more than "here's your
       tag now leave us alone"), but it's a piece of crap for everything else. The default style is ugly, the comment system is annoying, and there is far too much javascript involved (even though since version 2 you can actually try to use it with javascript disabled, would've been a pipe dream with CS 1)
      --
      "The way we can tell it's C# instead of Haskell is because it's nine lines instead of two." -- wadler
    3. Re:Google... by Zontar+The+Mindless · · Score: 2, Informative
      I would have thought WordPress would have a plugin though...


      Scott Reilly's Preserve Code Formatting plugin is working fine for me with WordPress 2.0.4.
      --
      Il n'y a pas de Planet B.
    4. Re:Google... by Anonymous Coward · · Score: 0

      From it's use of an XML frameset DTD for a document with a body element to use of horizontal scrollbars for overflow in the commenting system, Community server is one large steaming pile of WTF!

      An ironic WTF is that you can't even register on the daily WTF without enabling javascript because it uses ASP's viewstate (which is a WTF in and of itself).

  2. use slashcode by LiquidCoooled · · Score: 2, Funny

    #include <stdio.h>

    void main()
    {
        printf ("only joking!\n");
    }

    --
    liqbase :: faster than paper
    1. Re:use slashcode by LiquidCoooled · · Score: 1

      Slashdot is a discussion board, but it has blogging features due to the journals each person can post (in the zoo).
      Its got all the elements of a freidnster type social networking site (with friends and foes and private discussions etc).

      Its like web 2.0 without the chunky graphics.

      --
      liqbase :: faster than paper
    2. Re:use slashcode by Anonymous Coward · · Score: 0

      > Its like web 2.0 without the chunky graphics.

      Web 2.0 is about introducing vacuous mouth breathers to stuff the tech community has been using for years. RSS, forums (communities) and blogs were in common usage at the start of this decade and updating a frame with javascript is an idea dating back to the later part of the last decade (a terrible idea even back then).

      Other than convincing gullable investors to part with their money, web2.0 is meaningless.

      NB: Generous use of the word decade rather than century or millenium.

    3. Re:use slashcode by quigonn · · Score: 3, Insightful

      I gues you wanted to use one of the actually allowed signatures of the main function:

      int main(void) { }
      int main(int argc, char * argv[]) { }

      --
      A monkey is doing the real work for me.
    4. Re:use slashcode by LiquidCoooled · · Score: 1

      Back when I was writing C I never had a problem with void, sure it might be technically incorrect but back then I didn't care.
      My compiler was happy, my programs worked and I only ever used the int return when I needed to.

      --
      liqbase :: faster than paper
    5. Re:use slashcode by forkazoo · · Score: 1
      Back when I was writing C I never had a problem with void, sure it might be technically incorrect but back then I didn't care.
      My compiler was happy, my programs worked and I only ever used the int return when I needed to.


      Men have been shot for less than that. (Seriously, never admit that in comp.lang.c )
    6. Re:use slashcode by LiquidCoooled · · Score: 1

      If you think thats bad, you should see how I indent my code ;)

      --
      liqbase :: faster than paper
    7. Re:use slashcode by drakaan · · Score: 1

      ...and updating a frame with javascript is an idea dating back to the later part of the last decade (a terrible idea even back then).

      Not that I doubt your analytical abilities (whoever you may be), but what makes updating a frame (or div, or whatever else you might need to update) with javascript a terrible idea? What's the better alternative?

      If you're specifically talking about frames, I'd tend to say that frames are a bad idea in and of themselves, but I'm wondering what you mean specifically.

      --
      "Murphy was an optimist" - O'Toole's commentary on Murphy's Law
    8. Re:use slashcode by Anonymous Coward · · Score: 0

      I guess you wanted to learn C++ but gave up. The return type isn't part of the signature, and the void argument list is optional syntax. Cheers.

    9. Re:use slashcode by aevans · · Score: 1

      Actually a "web log" is a log of web sites. Like slashdot. Somewhere some people got them confused with public diaries, probably both types of pages added "guestbook" comment features and and datestamps originally with server side includes.

    10. Re:use slashcode by Anonymous Coward · · Score: 0

      Or the equivalent

      int main(int argc, char** argv) { }

    11. Re:use slashcode by Schraegstrichpunkt · · Score: 1

      "or some other implementation-defined manner" (ISO/IEC 9899:1999 (E), s. 5.1.2.2.1 "Program startup")

      Maybe the guy is writing code for some weird embedded OS? ;)

    12. Re:use slashcode by Anonymous Coward · · Score: 0

      or Plan9

  3. DokuWiki by bigpresh · · Score: 5, Informative

    It's not a blog service/package per se (although there are some blogging-type plugins for it) but I find DokuWiki to be excellent at handling code snippets with decent syntax highlighting, and easy to use.

    An example bit of code can be done as easily as:

    <code perl>
    # some code here
    </code>

    1. Re:DokuWiki by captnitro · · Score: 2

      I absolutely second DokuWiki. I've used it in several projects and it's incredibly easy to work with, and requires no database. I've set it up a few times as a beginner Wiki as well.

  4. Ikiwiki + source code coloring from Trac by halfnerd · · Score: 3, Informative

    Ikiwiki ( http://ikiwiki.kitenet.net/ ) is a really extendable wiki/blog-software and you could write a plugin in the style of Trac's Syntax Coloring support ( http://trac.edgewall.org/wiki/TracSyntaxColoring )

  5. URL withheld... by hoscetap · · Score: 0, Offtopic

    > (URL withheld: this isn't about self-promotion)

    or do you mean: "afraid of being slashdotted"

    1. Re:URL withheld... by jesboat · · Score: 1

      Mods: it's not offtopic, it's funny!

  6. JavaScript syntax highlighting by bigHairyDog · · Score: 3, Informative

    Dean Edwards' javascript syntax highlighter handles several languages (you can easily add your own) and operates via DHTML behaviors so you don't even need to include the script files in the page. It works in most browsers.

    http://dean.edwards.name/my/examples/star-light/

    What you need to use it is a blog that will let you post files to the server or create your own custom HTML templates, and then let people post HTML code. Code wrapped in <pre class="javascript"> gets highlighted correctly.

    If you can't post files, a bit of hacking around with the source code and you can embed it in a template and invoke it manually with javascript.

    Wordpress lets you post your own HTML templates with script - either install it on your own server or go for their free hosted service at wordpress.com.

    --

    foo mane padme hum

    1. Re:JavaScript syntax highlighting by QuantumG · · Score: 1

      That is so cool! I'm gunna add that to my blog right now!

      --
      How we know is more important than what we know.
    2. Re:JavaScript syntax highlighting by 6031769 · · Score: 1

      Just a note of caution - that link reproducibly locks up my Firefox (1.5.0.7 on Linux). With JS turned off, it's fine, but that does rather defeat the purpose.

      --
      Burns: We're building a casino!
      McAllister: Arrr. Give me 5 minutes.
    3. Re:JavaScript syntax highlighting by Anonymous Coward · · Score: 0

      It's working fine on FF 1.5.0.7 for Windows.

    4. Re:JavaScript syntax highlighting by WebCrapper · · Score: 1

      Using FF 1.5.0.7 on SUSE and its fine for me.

    5. Re:JavaScript syntax highlighting by Anonymous Coward · · Score: 0

      If you're going to promote your blog so damn much in most of your postings, why don't you add a few more Adsense ads to the "blog"... I'm so tired of seeing this kind of crap. It would be nice if Slashdot offered nofollow tags to urls because of link whoring people like you.

  7. This *IS* about self promotion... by QuantumG · · Score: 1

    I use Blogger and I've found that I have no problem communicating in code. Syntax hilighting for different languages? Uhh no, but maybe if you recommended it to Google they'd do it as a summer of code project or something. In any case, I bet my blog is way geekier than yours!

    --
    How we know is more important than what we know.
  8. You *are* a programmer by Kawahee · · Score: 3, Funny

    You know, as a programmer, you could write it yourself...

    --
    I'll subscribe to Slashdot when I see a month without a dupe, a typo, or an article the "editors" didn't read.
    1. Re:You *are* a programmer by usacomp2k3 · · Score: 2, Informative

      Why reinvent the wheel if it's already available?

    2. Re:You *are* a programmer by LarsWestergren · · Score: 2, Informative

      You know, as a programmer, you could write it yourself...

      Oh, absolutely. As a programmer, I say it is his SACRED DUTY to uphold the tradition of Not Invented Here! ;-)

      --

      Being bitter is drinking poison and hoping someone else will die

    3. Re:You *are* a programmer by dhasenan · · Score: 1

      A short script involving indent, listing, and latex2html would do the trick. That's more piping than reinventing.

      http://backpan.perl.org/authors/id/C/CH/CHTTRAX/ provides listing, which converts C++ or Perl to LaTeX. If you want a solution for other languages, well, no ideas.

    4. Re:You *are* a programmer by Lodragandraoidh · · Score: 1

      Kawahee, you must not be a programmer. If you were, you would know that one of the key aspects of an effective programmer is laziness. Developers manifest this quality by spending inordinant hours researching (or less successfully asking /.), downloading and testing various tools built by other programmers in order to find the 'right thing'. If, and only if they can not find a tool that does a very high percentage of what they want, then they will break down and spend the time to build it themselves. More commonly, they will use the 'high percentage' tool, and build a smaller add-on to capture that last few percentage points.

      This, of course, assumes the developer does not work in a shop where the choice of tools is dictated by management.

      --

      Lodragan Draoidh
      The more you explain it, the more I don't understand it. - Mark Twain
    5. Re:You *are* a programmer by stevenharman · · Score: 1

      >>one of the key aspects of an effective programmer is laziness I couldn't agree more... and that's probably why I have so many ideas, yet so few implemented products to show for it. ;) But I digress... Phil Haack makes some great points about rolling your own blog engine and why such attempts often come up short. The whole idea of having proper source code formatting/highlighting built into the blog engine is something that I too have have been longing for. It just seems such a daunting task as I'd want to support so many languages - but perhaps this would be one of those times to start small and get just one or two working. Maybe this will be a plug-in I'll look into building for the 2.0 release of Subtext.

      --
      90% of being smart is knowing what you're dumb at.
    6. Re:You *are* a programmer by stevenharman · · Score: 1

      And now for a properly formatted post... damn Preview Button!

      >>one of the key aspects of an effective programmer is laziness

      I couldn't agree more... and that's probably why I have so many ideas, yet so few implemented products to show for it. ;)

      But I digress... Phil Haack makes some great points about rolling your own blog engine and why such attempts often come up short.

      The whole idea of having proper source code formatting/highlighting built into the blog engine is something that I too have have been longing for. It just seems such a daunting task as I'd want to support so many languages - but perhaps this would be one of those times to start small and get just one or two working.

      Maybe this will be a plug-in I'll look into building for the 2.0 release of Subtext.

      --
      90% of being smart is knowing what you're dumb at.
  9. Syntax highlighter by ricardo_nz · · Score: 3, Informative

    Not sure about a decent blog... but for highlighting code, geshi does a nice job.

    1. Re:Syntax highlighter by Darth_Burrito · · Score: 1

      I've started to use geshi and find it to be very nice. There is a plugin available for serendipity and probably for a number of other blog apps. One problem I've noted though, is that geshi can be very slow. Sometimes it takes 10-20 seconds to render a large ugly html file. On the other hand, I've noticed sometimes it only takes a few seconds. If you store the marked up code in the blog app instead of re-marking it up for every request, the delay probably won't be a major concern.

    2. Re:Syntax highlighter by olaf2 · · Score: 1

      I'm using Geshi with in my regular website and it's working great! Next I used a wordpress plugin that's powered with geshi and the result is very bad (like with all other highlighters). The problem are all the filters used in WP, a html tag inside php code is parsed as a html tage and not as a string.

  10. Everything you wanted to know about that by Anonymous Coward · · Score: 0
  11. Not a blog, but... by Masa · · Score: 2, Interesting

    Well, I faced a similar need some time ago. I ended up using MoinMoin. I know, it's not a blogging software, it's a wiki, but in my case it does the job. There might be some other choices available at the wiki-front, but MoinMoin has syntax-colorisation for some programming languages built-in (Python, C, SH scripts if I remember correctly, I had a need for Python only).

  12. Copy Source as HTML by JamesNK · · Score: 2, Informative

    If you're using Visual Studio and you want your code snippits to look like they do in the IDE then I highly recommend the Copy Source as HTML plugin. It takes your code and produces a very clean HTML copy, correctly indented and colored, which you can then paste into your post.

    You can see an example of it in a blog post here.

    1. Re:Copy Source as HTML by Masa · · Score: 1

      By the way, Vim is another editor, which is able to save syntax-highlighted code as an HTML.

    2. Re:Copy Source as HTML by xtracto · · Score: 0, Flamebait
      By the way, Vim is another editor, which is able to save syntax-highlighted code as an HTML.

      How do you achieve that? is it the command
      :kjwerwuir2gt/html/sdlkafj2l2aldk/sxzasdklfjas;w3r
      --
      Ubuntu is an African word meaning 'I can't configure Debian'
    3. Re:Copy Source as HTML by dolmen.fr · · Score: 1

      There is also a menu: Syntax >> Convert to HTML.

      But I would not call it clean HTML code as it uses FONT tags.

    4. Re:Copy Source as HTML by dolmen.fr · · Score: 2, Informative

      ...unless you use:

      let use_xhtml=1
      let html_use_css=1

  13. Plain text, fixed font? by kosmosik · · Score: 1

    How about some plain-old-text displayed using fixed size font?

  14. Re:your sig by Kawahee · · Score: 1

    Duly noted.

    --
    I'll subscribe to Slashdot when I see a month without a dupe, a typo, or an article the "editors" didn't read.
  15. pastecode by staalanden · · Score: 2, Informative

    I think http://pastecode.com/ is what you are looking for

    1. Re:pastecode by sowth · · Score: 1
  16. Wordpress by fren · · Score: 1

    Wordpress is a great option.

    1. Re:Wordpress by Strixy · · Score: 1

      Being a big fan of Wordpress I did some digging for you.

      Bennett McElwee, has a Wordpress plugin that gives you more control over the appearance of your code in your posts. You can get it here. There is also an "alternatives" section near the bottom of the page listing four more plugins that do similar work in different ways depending on your needs. (How cool is that?)

      Wordpress does have a very basic code formatting button for posts, but not for comments. As usual, there is already a plugin that solves that problem too.

  17. vim + nanoblogger by Phoe6 · · Score: 2, Informative

    Here is what I do it, using nanoblogger and using vim as my editor. I wouuld rely on vim Syntax handling ablities and covert the portion of the code into :TOHtml.

    --
    Senthil
  18. You want Drupal + appropriate filter by yelvington · · Score: 3, Informative

    Drupal and the codefilter module will do a good job of supporting basic code entry in any arbitrary language. If you want robust support for highlighting for multiple languages, take a look at GeSHIFilter.

    http://drupal.org/
    http://drupal.org/project/codefilter
    GeSHIFilter: http://drupal.org/node/65961 and demo: http://www.ubisum.com/node/27

  19. Blogger by any other name? by durandal61 · · Score: 1

    You're talking about Blogger, right? Its Composer is sort of OK for anything but source code. When you do want to use it for code, it reveals its donkey-penis-sucking nature. I tried every which way, but it is so amazingly dumb that it will turn &gt; into >, and then choke on the spurious HTML-esque tags that are created.

    How did I get around this limitation? I turned off "Turn new lines into <br>" in the prefs, and edited the post in HTML mode (I didn't ever click on the Composer or Preview tab). Does this suck? Yes. A lot.

    Eventually I think I'll just freak out and take a screenshot of the code or something equally inane, and then I'll be able to turn the newline option back on, as having it off is quite irritating to me.

    d.

    --
    My motorbike travels in Chile.
  20. I second that by ben+there... · · Score: 1

    Check out how code highlighting looks in Drupal.

    PHP can be entered with <?php to start, other languages can be wrapped in <code> with codefilter. I haven't tried GeSHIFilter, but parent is right that it seems to add highlighting to the rest of the languages.

  21. WordPress + a plugin by Peter+Cooper · · Score: 1

    I've definitely seen a code highlight plugin for WordPress, but as I can't find it.. you could always write your own. WordPress is pretty ubiquitous now, writing plugins is simple, and it'd just be a call to a highlighting library for any code within tags.

    1. Re:WordPress + a plugin by SanityInAnarchy · · Score: 1

      Wordpress plugins are easy, but not incredibly powerful. The company I'm working for just recently jumped from b2evolution to Wordpress, and then to Drupal. It looks like we'll actually stick with Drupal.

      --
      Don't thank God, thank a doctor!
  22. Serendipity + geshi plugin by theripper · · Score: 1

    I would suggest serendipity for the blogging software itself with the geshi plugin that is available through it's plugin interface. Though I've never used the plugin I've heard it works well and I find the software (serendipity) to be highly configurable and just all around excellent.

  23. that sound! by Anonymous Coward · · Score: 0

    Was the sound of the joke that passed above your head mods...

    sheesh someone has to buy a sense of humor...

  24. Geshi indeed. by Poromenos1 · · Score: 1

    Geshi under drupal would be best, it handles highlighting VERY well and also does comments.

    --
    Send email from the afterlife! Write your e-will at Dead Man's Switch.
  25. I've tried two by Alternate+Interior · · Score: 1

    WordPress is brutal with HTML. It treats < as a tag delimiter, < as a tag delimiter. The numeric entity < (I think) is the only one it won't explode into a raw character. Blogger is much easier to do code in. < by itself is treated as HTML but < works. For what it's worth.

  26. Use separate syntax highlighting programs. by Ant+P. · · Score: 1

    If you really need the outputted HTML files inline on the page, you can just use a bit of regex to chop off the HTML header.

  27. Wordpress + VIM Syntax Plugin by dasunt · · Score: 1

    Wordpress has a plugin that uses some vim magic to syntax highlight code.

    It may be computationally expensive (I dunno), but there's always the wordpress caching plugin as well. ;)

  28. Emacs Muse by rpdillon · · Score: 2, Informative
    I just killed my Wordpress install over at Etherplex in favor of Emacs Muse. If you are an Emacs user already, Muse is a snap to use, and is a general document generator that can output to LaTeX, HTML, RDF, RSS and something called journal-html, which is designed specifically for blogs and is designed to be styled by a custom CSS. You can see the results over at my site.

    If you want to see the source file in emacs that generated that, check out the muse source for my site. Keep in mind that when using it in Emacs, the markup doesn't actually appear - it is converted to the proper fonts on-the-fly in Emacs.

    In this context, the use of htmlize is perfect for generating an HTML form of your code buffer from emacs. Whatever your color scheme, htmlize will pick up the colors and use them to generate the HTML. If you're not publishing an entire page, I suggest you set htmlize to use the "font" method for generating html that can be used without corresponding matching CSS. If you use Emacs color-theme package, the theme "BlippBlopp" produces good results for publishing on the web.

    The only thing this system lack that I care about is comments, but since no one reads my blog, its not that big of an issue. I installed SimpleMachine's SMF for blog comments and other forum needs. Vanilla may also be a good choice.

    Finally, it's worth mentioning that I can then edit my site from anywhere via Tramp mode in Emacs, which allows seamless file editting on remote servers over SSH. This way, I can edit my site from my laptop on the road, or my deskktop at home without worrying about having the code with me. Muse will then publish remotely as well (though there seems to be a bug with RSS generation and Tramp that I need to work out).

  29. Why should this be part of the blogging software? by curunir · · Score: 1

    Why not find blogging software that can handle user-entered HTML snippets and use something like colorer (one of a few out there) to generate HTML from code. If the blogging package also gave you the ability to add an iframe in your story, you could also point that at a web CVS/SVN repository viewer that has syntax coloring (most do) for the cases where you're posting the code of a source file rather than a snippet.

    This kind of solution is likely to be much cleaner and give you better results than looking for a blogging package that can handle code natively. Even if you were able to find such a package, it's unlikely it would be able to handle as many languanges as the packages that are dedicated to displaying code in an HTML format.

    --
    "Don't blame me, I voted for Kodos!"
  30. Test out several on opensourcecms.com by VGfort · · Score: 1

    opensourcecms.com They let you try out blogs also, not just CMSes

  31. Drupal + GeSHiFilter by kbahey · · Score: 1

    If you do not mind hosting your own solution, the look into installing Drupal and the GeSHiFilter module.

    You can also get a pre-hosted account at Bryght, but it is not free like other blogging services.

    Disclaimer: I am a contributor to the Drupal project.

  32. finger and .plan? by Lt.Hawkins · · Score: 1

    Worked great for John Carmack and Brian Hook!

    --
    -- My Sig is a P228.
  33. TWiki with plugins by Cato · · Score: 1

    TWiki (http://twiki.org/) has plugins that handle source code formatting (see http://twiki.org/cgi-bin/view/Plugins/SourceHighli ghtPlugin and http://twiki.org/cgi-bin/view/Plugins/SyntaxHighli ghtingPluginDev) and others provide blog features (http://twiki.org/cgi-bin/view/Plugins/BlogPlugin looks pretty good). (Some tweaking required for the syntax highlighting plugins to work with latest TWiki version).

    TWiki's generally great for intranet collaboration as it has good revision tracking, WYSIWYG editing (beta) and other nice features, as well as over 200 plugins including some that support action tracking, Extreme Programming support, etc.

  34. Re: Best Weblog Application for Posting Source... by Bhavesh · · Score: 1

    The best weblog I've seen so far is google's blogspot. Offers most if hosting with your own domain. It also helps to improve search engine ranking faster.

    --
    Bhavesh
    Source to top search engine ranking