1
0
Fork 0
forked from 0x2620/oxjs

add method source to parent source; strip leading and trailing newlines

This commit is contained in:
rolux 2011-05-06 20:01:34 +02:00
commit 72d3ec87c2
2 changed files with 28 additions and 14 deletions

View file

@ -86,8 +86,8 @@ Ox.DocPage = function(options, self) {
.css({marginLeft: ((level * 32 + 32) + 'px')})
.html(
'<code><b>&gt;</b>&nbsp;' +
//Ox.encodeHTML(example.statement)
example.statement
Ox.encodeHTML(example.statement)
//example.statement
.replace(/ /g, '&nbsp;')
.replace(/\n/g, '<br/>\n&nbsp;&nbsp;') +
'</code>'
@ -103,18 +103,12 @@ Ox.DocPage = function(options, self) {
});
} else if (section == 'source') {
var html = '';
var flag = false;
item.source.forEach(function(token) {
if (token.type != 'linebreak' && token.type != 'whitespace') {
flag = true;
}
if (flag) {
html += '<span class="Ox' + Ox.toTitleCase(token.type) + '">' +
Ox.encodeHTML(token.source)
.replace(/ /g, '&nbsp;')
.replace(/\n/g, '<br/>') +
'</span>';
}
html += '<span class="Ox' + Ox.toTitleCase(token.type) + '">' +
Ox.encodeHTML(token.source)
.replace(/ /g, '&nbsp;')
.replace(/\n/g, '<br/>') +
'</span>';
});
$elements.push($('<div>')
.addClass('OxSourceCode ' + className)