use new-style tokens
This commit is contained in:
parent
f98d997c4a
commit
2ea1283901
1 changed files with 7 additions and 6 deletions
|
@ -41,17 +41,18 @@ Ox.SourceViewer = function(options, self) {
|
||||||
Ox.get(self.options.file, function(source) {
|
Ox.get(self.options.file, function(source) {
|
||||||
var sections = [{comment: '', code: ''}];
|
var sections = [{comment: '', code: ''}];
|
||||||
Ox.tokenize(source).forEach(function(token, i) {
|
Ox.tokenize(source).forEach(function(token, i) {
|
||||||
var text = source.substr(token.offset, token.length),
|
var type = token.type == 'comment' ? 'comment' : 'code';
|
||||||
type = token.type == 'comment' ? 'comment' : 'code';
|
if (!/^\/\//.test(token.value)) {
|
||||||
if (!/^\/\//.test(text)) {
|
|
||||||
if (type == 'comment') {
|
if (type == 'comment') {
|
||||||
i && sections.push({comment: '', code: ''});
|
i && sections.push({comment: '', code: ''});
|
||||||
text = text.slice(2, -2);
|
token.value = token.value.slice(2, -2);
|
||||||
self.options.replaceComment.forEach(function(replace) {
|
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) {
|
sections.forEach(function(section) {
|
||||||
|
|
Loading…
Reference in a new issue