Permalink
Browse files

.

  • Loading branch information...
1 parent 25093d6 commit 46de4f774df5d4d2c401cc29bfb158074cd0fc3d @mnewt committed Aug 8, 2012
Showing with 82 additions and 71 deletions.
  1. +9 −4 README.md
  2. +58 −0 demo.html
  3. +8 −53 reference.html
  4. +7 −14 styleCode.js
View
@@ -11,20 +11,25 @@ The end of your html template should look like this:
```html
<!-- ======================= Begin Prettify ============================-->
- <link rel="stylesheet" href="google-code-prettify/src/prettify.css">
- <script src="google-code-prettify-min/prettify.js" type="text/javascript"></script>
- <script src="styleCode.js" type="text/javascript"></script>
+ <link rel="stylesheet"
+ href="https://raw.github.com/mnewt/prettify-wrapper/master/google-code-prettify/src/prettify.css">
+ <script
+ src="https://raw.github.com/mnewt/prettify-wrapper/master/google-code-prettify/src/prettify.js"
+ type="text/javascript"></script>
+ <script src="https://raw.github.com/mnewt/prettify-wrapper/master/styleCode.js"
+ type="text/javascript"></script>
<!-- ======================== End Prettify =============================-->
</body>
</html>
```
**TWO**: (optional): customize the theme by pointing the first line to a different CSS file, such as this one:
+https://raw.github.com/mnewt/prettify-wrapper/master/tomorrow-night-mnewt.css
# Themes
There are a few themes included in the package itself:
http://google-code-prettify.googlecode.com/svn/trunk/styles/index.html
-(https://github.com/jmblog)[jmblog] maintains some nice themes:
+[jmblog](https://github.com/jmblog) maintains some nice themes:
http://jmblog.github.com/color-themes-for-google-code-prettify/
View
@@ -0,0 +1,58 @@
+<!DOCTYPE html>
+<html>
+<body>
+
+<h1>There is some code below for demonstration purposes:</h1>
+
+<pre>
+<code>
+function addClass( classname, element ) {
+ var cn = element.className;
+ //test for existance
+ if( cn == "undefined" ) {
+ return;
+ }
+ //add a space if the element already has class
+ if( cn != '' ) {
+ classname = ' ' + classname;
+ }
+ element.className = cn + classname;
+}
+
+
+function styleCode()
+{
+ if (typeof disableStyleCode != "undefined")
+ {
+ return;
+ }
+ var a = false;
+ // iterate through all "pre" tags and add "prettyprint" class
+ var matches = document.body.getElementsByTagName("pre");
+ for (var i = 0; i < matches.length; ++i)
+ {
+ addClass("prettyprint", matches[i]);
+ a = true;
+ }
+ if (a) { prettyPrint() }
+}
+
+
+
+window.onload = function() { styleCode(); };
+
+</code>
+</pre>
+
+<!-- ======================= Begin Prettify ============================-->
+ <link href="http://raw.github.com/mnewt/prettify-wrapper/master/google-code-prettify-min/prettify.css"
+ type="text/css" rel="stylesheet"/>
+ <script
+ src="http://raw.github.com/mnewt/prettify-wrapper/master/google-code-prettify-min/prettify.js"
+ type="text/javascript"></script>
+ <script src="https://raw.github.com/mnewt/prettify-wrapper/master/styleCode.js"
+ type="text/javascript"></script>
+<!-- ======================== End Prettify =============================-->
+
+</body>
+</html>
View
@@ -1,54 +1,9 @@
-<!DOCTYPE html>
-<html>
-<body>
-
-<h1>There is some code below for demonstration purposes:</h1>
-
-<pre>
-<code>
-function addClass( classname, element ) {
- var cn = element.className;
- //test for existance
- if( cn == "undefined" ) {
- return;
- }
- //add a space if the element already has class
- if( cn != '' ) {
- classname = ' ' + classname;
- }
- element.className = cn + classname;
-}
-
-
-function styleCode()
-{
- if (typeof disableStyleCode != "undefined")
- {
- return;
- }
- var a = false;
- // iterate through all <pre> tags and add "prettyprint" class
- var matches = document.body.getElementsByTagName("pre");
- for (var i = 0; i < matches.length; ++i)
- {
- addClass("prettyprint", matches[i]);
- a = true;
- }
- if (a) { prettyPrint() }
-}
-
-
-
-window.onload = function() { styleCode(); };
-
-</code>
-</pre>
-
<!-- ======================= Begin Prettify ============================-->
- <link rel="stylesheet" href="google-code-prettify/src/prettify.css">
- <script src="google-code-prettify-min/prettify.js" type="text/javascript"></script>
- <script src="styleCode.js" type="text/javascript"></script>
-<!-- ======================== End Prettify =============================-->
-
-</body>
-</html>
+ <link rel="stylesheet"
+ href="https://raw.github.com/mnewt/prettify-wrapper/master/google-code-prettify/src/prettify.css">
+ <script
+ src="https://raw.github.com/mnewt/prettify-wrapper/master/google-code-prettify/src/prettify.js"
+ type="text/javascript"></script>
+ <script src="https://raw.github.com/mnewt/prettify-wrapper/master/styleCode.js"
+ type="text/javascript"></script>
+<!-- ======================== End Prettify =============================-->
View
@@ -1,16 +1,11 @@
-function addClass( classname, element ) {
- var cn = element.className;
- //test for existance
- if( cn == "undefined" ) {
- return;
- }
- //add a space if the element already has class
- if( cn != '' ) {
- classname = ' ' + classname;
- }
- element.className = cn + classname;
+function hasClass(el, name) {
+ return new RegExp('(\\s|^)'+name+'(\\s|$)').test(el.className);
}
+function addClass(el, name)
+{
+ if (!hasClass(el, name)) { el.className += (el.className ? ' ' : '') +name; }
+}
function styleCode()
{
@@ -19,7 +14,6 @@ function styleCode()
return;
}
var a = false;
- // iterate through all <pre> tags and add "prettyprint" class
var matches = document.body.getElementsByTagName("pre");
for (var i = 0; i < matches.length; ++i)
{
@@ -30,5 +24,4 @@ function styleCode()
}
-
-window.onload = function() { styleCode(); };
+window.onload = function() { styleCode(); };

0 comments on commit 46de4f7

Please sign in to comment.