Skip to content

Commit a1e901d

Browse files
committed
Added syntax highlighting for code snippets in the documentation.
This is using Prettify highlighter: http://code.google.com/p/google-code-prettify/ Added "threejs.css" for doing custom styling (if somebody would like to do this). See for example here: http://google-code-prettify.googlecode.com/svn/trunk/styles/index.html http://code.google.com/p/google-code-prettify/source/browse/trunk/styles/sunburst.css
1 parent 265b351 commit a1e901d

File tree

6 files changed

+65
-1
lines changed

6 files changed

+65
-1
lines changed

docs/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@
127127
goTo( window.location.hash.substring( 1 ) );
128128

129129
}
130-
130+
131131
window.addEventListener( 'hashchange', goToHash, false );
132132

133133
if ( window.location.hash.length > 0 ) goToHash();

docs/page.js

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,38 @@ var onDocumentLoad = function ( event ) {
2929

3030
document.body.appendChild( button );
3131

32+
// Syntax highlighting
33+
34+
var styleBase = document.createElement( 'link' );
35+
styleBase.href = '../../prettify/prettify.css';
36+
styleBase.rel = 'stylesheet';
37+
38+
var styleCustom = document.createElement( 'link' );
39+
styleCustom.href = '../../prettify/threejs.css';
40+
styleCustom.rel = 'stylesheet';
41+
42+
document.head.appendChild( styleBase );
43+
document.head.appendChild( styleCustom );
44+
45+
var prettify = document.createElement( 'script' );
46+
prettify.src = '../../prettify/prettify.js';
47+
48+
prettify.onload = function () {
49+
50+
var elements = document.getElementsByTagName( 'code' );
51+
52+
for ( var i = 0; i < elements.length; i ++ ) {
53+
54+
var e = elements[ i ];
55+
e.className += ' prettyprint';
56+
57+
}
58+
59+
prettyPrint();
60+
61+
}
62+
63+
document.head.appendChild( prettify );
3264

3365
};
3466

docs/prettify/prettify.css

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/prettify/prettify.js

Lines changed: 28 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/prettify/readme.txt

Whitespace-only changes.

docs/prettify/threejs.css

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
pre.prettyprint, code.prettyprint {
2+
background-color: #f9f9f9;
3+
}

0 commit comments

Comments
 (0)