Saturday, February 19, 2011

Is there a good embeddable code widget for blogs

My co-founder is currently asking on our blog for an embeddable code widget.

http://devver.net/blog/2008/10/someone-please-build-an-awesome-embeddable-code-widget/

Basically we want something like http://pastie.org/ or http://codepad.org/ but we really want to embed the code section in our blog. We know there are plugins for common blogs and server side solutions, but it would be great to be able to just embed a little javascript and have nicely formatted code anywhere...

Does something like this exist? Have we just missed it?

From stackoverflow
  • I think you want a javascript syntax highlighter

    Sometimes you just keep thinking in the wrong keywords ;-)

    danmayer : Yeah we might end up with syntax highlighter, but we really want it an embeddable widget that is hosted elsewhere. Some people aren't hosting their own blogs and don't deal with managing / hosting / or upgrading the javascript includes required for the google syntax highlighter.
    Jauco : Hmmm, you could paste the javascript inside the html of the template. Otherwise a google pages account is cheap and easy. I don't really expect you need to manage/host it that much. It's just drop it on once and then use it.
  • Check out CodeRay and UltraViolet. They're both quite good and easy to use.

  • I think some of the answers to this question might be helpful for your question.

  • We had a user point out a WordPress plugin that uses Gist to do exactly what we were asking for...

    http://pomoti.com/gist-it-english

    Even if you don't use the plug in it looks like a feature of Gist lets you embed the code anywhere you want on the web. http://gist.github.com

    Looks pretty sweet. Thanks goes to Dirceu Jr.

  • I use a highlighter included in Dojo (adapted from Ivan Sagalaev's highlight.js). All you need to do is to include a few lines of code in the head of your web page (a script tag pointing to AOL or Google, a link to CSS hosted by AOL or Google, and a trivial script to request the highlight) and add <pre><code lang="javascript"> blocks with preformatted snippets — they will be found and highlighted automatically.

    Of course, multiple languages are supported as well as automatic guessing the language of your snippet. If user turned off JavaScript, it will degrade gracefully.

    Another good point of this solution: no need to host any files, no need to configure servers, no need to generate HTML dynamically, can be used with anything — even static file will be highlighted just fine.

    You can see examples in official tests: test_highlight.html, test_pygments.html. This is the example of snippets on my web site: the article with several highlighted code snippets — look in the head of this page to see how the highlighter can be included directly from AOL.

0 comments:

Post a Comment