diff --git a/source/Ox.UI/js/Core/Ox.DocPage.js b/source/Ox.UI/js/Core/Ox.DocPage.js index a16183ff..5bbe6012 100644 --- a/source/Ox.UI/js/Core/Ox.DocPage.js +++ b/source/Ox.UI/js/Core/Ox.DocPage.js @@ -86,8 +86,8 @@ Ox.DocPage = function(options, self) { .css({marginLeft: ((level * 32 + 32) + 'px')}) .html( '> ' + - //Ox.encodeHTML(example.statement) - example.statement + Ox.encodeHTML(example.statement) + //example.statement .replace(/ /g, ' ') .replace(/\n/g, '
\n  ') + '
' @@ -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 += '' + - Ox.encodeHTML(token.source) - .replace(/ /g, ' ') - .replace(/\n/g, '
') + - '
'; - } + html += '' + + Ox.encodeHTML(token.source) + .replace(/ /g, ' ') + .replace(/\n/g, '
') + + '
'; }); $elements.push($('
') .addClass('OxSourceCode ' + className) diff --git a/source/Ox.js b/source/Ox.js index 6d90db1c..9193c269 100644 --- a/source/Ox.js +++ b/source/Ox.js @@ -200,13 +200,33 @@ Ox.doc = (function() { .replace(re.test, encodeLinebreaks) .split('\n'); // create a tree and parse its root node - item = Ox.extend(parseNode(parseTree(lines)), {source: tokens[i]}); + item = parseNode(parseTree(lines)); + + ///* + item.source = []; + var tokenBuffer = [], tokenFlag = false; + tokens[i].forEach(function(token) { + if (['linebreak', 'whitespace'].indexOf(token.type) > -1) { + tokenBuffer.push(token); + } else { + if (!tokenFlag) { + item.source.push(token); + tokenFlag = true; + } else { + item.source = Ox.merge(item.source, tokenBuffer, [token]); + } + tokenBuffer = []; + } + }); + //*/ + if (/^[A-Z]/.test(item.name)) { items.push(item); } else { lastItem = items[items.length - 1]; lastItem.properties = lastItem.properties || []; lastItem.properties.push(item); + lastItem.source = Ox.merge(lastItem.source, item.source); } }); function decodeLinebreaks(match, submatch) {