A Javascript Code "Prettifier"

I came across a link today that would allow you to post "pretty" code in any HTML page. I've had plenty of problems (as have others) posting well-formatted source code to my Blogger-based blog. I've wanted to correct this problem for some time, and this project appears to be a decent solution. Here's an example:

function chooseWinner() {
participantBo.chooseWinnerForEvent(eventId, function(data) {
people = $A(data);
intervalId = setInterval(doShift, 500);

Now that isn't too bad is it? There seems to be a bit of a delay as the Javascript is loaded, but I think that's more a symptom of my connection than it is a problem with the script.

Here's how you can take advantage of this solution (quoted from http://google-code-prettify.googlecode.com/svn/trunk/README.html):

  1. Download a distribution
  2. Include the script and stylesheets in your document
    (you will need to make sure the css and js file are on your server, and
    adjust the paths in the script and link tag)
    <link href="prettify.css" type="text/css" rel="stylesheet" />
    <script type="text/javascript" src="prettify.js"></script>

  3. Add onload="prettyPrint()" to your
    document's body tag.
  4. Modify the stylesheet to get the coloring you prefer

  5. Put code snippets in
    <pre class="prettyprint">...</pre>
    or <code class="prettyprint">...</code>
    and it will automatically be pretty printed.


Shane said...

I found this blog entry that generates formatted code:

katty said...

JavaScript is a good program and very easy to use. I don´t like a complex program. I prefer javascript because i consider it like a device very eficient and it have a good quality.
I always looking for the quality that is why i prefer to buy viagra because i always have a great result in my sexual life.

brinkka said...

Erectile Dysfunction FAQ's

Impotence, or penile erectile dysfunction, in men is not as rare as one would think it is.
In fact, one out of ten men around the world is affected by this condition. It is not exclusive to old men either. Impotence is caused not just by physical factors,
but mental factors as well.
Exercising on a regular basis and eating healthy food will increase your ability to sustain prolonged physical effort and we all know that sex is effort.
Smoking, frequently drinking large quantities of alcohol, taking recreational drugs and lack of exercising will sap your stamina and also slow down the flow of blood.
Penis exercises can be used for maintaining fitness, preventing or controlling premature ejaculation and increasing the length and girth of the penis.
by penis enlargement pills you can overcome these problems and not only that you can also enlarge, extend also to strengthen your penis and premature ejaculation will not exist anymore for you.
visit http://www.factspenisenlargement.com for more info.