Question

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?

Was it helpful?

Solution 2

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.

OTHER TIPS

I think you want a javascript syntax highlighter

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

Check out CodeRay and UltraViolet. They're both quite good and easy to use.

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top