Sha256: 309a1068ee9ec59d666264830e2ad6fc260168ea057dce945f8bfccaffc57110
Contents?: true
Size: 1.33 KB
Versions: 43
Compression:
Stored size: 1.33 KB
Contents
JSDOC.PluginManager.registerPlugin( "JSDOC.publishSrcHilite", { onPublishSrc: function(src) { if (src.path in JsHilite.cache) { return; // already generated src code } else JsHilite.cache[src.path] = true; try { var sourceCode = IO.readFile(src.path); } catch(e) { print(e.message); quit(); } var hiliter = new JsHilite(sourceCode, src.charset); src.hilited = hiliter.hilite(); } } ); function JsHilite(src, charset) { var tr = new JSDOC.TokenReader(); tr.keepComments = true; tr.keepDocs = true; tr.keepWhite = true; this.tokens = tr.tokenize(new JSDOC.TextStream(src)); // TODO is redefining toString() the best way? JSDOC.Token.prototype.toString = function() { return "<span class=\""+this.type+"\">"+this.data.replace(/</g, "<")+"</span>"; } if (!charset) charset = "utf-8"; this.header= IO.readFile(JSDOC.opt.t + "static/code-header.html"); this.footer= IO.readFile(JSDOC.opt.t + "static/code-footer.html"); this.showLinenumbers = true; } JsHilite.cache = {}; JsHilite.prototype.hilite = function() { var hilited = this.tokens.join(""); var line = 1; if (this.showLinenumbers) hilited = hilited.replace(/(^|\n)/g, function(m){return m+"<span class='line'>"+((line<10)? " ":"")+((line<100)? " ":"")+(line++)+"</span> "}); return this.header+hilited+this.footer; }
Version data entries
43 entries across 43 versions & 1 rubygems