diff -urN tidycvs\console\tidy.c tidydev4\console\tidy.c --- tidycvs\console\tidy.c Wed Feb 15 14:15:40 2006 +++ tidydev4\console\tidy.c Sun Feb 19 15:13:40 2006 @@ -14,6 +14,12 @@ */ #include "tidy.h" +#if !defined(NO_SETMODE_SUPPORT) +#if defined(_WIN32) || defined(OS2_OS) +#include +#include +#endif /* defined(_WIN32) || defined(OS2_OS) */ +#endif /* !NO_SETMODE_SUPPORT */ static FILE* errout = NULL; /* set to stderr */ /* static FILE* txtout = NULL; */ /* set to stdout */ @@ -1220,6 +1226,26 @@ continue; } +#if !defined(NO_SETMODE_SUPPORT) +#if defined(_WIN32) || defined(OS2_OS) + /* clear of help or version output, so + it is safe to set binary, since Tidy + internally translates LF'es + Note, system resets these on program exit. + */ +/* Note, _setmode() does NOT work on Win2K Pro w/ VC++ 6.0 SP3. +** The code has been left in in case it works w/ other compilers +** or operating systems. If stdout is in Text mode, be aware that +** it will garble UTF16 documents. In text mode, when it encounters +** a single byte of value 10 (0xA), it will insert a single byte +** value 13 (0xD) just before it. This has the effect of garbling +** the entire document. +*/ + setmode( fileno(stdout), _O_BINARY ); + setmode( fileno(stderr), _O_BINARY ); +#endif /* WIN32 or OS2_OS */ +#endif /* !NO_SETMODE_SUPPORT */ + if ( argc > 1 ) { htmlfil = argv[1]; @@ -1267,9 +1293,11 @@ break; } +#if 0 /* chopped code */ if (!tidyOptGetBool(tdoc, TidyQuiet) && errout == stderr && !contentErrors) fprintf(errout, "\n"); +#endif /* #if 0 end chop */ if (contentErrors + contentWarnings > 0 && !tidyOptGetBool(tdoc, TidyQuiet)) diff -urN tidycvs\include\platform.h tidydev4\include\platform.h --- tidycvs\include\platform.h Wed Feb 15 14:15:40 2006 +++ tidydev4\include\platform.h Sat Feb 18 13:46:52 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 -urN tidycvs\src\istack.c tidydev4\src\istack.c --- tidycvs\src\istack.c Sat Feb 18 12:32:44 2006 +++ tidydev4\src\istack.c Sat Feb 18 13:46:52 2006 @@ -288,6 +288,88 @@ 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 */ + /* * local variables: * mode: c diff -urN tidycvs\src\lexer.h tidydev4\src\lexer.h --- tidycvs\src\lexer.h Sat Feb 18 12:32:44 2006 +++ tidydev4\src\lexer.h Sat Feb 18 13:46:52 2006 @@ -622,6 +622,25 @@ 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 -urN tidycvs\src\parser.c tidydev4\src\parser.c --- tidycvs\src\parser.c Sat Feb 18 12:32:45 2006 +++ tidydev4\src\parser.c Sat Feb 18 13:46:51 2006 @@ -1513,6 +1513,28 @@ && 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) ) diff -urN tidycvs\src\tidylib.c tidydev4\src\tidylib.c --- tidycvs\src\tidylib.c Wed Jan 25 18:43:39 2006 +++ tidydev4\src\tidylib.c Sun Feb 19 15:22:01 2006 @@ -953,65 +953,18 @@ return status; } - - -/* Note, _setmode() does NOT work on Win2K Pro w/ VC++ 6.0 SP3. -** The code has been left in in case it works w/ other compilers -** or operating systems. If stdout is in Text mode, be aware that -** it will garble UTF16 documents. In text mode, when it encounters -** a single byte of value 10 (0xA), it will insert a single byte -** value 13 (0xD) just before it. This has the effect of garbling -** the entire document. -*/ - -#if !defined(NO_SETMODE_SUPPORT) - -#if defined(_WIN32) || defined(OS2_OS) -#include -#include -#endif - -#endif - int tidyDocSaveStdout( TidyDocImpl* doc ) { -#if !defined(NO_SETMODE_SUPPORT) - -#if defined(_WIN32) || defined(OS2_OS) - int oldstdoutmode = -1, oldstderrmode = -1; -#endif - -#endif int status = 0; uint outenc = cfg( doc, TidyOutCharEncoding ); uint nl = cfg( doc, TidyNewline ); StreamOut* out = FileOutput( stdout, outenc, nl ); -#if !defined(NO_SETMODE_SUPPORT) - -#if defined(_WIN32) || defined(OS2_OS) - oldstdoutmode = setmode( fileno(stdout), _O_BINARY ); - oldstderrmode = setmode( fileno(stderr), _O_BINARY ); -#endif - -#endif - - if ( 0 == status ) - status = tidyDocSaveStream( doc, out ); - - fflush(stdout); - fflush(stderr); - -#if !defined(NO_SETMODE_SUPPORT) + fflush(stderr); /* ensure any stderr is output first */ -#if defined(_WIN32) || defined(OS2_OS) - if ( oldstdoutmode != -1 ) - oldstdoutmode = setmode( fileno(stdout), oldstdoutmode ); - if ( oldstderrmode != -1 ) - oldstderrmode = setmode( fileno(stderr), oldstderrmode ); -#endif + status = tidyDocSaveStream( doc, out ); -#endif + fflush(stdout); /* flush the stdout html output */ MemFree( out ); return status; diff -urN tidycvs\src\version.h tidydev4\src\version.h --- tidycvs\src\version.h Wed Feb 15 14:15:44 2006 +++ tidydev4\src\version.h Wed Feb 15 18:37:20 2006 @@ -11,4 +11,4 @@ */ -static const char release_date[] = "14 February 2006"; +static const char release_date[] = "14 February 2006 (tidydev4)"; diff -urN tidycvs\temp1410061-2.htm tidydev4\temp1410061-2.htm --- tidycvs\temp1410061-2.htm Thu Jan 01 01:00:00 1970 +++ tidydev4\temp1410061-2.htm Sat Feb 18 15:53:06 2006 @@ -0,0 +1,12 @@ + + + +1410061 - issue 2 - inline propagation + + +In bold +
    +
  • Not in bold
  • +
+ + diff -urN tidycvs\test\input\cfg_1410061-2.txt tidydev4\test\input\cfg_1410061-2.txt --- tidycvs\test\input\cfg_1410061-2.txt Thu Jan 01 01:00:00 1970 +++ tidydev4\test\input\cfg_1410061-2.txt Sat Feb 18 15:26:55 2006 @@ -0,0 +1 @@ +tidy-mark: no diff -urN tidycvs\test\input\cfg_1423252.txt tidydev4\test\input\cfg_1423252.txt --- tidycvs\test\input\cfg_1423252.txt Thu Jan 01 01:00:00 1970 +++ tidydev4\test\input\cfg_1423252.txt Tue Feb 14 15:28:46 2006 @@ -0,0 +1,2 @@ +tidy-mark: no + diff -urN tidycvs\test\input\cfg_1426419.txt tidydev4\test\input\cfg_1426419.txt --- tidycvs\test\input\cfg_1426419.txt Thu Jan 01 01:00:00 1970 +++ tidydev4\test\input\cfg_1426419.txt Sat Feb 18 14:58:58 2006 @@ -0,0 +1 @@ +tidy-mark: no diff -urN tidycvs\test\input\in_1423252.html tidydev4\test\input\in_1423252.html --- tidycvs\test\input\in_1423252.html Fri Feb 17 16:08:32 2006 +++ tidydev4\test\input\in_1423252.html Sat Feb 18 14:18:26 2006 @@ -1,3 +1,11 @@ -a + + + +[1423252] missing text node, and font propagation + + +a
b
-

c +

c + + diff -urN tidycvs\test\input\in_1426419.html tidydev4\test\input\in_1426419.html --- tidycvs\test\input\in_1426419.html Thu Jan 01 01:00:00 1970 +++ tidydev4\test\input\in_1426419.html Sat Feb 18 15:00:53 2006 @@ -0,0 +1,12 @@ + + + +[1426419] mal-formed inline elements + + +

Bold Bold and Italics Italics Only

+

Mono Mono and Bold Bold Only

+

Italics Italics and Bold Bold Only

+ + diff -urN tidycvs\test\testcases.txt tidydev4\test\testcases.txt --- tidycvs\test\testcases.txt Sat Feb 18 12:32:45 2006 +++ tidydev4\test\testcases.txt Sat Feb 18 14:59:42 2006 @@ -187,3 +187,4 @@ 1410061-2 1 1415137 1 1423252 1 +1426419 1