Skip to content

Commit

Permalink
Working towards test suite domination. Then I'll rearchitect the gram…
Browse files Browse the repository at this point in the history
…mar.
  • Loading branch information
cgiffard committed Aug 23, 2012
1 parent 3b90f52 commit 9d60a6d
Show file tree
Hide file tree
Showing 4 changed files with 121 additions and 15 deletions.
62 changes: 56 additions & 6 deletions compiled/duckdown-unminified.js
Expand Up @@ -3,7 +3,7 @@
// Christopher Giffard 2012
//
//
// Package built Thu Aug 23 2012 11:58:16 GMT+1000 (EST)
// Package built Thu Aug 23 2012 13:53:50 GMT+1000 (EST)
//


Expand Down Expand Up @@ -523,14 +523,44 @@ function require(input) {

if (node.rootBlock &&
node.rootBlock.previousSibling &&
node.rootBlock.previousSibling.blockType === node.state &&
node.rootBlock.previousSibling.blockNode &&
(
node.rootBlock.previousSibling.semanticLevel === "hybrid" ||
node.rootBlock.previousSibling.semanticLevel === "textblock" ||
node.rootBlock.previousSibling.semanticLevel === "block"
) &&
node.rootBlock.previousSibling.blockNode.indentation < node.indentation) {

var parentList = node.rootBlock.previousSibling.blockNode;

while ( parentList.children.length &&
typeof parentList.children[parentList.children.length-1] === "object" &&
(
parentList.children[parentList.children.length-1].semanticLevel === "hybrid" ||
parentList.children[parentList.children.length-1].semanticLevel === "textblock" ||
parentList.children[parentList.children.length-1].semanticLevel === "block"
)) {

if (parentList.children[parentList.children.length-1].indentation !== null &&
parentList.children[parentList.children.length-1].indentation >= node.indentation) break;

parentList = parentList.children[parentList.children.length-1];
}

// Add this node as a child of the last node.
node.rootBlock.previousSibling.blockNode.children.push(node);
parentList.children.push(node);
parentList.blockParent = true;
node.rootBlock.remove();
node.breakBefore = true;

// Correct indices
parentList.updateIndices();

if (parentList.children[node.index-1] &&
(typeof parentList.children[node.index-1] !== "object" ||
parentList.children[node.index-1].state !== node.state )) {

node.breakBefore = true;
}
}
},
"compile": function(node,compiler) {
Expand Down Expand Up @@ -603,14 +633,34 @@ function require(input) {

if (node.rootBlock &&
node.rootBlock.previousSibling &&
node.rootBlock.previousSibling.blockType === node.state &&
node.rootBlock.previousSibling.blockNode &&
(
node.rootBlock.previousSibling.semanticLevel === "hybrid" ||
node.rootBlock.previousSibling.semanticLevel === "textblock" ||
node.rootBlock.previousSibling.semanticLevel === "block"
) &&
node.rootBlock.previousSibling.blockNode.indentation < node.indentation) {

var parentList = node.rootBlock.previousSibling.blockNode;

while ( parentList.children.length &&
typeof parentList.children[parentList.children.length-1] === "object" &&
(
parentList.children[parentList.children.length-1].semanticLevel === "hybrid" ||
parentList.children[parentList.children.length-1].semanticLevel === "textblock" ||
parentList.children[parentList.children.length-1].semanticLevel === "block"
)) {


if (parentList.children[parentList.children.length-1].indentation !== null &&
parentList.children[parentList.children.length-1].indentation >= node.indentation) break;

parentList = parentList.children[parentList.children.length-1];
}

// Add this node as a child of the last node.
parentList.children.push(node);
parentList.blockParent = true;
node.rootBlock.remove();

// Correct indices
Expand Down Expand Up @@ -657,7 +707,7 @@ function require(input) {
buffer += "<ol" + listType + ">\n";
}

buffer += "<li>" + compiler(node) + "</li>\n";
buffer += "<li>" + compiler(node) + (node.blockParent ? "\n" : "") + "</li>\n";

if (!node.parent.nextSibling ||
node.parent.nextSiblingCulled ||
Expand Down

0 comments on commit 9d60a6d

Please sign in to comment.