01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
2009-09-30 Wed
■ ハンドラーのかき方 [javascript]
google-code-prettify での特定言語に対するハンドラーは、
function createMyDecorator(){ var decorate = function(job){ var sourceCode = job.source, basePos = job.basePos; var decorations = [basePos, PR.PR_PLAIN]; /** * decorations は * position と style の組の配列 * * position 番目以降は style を適用 * と解釈される * * style はCSSでのクラス名になる * */ job.decorations = decorations; }; return decorate; }; PR.registerLangHandler(createMyDecorator(), ['MyLangExt']);
こんな感じで書くようだ。