diff options
author | Felix Geisendörfer <felix@debuggable.com> | 2009-09-23 00:46:56 +0200 |
---|---|---|
committer | Ryan Dahl <ry@tinyclouds.org> | 2009-09-23 11:25:31 +0200 |
commit | be3dddeec9c970f5cc81b672a4cf034d917d450c (patch) | |
tree | b66c96a78dd48990f991592110a26b15bf922adb | |
parent | 76f4962636e434b91c9dea5de58d244f81db78ba (diff) | |
download | node-new-be3dddeec9c970f5cc81b672a4cf034d917d450c.tar.gz |
Syntax highlighting for api.html.
Asciidoc does not seem to support including custom JS, so this patch is a hack
for toc.js to dynamically include the needed CSS / JS. It should be ok unless
somebody has a better approach ...
-rw-r--r-- | doc/toc.js | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/doc/toc.js b/doc/toc.js index be6dabaed6..5f14bb56dd 100644 --- a/doc/toc.js +++ b/doc/toc.js @@ -67,3 +67,34 @@ function generateToc(toclevels) { if (entries.length == 0) document.getElementById("header").removeChild(toc); } + +(function() { + var includes = ['sh_main.js', 'sh_javascript.min.js', 'sh_vim-dark.css']; + var head = document.getElementsByTagName("head")[0]; + + for (var i = 0; i < includes.length; i ++) { + var ext = includes[i].match(/\.([^.]+)$/); + switch (ext[1]) { + case 'js': + var element = document.createElement('script'); + element.type = 'text/javascript'; + element.src = includes[i]; + break; + case 'css': + var element = document.createElement('link'); + element.type = 'text/css'; + element.rel = 'stylesheet'; + element.media = 'screen'; + element.href = includes[i]; + break; + } + + head.appendChild(element); + } + var i = setInterval(function () { + if (window["sh_highlightDocument"]) { + sh_highlightDocument(); + clearInterval(i); + } + }, 100); +})(); |