use new-style tokens

This commit is contained in:
rolux 2012-05-27 21:33:04 +02:00
parent f98d997c4a
commit 2ea1283901

View file

@ -41,17 +41,18 @@ Ox.SourceViewer = function(options, self) {
Ox.get(self.options.file, function(source) {
var sections = [{comment: '', code: ''}];
Ox.tokenize(source).forEach(function(token, i) {
var text = source.substr(token.offset, token.length),
type = token.type == 'comment' ? 'comment' : 'code';
if (!/^\/\//.test(text)) {
var type = token.type == 'comment' ? 'comment' : 'code';
if (!/^\/\//.test(token.value)) {
if (type == 'comment') {
i && sections.push({comment: '', code: ''});
text = text.slice(2, -2);
token.value = token.value.slice(2, -2);
self.options.replaceComment.forEach(function(replace) {
text = text.replace(replace[0], replace[1]);
token.value = token.value.replace(
replace[0], replace[1]
);
});
}
Ox.last(sections)[type] += text;
Ox.last(sections)[type] += token.value;
}
});
sections.forEach(function(section) {