Skip to content

Commit

Permalink
Fix previous element selection.
Browse files Browse the repository at this point in the history
  • Loading branch information
VonC committed Nov 30, 2013
1 parent 8ad633e commit d52eb59
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions plugin/markdown/markdown.js
Original file line number Diff line number Diff line change
Expand Up @@ -303,16 +303,24 @@
*/
function addAttributes( section, element, previousElement, separatorElementAttributes, separatorSectionAttributes ) {

console.log("*** element='" + element.innerHTML + "', nodeType='" + element.nodeType + "'");
console.log("*** element='" + element.tagName + "', nodeType='" + element.nodeType + "'");
console.log("previousElement="+previousElement)
console.log("section=****"+section.outerHTML+"****");
//console.log("section=****"+section.outerHTML+"****");
if ( element != null && element.childNodes != undefined && element.childNodes.length > 0 ) {
previousParentElement = element;
for( var i = 0; i < element.childNodes.length; i++ ) {
childElement = element.childNodes[i];
console.log(" Child element='" + childElement.innerHTML + "', type " + childElement.nodeType);
if ( i > 0 && typeof element.childNodes[i-1].setAttribute == 'function' ) {
previousParentElement = element.childNodes[i-1];
console.log(" Child element='" + childElement.tagName + "', type " + childElement.nodeType);
if ( i > 0 ) {
j = i - 1;
while ( j >= 0 ) {
aPreviousChildElement = element.childNodes[j];
if ( typeof aPreviousChildElement.setAttribute == 'function' && aPreviousChildElement.tagName != "BR") {
previousParentElement = aPreviousChildElement;
break;
}
j = j - 1;
}
}
parentSection = section;
if( childElement.nodeName == "section" ) {
Expand Down

0 comments on commit d52eb59

Please sign in to comment.