Is there a Content Delivery Network (CDN) that hosts Google Code Prettify?
Asked Answered
D

5

61

Is there a content delivery network (CDN) that is hosting google-code-prettify?

I am putting together a blog on TypePad and would like to take advantage of a CDN if possible.

Doublestop answered 19/2, 2010 at 5:20 Comment(4)
+ 1 Google doesn't seem to host prettify for some reason, odd: code.google.com/apis/ajaxlibs/documentation/#jqueryWilbur
@Wilbur I've made a suggestion that it be added: code.google.com/p/google-ajax-apis/issues/detail?id=393. Based on the lack of answers here I am guessing it's going to be a wait until Google adds it.Doublestop
I wish they would, because: meta.stackexchange.com/questions/96519/…Sulfonmethane
We should all "heavily lobby Google to host this" as Jeff says. Click the star icon next to Issue 393 on the link @Doublestop provided: code.google.com/p/google-ajax-apis/issues/detail?id=393Millhon
E
4

There is a CDN for prettify:

https://cdn.jsdelivr.net/gh/google/code-prettify@master/loader/run_prettify.js

Its use is explained on the official code-prettify repository. You can use it with a skin, like this:

<script src="https://cdn.jsdelivr.net/gh/google/code-prettify@master/loader/run_prettify.js?skin=desert"></script>

That way you don't have to worry about additional CSS files. For more details and a full list of URL configurations, check the Getting Started section.


As mentioned by Jan Šotola, the previous RawGit CDN was shut down.
Read more details on migrating away from deprecated RawGit.

Eupatrid answered 27/9, 2016 at 0:47 Comment(1)
RawGit CDN is shutting down. It is recommended to use jsDelivr CDN instead. groups.google.com/forum/#!topic/js-code-prettifier/IFHev_kLm30Swayne
S
34

Found it!

http://www.cdnjs.com/libraries/prettify

<script src="http://cdnjs.cloudflare.com/ajax/libs/prettify/r298/run_prettify.js" type="text/javascript"></script>
<link href="http://cdnjs.cloudflare.com/ajax/libs/prettify/r298/prettify.css" type="text/css">

Update: https://github.com/cdnjs/cdnjs/issues/695 (see bottom of page)

Stacistacia answered 19/2, 2010 at 5:20 Comment(5)
Yes, but where is the .css file?Frontier
Not all the language files are listed comparing to the files hosted on Google Code. Is it just not showing? What happens when the requested language is not there on CloudeFare?Pewit
+1 I would have chosen @Peter Dietz answer for its simplicity. But your's works too jsfiddle.net/9LY48/3 fwiw its a little hard to tell it was working until I added lang-css to the classname... Helps to read the docs I guess.Armillas
For rev 298 : r298/prettify.js did not work for me, r298/run_prettify.js did work.Haemato
The problem with this is that you cannot use URL configurations, like skin. Visit the code-prettify repo to get the latest CDN url.Eupatrid
I
4

I believe you could use it directly from Google Code though.. ? embeding
http://google-code-prettify.googlecode.com/svn/trunk/src/prettify.js

Infanta answered 27/5, 2011 at 22:32 Comment(3)
This is not a good way though - it could change without notice.Cheston
Also it is served as is instead of gziped which a normal CDN should does.Tasman
Here's the CSS: google-code-prettify.googlecode.com/svn/trunk/src/prettify.cssKaffiyeh
P
4

You can use Google Code Prettify directly.

Read their Google Code Prettify Readme or wiki, and they tell you how to use them as the hosting provider.

<script
 src="https://google-code-prettify.googlecode.com/svn/loader/run_prettify.js"
 type="text/javascript"></script>

Then to use the prettyprint powers of Google Code Prettify, add class="prettyprint" to your code blocks, which should be in a pre or a code. Examples below:

<pre class="prettyprint">...</pre>

or

<code class="prettyprint">...</code>
Pigfish answered 28/2, 2013 at 18:0 Comment(1)
It does work, but slows down my site because (1) does not always responds within a second and (2) most important, the Expire header is not correctly set in the future, so browser cache cannot do his jobHaemato
E
4

There is a CDN for prettify:

https://cdn.jsdelivr.net/gh/google/code-prettify@master/loader/run_prettify.js

Its use is explained on the official code-prettify repository. You can use it with a skin, like this:

<script src="https://cdn.jsdelivr.net/gh/google/code-prettify@master/loader/run_prettify.js?skin=desert"></script>

That way you don't have to worry about additional CSS files. For more details and a full list of URL configurations, check the Getting Started section.


As mentioned by Jan Šotola, the previous RawGit CDN was shut down.
Read more details on migrating away from deprecated RawGit.

Eupatrid answered 27/9, 2016 at 0:47 Comment(1)
RawGit CDN is shutting down. It is recommended to use jsDelivr CDN instead. groups.google.com/forum/#!topic/js-code-prettifier/IFHev_kLm30Swayne
A
-2

You could create an account on Dropbox and put all the JavaScript and CSS files in the public folder. This worked for me!

Aberration answered 28/6, 2011 at 19:34 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.