From cc1afb2ad3ba4ec555c03358af24f8b68ce15d75 Mon Sep 17 00:00:00 2001 From: Gabriel Wicke Date: Thu, 21 Jun 2012 18:35:01 +0200 Subject: [PATCH] Support dt/dd transitions in the middle of the stack Change-Id: I1d75caa7782d02a2c33413a078e99b17ccc4141c --- modules/parser/ext.core.ListHandler.js | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/modules/parser/ext.core.ListHandler.js b/modules/parser/ext.core.ListHandler.js index 5e2b502c2c..bb5e90c649 100644 --- a/modules/parser/ext.core.ListHandler.js +++ b/modules/parser/ext.core.ListHandler.js @@ -100,7 +100,7 @@ ListHandler.prototype.popTags = function ( n ) { return tokens; }; -ListHandler.prototype.isDlDd = function (a, b) { +ListHandler.prototype.isDtDd = function (a, b) { var ab = [a,b].sort(); return (ab[0] === ':' && ab[1] === ';'); }; @@ -130,17 +130,18 @@ ListHandler.prototype.doListItem = function ( bs, bn, token ) { ]; } else { var tokens = []; - if ( bs.length <= bn.length && - bs.length - prefixLen === 1 && - this.isDlDd( bs[prefixLen], bn[prefixLen] ) ) + if ( bs.length > prefixLen && + bn.length > prefixLen && + this.isDtDd( bs[prefixLen], bn[prefixLen] ) ) { + tokens = this.popTags(bs.length - prefixLen - 1); // handle dd/dt transitions var newName = this.bulletCharsMap[bn[prefixLen]].item; var endTag = this.endtags.pop(); this.endtags.push(new EndTagTk( newName )); // TODO: review dataAttribs forwarding here and below in // doListItem, in particular re accuracy of tsr! - tokens = [ endTag, new TagTk( newName, [], token.dataAttribs ) ]; + tokens = tokens.concat([ endTag, new TagTk( newName, [], token.dataAttribs ) ]); prefixLen++; } else { tokens = tokens.concat( this.popTags(bs.length - prefixLen) );