Fix for Bug 37913

* Strips the first paragraph tag in a list item or table cell context
  if there are no attributes on it and stx:html is not set

Change-Id: I74988645fe505c662f86488e32d0f11d464ffe41
This commit is contained in:
Subramanya Sastry 2012-06-29 23:47:59 -05:00
parent 604aae2f3f
commit 166e7a75c9

View file

@ -228,13 +228,14 @@ var id = function(v) {
};
};
WSP._listHandler = function( handler, bullet, state, token ) {
function isListItem(token) {
if (token.constructor !== TagTk) return false;
function isListItem(token) {
if (token.constructor !== TagTk) return false;
var tokenName = token.name;
return (tokenName === 'li' || tokenName === 'dt' || tokenName === 'dd');
}
var tokenName = token.name;
return (tokenName === 'li' || tokenName === 'dt' || tokenName === 'dd');
}
WSP._listHandler = function( handler, bullet, state, token ) {
if ( state.singleLineMode ) {
state.singleLineMode--;
}
@ -634,11 +635,24 @@ WSP.tagHandlers = {
handle: WSP._serializeTableTag.bind(null, "|+", ' |')
}
},
p: {
p: {
make: function(state, token) {
// "stx": "html" tags never get here
// Special case handling in a list context
// VE embeds list content in paragraph tags
return state.singleLineMode ? WSP.defaultHTMLTagHandler : this;
// VE embeds list content in paragraph tags.
//
// SSS FIXME: This will *NOT* work if the list item has nested paragraph tags!
var prevToken = state.prevToken;
if ( token.attribs.length === 0
&& ( (state.listStack.length > 0 && isListItem(prevToken))
|| (prevToken.constructor === TagTk && prevToken.name === 'td')
|| (state.ignorePTag && token.constructor === EndTagTk)))
{
state.ignorePTag = !state.ignorePTag;
return { start: { ignore: true }, end: { ignore: true } };
} else {
return state.singleLineMode ? WSP.defaultHTMLTagHandler : this;
}
},
start: {
startsNewline : true,