Issue #212 - Further fix to set MixedContent in some cases.

In certain circumstances a leading space has to be preverved to allow it
to be used to create a text space node to insert before this element to
preserve the view in a browser.

And added a note asking why is ParseTag called with a hardcoded
IgnoreWhitespace when some effort above has set the mode variable to
MixedContent in certain cases, but need to think about this 2nd change.

Also added some MSVC Debug output when this leading text is used to insert
such a created text node before the element just to be reminded of this
special event.
This commit is contained in:
Geoff McLane 2015-06-04 13:11:54 +02:00
parent a278b04a19
commit 326f2414fd
1 changed files with 14 additions and 0 deletions

View File

@ -516,6 +516,10 @@ static void TrimInitialSpace( TidyDocImpl* doc, Node *element, Node *text )
node->end = element->start;
lexer->lexbuf[node->start] = ' ';
TY_(InsertNodeBeforeElement)(element ,node);
#if !defined(NDEBUG) && defined(_MSC_VER)
SPRTF("TrimInitialSpace: Created text node, inserted before <%s>\n",
(element->element ? element->element : "unknown"));
#endif
}
}
@ -906,6 +910,13 @@ void TY_(ParseBlock)( TidyDocImpl* doc, Node *element, GetTokenMode mode)
{
mode = IgnoreWhitespace;
}
else if (mode == IgnoreWhitespace)
{
/* Issue #212 - Further fix in case ParseBlock() is called with 'IgnoreWhitespace'
when such a leading space may need to be inserted before this element to
preverve the browser view */
mode = MixedContent;
}
while ((node = TY_(GetToken)(doc, mode /*MixedContent*/)) != NULL)
{
@ -1355,6 +1366,9 @@ void TY_(ParseBlock)( TidyDocImpl* doc, Node *element, GetTokenMode mode)
if (node->implicit)
TY_(ReportError)(doc, element, node, INSERTING_TAG );
/* Issue #212 - WHY is this hard coded to 'IgnoreWhitespace' while an
effort has been made above to set a 'MixedContent' mode in some cases?
WHY IS THE 'mode' VARIABLE NOT USED HERE???? */
ParseTag( doc, node, IgnoreWhitespace /*MixedContent*/ );
continue;
}