// <script type="text/javascript">
+TokenReader = imports.TokenReader.TokenReader;
+ScopeParser= imports.ScopeParser.ScopeParser;
+Collapse = imports.Collapse.Collapse;
+TextStream = imports.TextStream.TextStream;
+
-toPretty = function toPretty(str)
+function escapeHTML(str) {
+ return str.replace(/&/g,'&').
+ replace(/>/g,'>').
+ replace(/</g,'<').
+ replace(/"/g,'"');
+};
+
+function toPretty(str)
{
- var tr = new JSDOC.TokenReader();
- var toks = tr.tokenize(str,false); // dont merge xxx + . + yyyy etc.
- var sp = new JSDOC.ScopeParser(new JSDOC.TokenStream(toks));
- sp.buildSymbolTree();
+
+ var txs = new TextStream(str);
+ var tr = new TokenReader({ keepComments : true, keepWhite : true });
+ var toks = tr.tokenize(txs)
+
+ //var sp = new ScopeParser(new Collapse(toks));
+ //sp.buildSymbolTree();
+
+
// sp.mungeSymboltree();
var r = '';
- r += sp.warnings.join("<BR>");
- r == "<BR>";
+ //r += sp.warnings.join("<BR>");
+ //r == "<BR>";
function toStyle(tok)
{
- if (tok.isType("whitespace")) {
+ if (tok.is("WHIT") || tok.is("COMM") ) {
if (tok.data.indexOf("/") > -1) {
return 'comment';
}
return cs; // keep the same..
}
- if (tok.isType('string')) {
+ if (tok.is('STRN')) {
return 'string';
}
// other 'vary things??
- if (tok.isType('identifier') || tok.isType('dot') || tok.isType('this')) {
+ if (tok.is('NAME') || tok.data == '.' || tok.name == 'THIS') {
return 'var';
}
if (/^[a-z]+/i.test(tok.data)) {
return 'keyword';
}
return 'syntax'
-
}
// loop through and print it...?
if (toks[i].identifier) {
r += '<span class="with-ident2">' +
- htmlescape(toks[i].data) + '</span>';
+ escapeHTML(toks[i].data) + '</span>';
continue;
}
- r += htmlescape(toks[i].data).replace(/\n/g, '<BR>');
+ r += escapeHTML(toks[i].data).replace(/\n/g, "<BR/>\n");
}
if (cs.length) r +='</span>';
+
return '<code class="jsdoc-pretty">'+r+'</code>';