From be3dddeec9c970f5cc81b672a4cf034d917d450c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Felix=20Geisend=C3=B6rfer?= Date: Wed, 23 Sep 2009 00:46:56 +0200 Subject: [PATCH] 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 ... --- doc/toc.js | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) 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); +})();