diff -ur -x tidy.exe -x tidy.suo -x *.obj -x *.ncb -x *.sln -x *.vcproj -x *.pdb -x *.idb -x *.ilk -x *.pch -x *.lib -x BuildLog.htm -x upd.bat -x update.mak -x Debug -x DebugDLL -x Release -x ReleaseDLL -x CVS -x diff tidycvs\include\platform.h tidydev2\include\platform.h --- tidycvs\include\platform.h Wed Jun 15 14:45:39 2005 +++ tidydev2\include\platform.h Tue Feb 07 14:08:30 2006 @@ -50,6 +50,14 @@ /* #define SUPPORT_GETPWNAM */ +/* ===================================================== + Define ADD_INLINE_FIX2 to provide a fix for the + following html + bold bold and italics italics only + Tidy will then convert this to + bold bold and italics italics only + ====================================================== */ +#define ADD_INLINE_FIX2 /* Enable/disable support for Big5 and Shift_JIS character encodings */ #ifndef SUPPORT_ASIAN_ENCODINGS diff -ur -x tidy.exe -x tidy.suo -x *.obj -x *.ncb -x *.sln -x *.vcproj -x *.pdb -x *.idb -x *.ilk -x *.pch -x *.lib -x BuildLog.htm -x upd.bat -x update.mak -x Debug -x DebugDLL -x Release -x ReleaseDLL -x CVS -x diff tidycvs\src\istack.c tidydev2\src\istack.c --- tidycvs\src\istack.c Mon Dec 06 13:53:25 2004 +++ tidydev2\src\istack.c Tue Feb 07 14:08:30 2006 @@ -268,6 +268,84 @@ return node; } +#ifdef ADD_INLINE_FIX2 +/* Bool SwitchInline( TidyDocImpl * doc, Node * element, Node * node ) + We have two CM_INLINE elements pushed ... the first is closing, + but, like the browser, the second should be retained ... + Like bold bold and italics italics only + This function switches the tag positions on the stack, + returning 'yes' if both were found in the expected order. +*/ +Bool SwitchInline( TidyDocImpl * doc, Node * element, Node * node ) +{ + Lexer* lexer = doc->lexer; + if ( lexer + && element + && node + && (element->tag != NULL) + && (node->tag != NULL) + && IsPushed( doc, element ) + && IsPushed( doc, node ) + && ((lexer->istacksize - lexer->istackbase) >= 2) ) + { + /* we have a chance of succeeding ... */ + int i; + for (i = (lexer->istacksize - lexer->istackbase - 1); i >= 0; --i) + { + if (lexer->istack[i].tag == element->tag) { + /* found the element tag - phew */ + IStack * istack1 = &lexer->istack[i]; + IStack * istack2 = 0; + --i; /* back one more, and continue */ + for ( ; i >= 0; --i) + { + if (lexer->istack[i].tag == node->tag) + { + /* found the element tag - phew */ + istack2 = &lexer->istack[i]; + break; + } + } + if( istack2 ) + { + /* perform the SWAP ... */ + static IStack _tmp_istack; + IStack * istack3 = &_tmp_istack; /* establish a temp */ + *istack3 = *istack2; /* copy 2nd to temp */ + *istack2 = *istack1; /* copy 1st to 2nd */ + *istack1 = *istack3; /* copy temp to 1st */ + return yes; /* return success */ + } + } + } + } + return no; +} +/* Bool InlineDup1( TidyDocImpl* doc, Node* node, Node* element ) + We want to push a specific a specific element on the stack, + but it may not be the LAST element, which InlineDup() + would handle. return yes, if found and inserted ... */ +Bool InlineDup1( TidyDocImpl* doc, Node* node, Node* element ) +{ + Lexer* lexer = doc->lexer; + int n; + if ( element + && (element->tag != NULL) + && ((n = lexer->istacksize - lexer->istackbase) > 0) ) + { + int i; + for ( i = n - 1; i >=0; --i ) { + if (lexer->istack[i].tag == element->tag) { + /* found our element tag - insert it */ + lexer->insert = &(lexer->istack[i]); + lexer->inode = node; + return yes; /* return success */ + } + } + } + return no; +} +#endif /* #ifdef ADD_INLINE_FIX2 */ diff -ur -x tidy.exe -x tidy.suo -x *.obj -x *.ncb -x *.sln -x *.vcproj -x *.pdb -x *.idb -x *.ilk -x *.pch -x *.lib -x BuildLog.htm -x upd.bat -x update.mak -x Debug -x DebugDLL -x Release -x ReleaseDLL -x CVS -x diff tidycvs\src\lexer.h tidydev2\src\lexer.h --- tidycvs\src\lexer.h Fri Jan 27 12:35:41 2006 +++ tidydev2\src\lexer.h Tue Feb 07 14:08:30 2006 @@ -621,6 +621,28 @@ void DeferDup( TidyDocImpl* doc ); Node *InsertedToken( TidyDocImpl* doc ); + +#ifdef ADD_INLINE_FIX2 +/* + We have two CM_INLINE elements pushed ... the first is closing, + but, like the browser, the second should be retained ... + Like bold bold and italics italics only + This function switches the tag positions on the stack, + returning 'yes' if both were found in the expected order. +*/ +Bool SwitchInline( TidyDocImpl * doc, Node * element, Node * node ); + +/* + We want to push a specific a specific element on the stack, + but it may not be the LAST element, which InlineDup() + would handle. +*/ +Bool InlineDup1( TidyDocImpl* doc, Node* node, Node* element ); + +#endif /* #ifdef ADD_INLINE_FIX2 */ + + + #ifdef __cplusplus } #endif diff -ur -x tidy.exe -x tidy.suo -x *.obj -x *.ncb -x *.sln -x *.vcproj -x *.pdb -x *.idb -x *.ilk -x *.pch -x *.lib -x BuildLog.htm -x upd.bat -x update.mak -x Debug -x DebugDLL -x Release -x ReleaseDLL -x CVS -x diff tidycvs\src\parser.c tidydev2\src\parser.c --- tidycvs\src\parser.c Sat Feb 04 14:02:21 2006 +++ tidydev2\src\parser.c Tue Feb 07 14:08:30 2006 @@ -1513,6 +1513,29 @@ && nodeHasCM(element, CM_INLINE) ) { /* allow any inline end tag to end current element */ +#ifdef ADD_INLINE_FIX2 + /* but, like the browser, retain an earlier inline element ... + This is implemented by setting the lexer into a mode + where it gets tokens from the inline stack rather than + from the input stream. check the scenerio fits ... */ + if( !nodeIsA(element) + && (node->tag != element->tag) + && IsPushed( doc, node ) + && IsPushed( doc, element ) ) + { + /* we have something like bold bold and italic italics */ + if( SwitchInline( doc, element, node ) ) + { + ReportError(doc, element, node, NON_MATCHING_ENDTAG); + UngetToken( doc ); /* put this back */ + InlineDup1( doc, NULL, element ); /* dupe the , after */ + if (!(mode & Preformatted)) + TrimSpaces(doc, element); + return; /* close , but will re-open it, after */ + } + } +#endif /* #ifdef ADD_INLINE_FIX2 */ + PopInline( doc, element ); if ( !nodeIsA(element) )