Merge remote-tracking branch 'upstream/issue-228'
This commit is contained in:
commit
f0bf30e3cc
|
@ -85,7 +85,7 @@ add_definitions ( -DSUPPORT_ASIAN_ENCODINGS=1 )
|
||||||
add_definitions ( -DSUPPORT_ACCESSIBILITY_CHECKS=1 )
|
add_definitions ( -DSUPPORT_ACCESSIBILITY_CHECKS=1 )
|
||||||
add_definitions ( -DLIBTIDY_VERSION="${LIBTIDY_VERSION}" )
|
add_definitions ( -DLIBTIDY_VERSION="${LIBTIDY_VERSION}" )
|
||||||
add_definitions ( -DRELEASE_DATE="${tidy_YEAR}/${tidy_MONTH}/${tidy_DAY}" )
|
add_definitions ( -DRELEASE_DATE="${tidy_YEAR}/${tidy_MONTH}/${tidy_DAY}" )
|
||||||
### add_definitions ( -DRC_NUMBER="RC1" )
|
add_definitions ( -DRC_NUMBER="D231" )
|
||||||
|
|
||||||
# Issue #188 - Support user items in platform.h
|
# Issue #188 - Support user items in platform.h
|
||||||
if (TIDY_CONFIG_FILE)
|
if (TIDY_CONFIG_FILE)
|
||||||
|
|
|
@ -309,7 +309,7 @@ static const TidyOptionImpl option_defs[] =
|
||||||
{ TidyEmptyTags, MU, "new-empty-tags", ST, 0, ParseTagNames, NULL },
|
{ TidyEmptyTags, MU, "new-empty-tags", ST, 0, ParseTagNames, NULL },
|
||||||
{ TidyPreTags, MU, "new-pre-tags", ST, 0, ParseTagNames, NULL },
|
{ TidyPreTags, MU, "new-pre-tags", ST, 0, ParseTagNames, NULL },
|
||||||
{ TidyAccessibilityCheckLevel, DG, "accessibility-check", IN, 0, ParseAcc, accessPicks },
|
{ TidyAccessibilityCheckLevel, DG, "accessibility-check", IN, 0, ParseAcc, accessPicks },
|
||||||
{ TidyVertSpace, PP, "vertical-space", BL, no, ParseBool, boolPicks },
|
{ TidyVertSpace, PP, "vertical-space", IN, no, ParseAutoBool, autoBoolPicks }, /* #228 - tri option */
|
||||||
#if SUPPORT_ASIAN_ENCODINGS
|
#if SUPPORT_ASIAN_ENCODINGS
|
||||||
{ TidyPunctWrap, PP, "punctuation-wrap", BL, no, ParseBool, boolPicks },
|
{ TidyPunctWrap, PP, "punctuation-wrap", BL, no, ParseBool, boolPicks },
|
||||||
#endif
|
#endif
|
||||||
|
|
13
src/lexer.c
13
src/lexer.c
|
@ -983,7 +983,8 @@ static void ParseEntity( TidyDocImpl* doc, GetTokenMode mode )
|
||||||
if ( TY_(tmbstrcmp)(lexer->lexbuf+start, "&apos") == 0
|
if ( TY_(tmbstrcmp)(lexer->lexbuf+start, "&apos") == 0
|
||||||
&& !cfgBool(doc, TidyXmlOut)
|
&& !cfgBool(doc, TidyXmlOut)
|
||||||
&& !lexer->isvoyager
|
&& !lexer->isvoyager
|
||||||
&& !cfgBool(doc, TidyXhtmlOut) )
|
&& !cfgBool(doc, TidyXhtmlOut)
|
||||||
|
&& !(TY_(HTMLVersion)(doc) == HT50) ) /* Issue #239 - no warning if in HTML5++ mode */
|
||||||
TY_(ReportEntityError)( doc, APOS_UNDEFINED, lexer->lexbuf+start, 39 );
|
TY_(ReportEntityError)( doc, APOS_UNDEFINED, lexer->lexbuf+start, 39 );
|
||||||
|
|
||||||
if (( mode == OtherNamespace ) && ( c == ';' ))
|
if (( mode == OtherNamespace ) && ( c == ';' ))
|
||||||
|
@ -2624,6 +2625,16 @@ static Node* GetTokenFromStream( TidyDocImpl* doc, GetTokenMode mode )
|
||||||
/* special check needed for CRLF sequence */
|
/* special check needed for CRLF sequence */
|
||||||
/* this doesn't apply to empty elements */
|
/* this doesn't apply to empty elements */
|
||||||
/* nor to preformatted content that needs escaping */
|
/* nor to preformatted content that needs escaping */
|
||||||
|
/*\
|
||||||
|
* Issue #230: Need to KEEP this user newline character in certain
|
||||||
|
* circumstances, certainly for <pre>, <script>, <style>...
|
||||||
|
* Any others?
|
||||||
|
* Issue #238: maybe **ONLY** for <pre>
|
||||||
|
\*/
|
||||||
|
if ( nodeIsPRE(lexer->token) )
|
||||||
|
{
|
||||||
|
mode = Preformatted;
|
||||||
|
}
|
||||||
|
|
||||||
if ((mode != Preformatted && ExpectsContent(lexer->token))
|
if ((mode != Preformatted && ExpectsContent(lexer->token))
|
||||||
|| nodeIsBR(lexer->token) || nodeIsHR(lexer->token))
|
|| nodeIsBR(lexer->token) || nodeIsHR(lexer->token))
|
||||||
|
|
|
@ -748,9 +748,10 @@ static const TidyOptionDoc option_docs[] =
|
||||||
"successive tab stops. It is used to map tabs to spaces when reading the "
|
"successive tab stops. It is used to map tabs to spaces when reading the "
|
||||||
"input. "
|
"input. "
|
||||||
},
|
},
|
||||||
{TidyVertSpace,
|
{TidyVertSpace, /* Issue #228 - changed to tri-state */
|
||||||
"This option specifies if Tidy should add some empty lines for "
|
"This option specifies if Tidy should add some extra empty lines for "
|
||||||
"readability. "
|
"readability. Default is 'no'. If set to 'auto', will eliminate nearly "
|
||||||
|
"all newline chars."
|
||||||
},
|
},
|
||||||
{TidyWrapLen,
|
{TidyWrapLen,
|
||||||
"This option specifies the right margin Tidy uses for line wrapping. Tidy "
|
"This option specifies the right margin Tidy uses for line wrapping. Tidy "
|
||||||
|
|
|
@ -97,15 +97,15 @@ void TY_(freeFileSource)( TidyInputSource* inp, Bool closeIt )
|
||||||
|
|
||||||
|
|
||||||
#if defined(_WIN32)
|
#if defined(_WIN32)
|
||||||
#include "streamio.h"
|
|
||||||
#include "tidy-int.h"
|
|
||||||
#include "message.h"
|
|
||||||
|
|
||||||
#include <errno.h>
|
|
||||||
#if defined(_MSC_VER) && (_MSC_VER < 1300) /* less than msvc++ 7.0 */
|
#if defined(_MSC_VER) && (_MSC_VER < 1300) /* less than msvc++ 7.0 */
|
||||||
#pragma warning(disable:4115) /* named type definition in parentheses in windows headers */
|
#pragma warning(disable:4115) /* named type definition in parentheses in windows headers */
|
||||||
#endif
|
#endif
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
|
#include <errno.h>
|
||||||
|
|
||||||
|
#include "streamio.h"
|
||||||
|
#include "tidy-int.h"
|
||||||
|
#include "message.h"
|
||||||
|
|
||||||
typedef struct _fp_input_mapped_source
|
typedef struct _fp_input_mapped_source
|
||||||
{
|
{
|
||||||
|
|
143
src/pprint.c
143
src/pprint.c
|
@ -36,6 +36,12 @@ static int TextStartsWithWhitespace( Lexer *lexer, Node *node, uint start, uint
|
||||||
static Bool InsideHead( TidyDocImpl* doc, Node *node );
|
static Bool InsideHead( TidyDocImpl* doc, Node *node );
|
||||||
static Bool ShouldIndent( TidyDocImpl* doc, Node *node );
|
static Bool ShouldIndent( TidyDocImpl* doc, Node *node );
|
||||||
|
|
||||||
|
/*\
|
||||||
|
* Issue #228 20150715 - macros to access --vertical-space tri state configuration parameter
|
||||||
|
\*/
|
||||||
|
#define TidyClassicVS ((cfgAutoBool( doc, TidyVertSpace ) == TidyYesState) ? yes : no)
|
||||||
|
#define TidyAddVS ((cfgAutoBool( doc, TidyVertSpace ) == TidyAutoState) ? no : yes )
|
||||||
|
|
||||||
/*\
|
/*\
|
||||||
* 20150515 - support using tabs instead of spaces - Issue #108
|
* 20150515 - support using tabs instead of spaces - Issue #108
|
||||||
* GH: https://github.com/htacg/tidy-html5/issues/108 - Keep indent with tabs #108
|
* GH: https://github.com/htacg/tidy-html5/issues/108 - Keep indent with tabs #108
|
||||||
|
@ -711,6 +717,44 @@ static void PCondFlushLine( TidyDocImpl* doc, uint indent )
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Two additional "smart" flush line functions which only
|
||||||
|
* write a newline if `vertical-space no`. See issues #163 and #227.
|
||||||
|
* These need to be used in the right place. In same cases `PFlushLine`
|
||||||
|
* and `PCondFlushLine` should still be used.
|
||||||
|
*/
|
||||||
|
void TY_(PFlushLineSmart)( TidyDocImpl* doc, uint indent )
|
||||||
|
{
|
||||||
|
TidyPrintImpl* pprint = &doc->pprint;
|
||||||
|
|
||||||
|
if ( pprint->linelen > 0 )
|
||||||
|
PFlushLineImpl( doc );
|
||||||
|
|
||||||
|
/* Issue #228 - cfgBool( doc, TidyVertSpace ); */
|
||||||
|
if(TidyAddVS) {
|
||||||
|
TY_(WriteChar)( '\n', doc->docOut );
|
||||||
|
}
|
||||||
|
|
||||||
|
pprint->indent[ 0 ].spaces = indent;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void PCondFlushLineSmart( TidyDocImpl* doc, uint indent )
|
||||||
|
{
|
||||||
|
TidyPrintImpl* pprint = &doc->pprint;
|
||||||
|
|
||||||
|
if ( pprint->linelen > 0 )
|
||||||
|
{
|
||||||
|
PFlushLineImpl( doc );
|
||||||
|
|
||||||
|
/* Issue #228 - cfgBool( doc, TidyVertSpace ); */
|
||||||
|
if(TidyAddVS) {
|
||||||
|
TY_(WriteChar)( '\n', doc->docOut );
|
||||||
|
}
|
||||||
|
|
||||||
|
pprint->indent[ 0 ].spaces = indent;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static void PPrintChar( TidyDocImpl* doc, uint c, uint mode )
|
static void PPrintChar( TidyDocImpl* doc, uint c, uint mode )
|
||||||
{
|
{
|
||||||
tmbchar entity[128];
|
tmbchar entity[128];
|
||||||
|
@ -1164,7 +1208,7 @@ static void PPrintAttribute( TidyDocImpl* doc, uint indent,
|
||||||
if ( TY_(nodeIsElement)(node) && !first )
|
if ( TY_(nodeIsElement)(node) && !first )
|
||||||
{
|
{
|
||||||
indent += xtra;
|
indent += xtra;
|
||||||
PCondFlushLine( doc, indent );
|
PCondFlushLineSmart( doc, indent );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
indAttrs = no;
|
indAttrs = no;
|
||||||
|
@ -1471,7 +1515,7 @@ static void PPrintTag( TidyDocImpl* doc,
|
||||||
See bug #996484 */
|
See bug #996484 */
|
||||||
else if ( mode & NOWRAP ||
|
else if ( mode & NOWRAP ||
|
||||||
nodeIsBR(node) || AfterSpace(doc->lexer, node))
|
nodeIsBR(node) || AfterSpace(doc->lexer, node))
|
||||||
PCondFlushLine( doc, indent );
|
PCondFlushLineSmart( doc, indent );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1536,7 +1580,7 @@ static void PPrintComment( TidyDocImpl* doc, uint indent, Node* node )
|
||||||
AddString(pprint, "--");
|
AddString(pprint, "--");
|
||||||
AddChar( pprint, '>' );
|
AddChar( pprint, '>' );
|
||||||
if ( node->linebreak && node->next )
|
if ( node->linebreak && node->next )
|
||||||
TY_(PFlushLine)( doc, indent );
|
TY_(PFlushLineSmart)( doc, indent );
|
||||||
}
|
}
|
||||||
|
|
||||||
static void PPrintDocType( TidyDocImpl* doc, uint indent, Node *node )
|
static void PPrintDocType( TidyDocImpl* doc, uint indent, Node *node )
|
||||||
|
@ -1550,7 +1594,7 @@ static void PPrintDocType( TidyDocImpl* doc, uint indent, Node *node )
|
||||||
/* todo: handle non-ASCII characters in FPI / SI / node->element */
|
/* todo: handle non-ASCII characters in FPI / SI / node->element */
|
||||||
|
|
||||||
SetWrap( doc, indent );
|
SetWrap( doc, indent );
|
||||||
PCondFlushLine( doc, indent );
|
PCondFlushLineSmart( doc, indent );
|
||||||
|
|
||||||
AddString( pprint, "<!DOCTYPE " );
|
AddString( pprint, "<!DOCTYPE " );
|
||||||
SetWrap( doc, indent );
|
SetWrap( doc, indent );
|
||||||
|
@ -1573,7 +1617,7 @@ static void PPrintDocType( TidyDocImpl* doc, uint indent, Node *node )
|
||||||
if (!(i>0&&TY_(tmbstrlen)(sys->value)+2+i<wraplen&&i<=(spaces?spaces:2)*2))
|
if (!(i>0&&TY_(tmbstrlen)(sys->value)+2+i<wraplen&&i<=(spaces?spaces:2)*2))
|
||||||
i = 0;
|
i = 0;
|
||||||
|
|
||||||
PCondFlushLine(doc, i);
|
PCondFlushLineSmart(doc, i);
|
||||||
if (pprint->linelen)
|
if (pprint->linelen)
|
||||||
AddChar(pprint, ' ');
|
AddChar(pprint, ' ');
|
||||||
}
|
}
|
||||||
|
@ -1591,7 +1635,7 @@ static void PPrintDocType( TidyDocImpl* doc, uint indent, Node *node )
|
||||||
|
|
||||||
if (node->content)
|
if (node->content)
|
||||||
{
|
{
|
||||||
PCondFlushLine(doc, indent);
|
PCondFlushLineSmart(doc, indent);
|
||||||
AddChar(pprint, '[');
|
AddChar(pprint, '[');
|
||||||
PPrintText(doc, CDATA, 0, node->content);
|
PPrintText(doc, CDATA, 0, node->content);
|
||||||
AddChar(pprint, ']');
|
AddChar(pprint, ']');
|
||||||
|
@ -1599,7 +1643,7 @@ static void PPrintDocType( TidyDocImpl* doc, uint indent, Node *node )
|
||||||
|
|
||||||
SetWrap( doc, 0 );
|
SetWrap( doc, 0 );
|
||||||
AddChar( pprint, '>' );
|
AddChar( pprint, '>' );
|
||||||
PCondFlushLine( doc, indent );
|
PCondFlushLineSmart( doc, indent );
|
||||||
}
|
}
|
||||||
|
|
||||||
static void PPrintPI( TidyDocImpl* doc, uint indent, Node *node )
|
static void PPrintPI( TidyDocImpl* doc, uint indent, Node *node )
|
||||||
|
@ -1664,7 +1708,7 @@ static void PPrintXmlDecl( TidyDocImpl* doc, uint indent, Node *node )
|
||||||
AddChar( pprint, '?' );
|
AddChar( pprint, '?' );
|
||||||
AddChar( pprint, '>' );
|
AddChar( pprint, '>' );
|
||||||
WrapOn( doc, saveWrap );
|
WrapOn( doc, saveWrap );
|
||||||
TY_(PFlushLine)( doc, indent );
|
TY_(PFlushLineSmart)( doc, indent );
|
||||||
}
|
}
|
||||||
|
|
||||||
/* note ASP and JSTE share <% ... %> syntax */
|
/* note ASP and JSTE share <% ... %> syntax */
|
||||||
|
@ -1729,14 +1773,14 @@ static void PPrintCDATA( TidyDocImpl* doc, uint indent, Node *node )
|
||||||
if ( !indentCData )
|
if ( !indentCData )
|
||||||
indent = 0;
|
indent = 0;
|
||||||
|
|
||||||
PCondFlushLine( doc, indent );
|
PCondFlushLineSmart( doc, indent );
|
||||||
saveWrap = WrapOff( doc ); /* disable wrapping */
|
saveWrap = WrapOff( doc ); /* disable wrapping */
|
||||||
|
|
||||||
AddString( pprint, "<![CDATA[" );
|
AddString( pprint, "<![CDATA[" );
|
||||||
PPrintText( doc, COMMENT, indent, node );
|
PPrintText( doc, COMMENT, indent, node );
|
||||||
AddString( pprint, "]]>" );
|
AddString( pprint, "]]>" );
|
||||||
|
|
||||||
PCondFlushLine( doc, indent );
|
PCondFlushLineSmart( doc, indent );
|
||||||
WrapOn( doc, saveWrap ); /* restore wrapping */
|
WrapOn( doc, saveWrap ); /* restore wrapping */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1889,15 +1933,13 @@ void PPrintScriptStyle( TidyDocImpl* doc, uint mode, uint indent, Node *node )
|
||||||
Bool xhtmlOut = cfgBool( doc, TidyXhtmlOut );
|
Bool xhtmlOut = cfgBool( doc, TidyXhtmlOut );
|
||||||
|
|
||||||
if ( InsideHead(doc, node) )
|
if ( InsideHead(doc, node) )
|
||||||
TY_(PFlushLine)( doc, indent );
|
TY_(PFlushLineSmart)( doc, indent );
|
||||||
|
|
||||||
PCondFlushLine( doc, indent ); /* Issue #56 - long oustanding bug - flush any existing closing tag */
|
PCondFlushLineSmart( doc, indent ); /* Issue #56 - long oustanding bug - flush any existing closing tag */
|
||||||
|
|
||||||
PPrintTag( doc, mode, indent, node );
|
PPrintTag( doc, mode, indent, node );
|
||||||
|
|
||||||
/* use zero indent here, see http://tidy.sf.net/bug/729972
|
TY_(PFlushLineSmart)(doc, indent);
|
||||||
WHY??? TY_(PFlushLine)(doc, 0); */
|
|
||||||
TY_(PFlushLine)(doc, indent);
|
|
||||||
|
|
||||||
if ( xhtmlOut && node->content != NULL )
|
if ( xhtmlOut && node->content != NULL )
|
||||||
{
|
{
|
||||||
|
@ -1928,7 +1970,7 @@ void PPrintScriptStyle( TidyDocImpl* doc, uint mode, uint indent, Node *node )
|
||||||
AddString( pprint, commentStart );
|
AddString( pprint, commentStart );
|
||||||
AddString( pprint, CDATA_START );
|
AddString( pprint, CDATA_START );
|
||||||
AddString( pprint, commentEnd );
|
AddString( pprint, commentEnd );
|
||||||
PCondFlushLine( doc, indent );
|
PCondFlushLineSmart( doc, indent );
|
||||||
|
|
||||||
WrapOn( doc, saveWrap );
|
WrapOn( doc, saveWrap );
|
||||||
}
|
}
|
||||||
|
@ -1952,7 +1994,7 @@ void PPrintScriptStyle( TidyDocImpl* doc, uint mode, uint indent, Node *node )
|
||||||
|
|
||||||
if ( contentIndent < 0 )
|
if ( contentIndent < 0 )
|
||||||
{
|
{
|
||||||
PCondFlushLine( doc, indent );
|
PCondFlushLineSmart( doc, indent );
|
||||||
contentIndent = 0;
|
contentIndent = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1967,7 +2009,7 @@ void PPrintScriptStyle( TidyDocImpl* doc, uint mode, uint indent, Node *node )
|
||||||
AddString( pprint, commentEnd );
|
AddString( pprint, commentEnd );
|
||||||
|
|
||||||
WrapOn( doc, saveWrap );
|
WrapOn( doc, saveWrap );
|
||||||
PCondFlushLine( doc, indent );
|
PCondFlushLineSmart( doc, indent );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1979,7 +2021,7 @@ void PPrintScriptStyle( TidyDocImpl* doc, uint mode, uint indent, Node *node )
|
||||||
if ( cfgAutoBool(doc, TidyIndentContent) == TidyNoState
|
if ( cfgAutoBool(doc, TidyIndentContent) == TidyNoState
|
||||||
&& node->next != NULL &&
|
&& node->next != NULL &&
|
||||||
!( TY_(nodeHasCM)(node, CM_INLINE) || TY_(nodeIsText)(node) ) )
|
!( TY_(nodeHasCM)(node, CM_INLINE) || TY_(nodeIsText)(node) ) )
|
||||||
TY_(PFlushLine)( doc, indent );
|
TY_(PFlushLineSmart)( doc, indent );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -2112,20 +2154,20 @@ void TY_(PPrintTree)( TidyDocImpl* doc, uint mode, uint indent, Node *node )
|
||||||
or remove the CM_INLINE from the tag
|
or remove the CM_INLINE from the tag
|
||||||
*/
|
*/
|
||||||
if ( ! TY_(nodeHasCM)(node, CM_INLINE) )
|
if ( ! TY_(nodeHasCM)(node, CM_INLINE) )
|
||||||
PCondFlushLine( doc, indent );
|
PCondFlushLineSmart( doc, indent );
|
||||||
|
|
||||||
if ( nodeIsBR(node) && node->prev &&
|
if ( nodeIsBR(node) && node->prev &&
|
||||||
!(nodeIsBR(node->prev) || (mode & PREFORMATTED)) &&
|
!(nodeIsBR(node->prev) || (mode & PREFORMATTED)) &&
|
||||||
cfgBool(doc, TidyBreakBeforeBR) )
|
cfgBool(doc, TidyBreakBeforeBR) )
|
||||||
TY_(PFlushLine)( doc, indent );
|
TY_(PFlushLineSmart)( doc, indent );
|
||||||
|
|
||||||
if ( nodeIsHR(node) )
|
if ( nodeIsHR(node) )
|
||||||
{
|
{
|
||||||
/* insert extra newline for classic formatting */
|
/* insert extra newline for classic formatting */
|
||||||
Bool classic = cfgBool( doc, TidyVertSpace );
|
Bool classic = TidyClassicVS; /* #228 - cfgBool( doc, TidyVertSpace ); */
|
||||||
if (classic && node->parent && node->parent->content != node)
|
if (classic && node->parent && node->parent->content != node)
|
||||||
{
|
{
|
||||||
TY_(PFlushLine)( doc, indent );
|
TY_(PFlushLineSmart)( doc, indent );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2134,10 +2176,10 @@ void TY_(PPrintTree)( TidyDocImpl* doc, uint mode, uint indent, Node *node )
|
||||||
if (node->next)
|
if (node->next)
|
||||||
{
|
{
|
||||||
if (nodeIsPARAM(node) || nodeIsAREA(node))
|
if (nodeIsPARAM(node) || nodeIsAREA(node))
|
||||||
PCondFlushLine(doc, indent);
|
PCondFlushLineSmart(doc, indent);
|
||||||
else if ((nodeIsBR(node) && !(mode & PREFORMATTED))
|
else if ((nodeIsBR(node) && !(mode & PREFORMATTED))
|
||||||
|| nodeIsHR(node))
|
|| nodeIsHR(node))
|
||||||
TY_(PFlushLine)(doc, indent);
|
TY_(PFlushLineSmart)(doc, indent);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else /* some kind of container element */
|
else /* some kind of container element */
|
||||||
|
@ -2148,32 +2190,35 @@ void TY_(PPrintTree)( TidyDocImpl* doc, uint mode, uint indent, Node *node )
|
||||||
if ( node->tag &&
|
if ( node->tag &&
|
||||||
(node->tag->parser == TY_(ParsePre) || nodeIsTEXTAREA(node)) )
|
(node->tag->parser == TY_(ParsePre) || nodeIsTEXTAREA(node)) )
|
||||||
{
|
{
|
||||||
Bool classic = cfgBool( doc, TidyVertSpace );
|
Bool classic = TidyClassicVS; /* #228 - cfgBool( doc, TidyVertSpace ); */
|
||||||
uint indprev = indent;
|
uint indprev = indent;
|
||||||
PCondFlushLine( doc, indent );
|
|
||||||
|
|
||||||
PCondFlushLine( doc, indent );
|
PCondFlushLineSmart( doc, indent ); /* about to add <pre> tag - clear any previous */
|
||||||
|
|
||||||
/* insert extra newline for classic formatting */
|
/* insert extra newline for classic formatting */
|
||||||
if (classic && node->parent && node->parent->content != node)
|
if (classic && node->parent && node->parent->content != node)
|
||||||
{
|
{
|
||||||
TY_(PFlushLine)( doc, indent );
|
TY_(PFlushLineSmart)( doc, indent );
|
||||||
}
|
}
|
||||||
PPrintTag( doc, mode, indent, node );
|
|
||||||
|
PPrintTag( doc, mode, indent, node ); /* add <pre> or <textarea> tag */
|
||||||
|
|
||||||
indent = 0;
|
indent = 0;
|
||||||
|
/* @camoy Fix #158 - remove inserted newlines in pre - TY_(PFlushLineSmart)( doc, indent ); */
|
||||||
|
|
||||||
for ( content = node->content; content; content = content->next )
|
for ( content = node->content; content; content = content->next )
|
||||||
{
|
{
|
||||||
TY_(PPrintTree)( doc, (mode | PREFORMATTED | NOWRAP),
|
TY_(PPrintTree)( doc, (mode | PREFORMATTED | NOWRAP),
|
||||||
indent, content );
|
indent, content );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* @camoy Fix #158 - remove inserted newlines in pre - PCondFlushLineSmart( doc, indent ); */
|
||||||
indent = indprev;
|
indent = indprev;
|
||||||
PPrintEndTag( doc, mode, indent, node );
|
PPrintEndTag( doc, mode, indent, node );
|
||||||
|
|
||||||
if ( cfgAutoBool(doc, TidyIndentContent) == TidyNoState
|
if ( cfgAutoBool(doc, TidyIndentContent) == TidyNoState
|
||||||
&& node->next != NULL )
|
&& node->next != NULL )
|
||||||
TY_(PFlushLine)( doc, indent );
|
TY_(PFlushLineSmart)( doc, indent );
|
||||||
}
|
}
|
||||||
else if ( nodeIsSTYLE(node) || nodeIsSCRIPT(node) )
|
else if ( nodeIsSTYLE(node) || nodeIsSCRIPT(node) )
|
||||||
{
|
{
|
||||||
|
@ -2202,7 +2247,7 @@ void TY_(PPrintTree)( TidyDocImpl* doc, uint mode, uint indent, Node *node )
|
||||||
if ( ShouldIndent(doc, node) )
|
if ( ShouldIndent(doc, node) )
|
||||||
{
|
{
|
||||||
indent += spaces;
|
indent += spaces;
|
||||||
PCondFlushLine( doc, indent );
|
PCondFlushLineSmart( doc, indent );
|
||||||
|
|
||||||
for ( content = node->content;
|
for ( content = node->content;
|
||||||
content != NULL;
|
content != NULL;
|
||||||
|
@ -2210,7 +2255,7 @@ void TY_(PPrintTree)( TidyDocImpl* doc, uint mode, uint indent, Node *node )
|
||||||
TY_(PPrintTree)( doc, mode, indent, content );
|
TY_(PPrintTree)( doc, mode, indent, content );
|
||||||
|
|
||||||
indent -= spaces;
|
indent -= spaces;
|
||||||
PCondFlushLine( doc, indent );
|
PCondFlushLineSmart( doc, indent );
|
||||||
/* PCondFlushLine( doc, indent ); */
|
/* PCondFlushLine( doc, indent ); */
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -2228,19 +2273,19 @@ void TY_(PPrintTree)( TidyDocImpl* doc, uint mode, uint indent, Node *node )
|
||||||
Bool indsmart = ( cfgAutoBool(doc, TidyIndentContent) == TidyAutoState );
|
Bool indsmart = ( cfgAutoBool(doc, TidyIndentContent) == TidyAutoState );
|
||||||
Bool hideend = cfgBool( doc, TidyHideEndTags ) ||
|
Bool hideend = cfgBool( doc, TidyHideEndTags ) ||
|
||||||
cfgBool( doc, TidyOmitOptionalTags );
|
cfgBool( doc, TidyOmitOptionalTags );
|
||||||
Bool classic = cfgBool( doc, TidyVertSpace );
|
Bool classic = TidyClassicVS; /* #228 - cfgBool( doc, TidyVertSpace ); */
|
||||||
uint contentIndent = indent;
|
uint contentIndent = indent;
|
||||||
|
|
||||||
/* insert extra newline for classic formatting */
|
/* insert extra newline for classic formatting */
|
||||||
if (classic && node->parent && node->parent->content != node && !nodeIsHTML(node))
|
if (classic && node->parent && node->parent->content != node && !nodeIsHTML(node))
|
||||||
{
|
{
|
||||||
TY_(PFlushLine)( doc, indent );
|
TY_(PFlushLineSmart)( doc, indent );
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( ShouldIndent(doc, node) )
|
if ( ShouldIndent(doc, node) )
|
||||||
contentIndent += spaces;
|
contentIndent += spaces;
|
||||||
|
|
||||||
PCondFlushLine( doc, indent );
|
PCondFlushLineSmart( doc, indent );
|
||||||
|
|
||||||
/*\
|
/*\
|
||||||
* Issue #180 - with the above PCondFlushLine,
|
* Issue #180 - with the above PCondFlushLine,
|
||||||
|
@ -2248,7 +2293,7 @@ void TY_(PPrintTree)( TidyDocImpl* doc, uint mode, uint indent, Node *node )
|
||||||
* Maybe only if 'classic' ie --vertical-space yes
|
* Maybe only if 'classic' ie --vertical-space yes
|
||||||
\*/
|
\*/
|
||||||
if ( indsmart && node->prev != NULL && classic)
|
if ( indsmart && node->prev != NULL && classic)
|
||||||
TY_(PFlushLine)( doc, indent );
|
TY_(PFlushLineSmart)( doc, indent );
|
||||||
|
|
||||||
/* do not omit elements with attributes */
|
/* do not omit elements with attributes */
|
||||||
if ( !hideend || !TY_(nodeHasCM)(node, CM_OMITST) ||
|
if ( !hideend || !TY_(nodeHasCM)(node, CM_OMITST) ||
|
||||||
|
@ -2261,11 +2306,11 @@ void TY_(PPrintTree)( TidyDocImpl* doc, uint mode, uint indent, Node *node )
|
||||||
/* fix for bug 530791, don't wrap after */
|
/* fix for bug 530791, don't wrap after */
|
||||||
/* <li> if first child is text node */
|
/* <li> if first child is text node */
|
||||||
if (!(nodeIsLI(node) && TY_(nodeIsText)(node->content)))
|
if (!(nodeIsLI(node) && TY_(nodeIsText)(node->content)))
|
||||||
PCondFlushLine( doc, contentIndent );
|
PCondFlushLineSmart( doc, contentIndent );
|
||||||
}
|
}
|
||||||
else if ( TY_(nodeHasCM)(node, CM_HTML) || nodeIsNOFRAMES(node) ||
|
else if ( TY_(nodeHasCM)(node, CM_HTML) || nodeIsNOFRAMES(node) ||
|
||||||
(TY_(nodeHasCM)(node, CM_HEAD) && !nodeIsTITLE(node)) )
|
(TY_(nodeHasCM)(node, CM_HEAD) && !nodeIsTITLE(node)) )
|
||||||
TY_(PFlushLine)( doc, contentIndent );
|
TY_(PFlushLineSmart)( doc, contentIndent );
|
||||||
}
|
}
|
||||||
|
|
||||||
last = NULL;
|
last = NULL;
|
||||||
|
@ -2276,7 +2321,7 @@ void TY_(PPrintTree)( TidyDocImpl* doc, uint mode, uint indent, Node *node )
|
||||||
content->tag && !TY_(nodeHasCM)(content, CM_INLINE) )
|
content->tag && !TY_(nodeHasCM)(content, CM_INLINE) )
|
||||||
{
|
{
|
||||||
/* TY_(PFlushLine)(fout, indent); */
|
/* TY_(PFlushLine)(fout, indent); */
|
||||||
TY_(PFlushLine)( doc, contentIndent );
|
TY_(PFlushLineSmart)( doc, contentIndent );
|
||||||
}
|
}
|
||||||
|
|
||||||
TY_(PPrintTree)( doc, mode, contentIndent, content );
|
TY_(PPrintTree)( doc, mode, contentIndent, content );
|
||||||
|
@ -2293,7 +2338,7 @@ void TY_(PPrintTree)( TidyDocImpl* doc, uint mode, uint indent, Node *node )
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
PCondFlushLine( doc, indent );
|
PCondFlushLineSmart( doc, indent );
|
||||||
if ( !hideend || !TY_(nodeHasCM)(node, CM_OPT) )
|
if ( !hideend || !TY_(nodeHasCM)(node, CM_OPT) )
|
||||||
{
|
{
|
||||||
PPrintEndTag( doc, mode, indent, node );
|
PPrintEndTag( doc, mode, indent, node );
|
||||||
|
@ -2306,15 +2351,15 @@ void TY_(PPrintTree)( TidyDocImpl* doc, uint mode, uint indent, Node *node )
|
||||||
{
|
{
|
||||||
/* newline before endtag for classic formatting */
|
/* newline before endtag for classic formatting */
|
||||||
if ( classic && !HasMixedContent(node) )
|
if ( classic && !HasMixedContent(node) )
|
||||||
TY_(PFlushLine)( doc, indent );
|
TY_(PFlushLineSmart)( doc, indent );
|
||||||
PPrintEndTag( doc, mode, indent, node );
|
PPrintEndTag( doc, mode, indent, node );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!indcont && !hideend && !nodeIsHTML(node) && !classic)
|
if (!indcont && !hideend && !nodeIsHTML(node) && !classic)
|
||||||
TY_(PFlushLine)( doc, indent );
|
TY_(PFlushLineSmart)( doc, indent );
|
||||||
else if (classic && node->next != NULL && TY_(nodeHasCM)(node, CM_LIST|CM_DEFLIST|CM_TABLE|CM_BLOCK/*|CM_HEADING*/))
|
else if (classic && node->next != NULL && TY_(nodeHasCM)(node, CM_LIST|CM_DEFLIST|CM_TABLE|CM_BLOCK/*|CM_HEADING*/))
|
||||||
TY_(PFlushLine)( doc, indent );
|
TY_(PFlushLineSmart)( doc, indent );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2331,7 +2376,7 @@ void TY_(PPrintXMLTree)( TidyDocImpl* doc, uint mode, uint indent, Node *node )
|
||||||
}
|
}
|
||||||
else if ( node->type == CommentTag )
|
else if ( node->type == CommentTag )
|
||||||
{
|
{
|
||||||
PCondFlushLine( doc, indent );
|
PCondFlushLineSmart( doc, indent );
|
||||||
PPrintComment( doc, indent, node);
|
PPrintComment( doc, indent, node);
|
||||||
/* PCondFlushLine( doc, 0 ); */
|
/* PCondFlushLine( doc, 0 ); */
|
||||||
}
|
}
|
||||||
|
@ -2362,7 +2407,7 @@ void TY_(PPrintXMLTree)( TidyDocImpl* doc, uint mode, uint indent, Node *node )
|
||||||
else if ( TY_(nodeHasCM)(node, CM_EMPTY) ||
|
else if ( TY_(nodeHasCM)(node, CM_EMPTY) ||
|
||||||
(node->type == StartEndTag && !xhtmlOut) )
|
(node->type == StartEndTag && !xhtmlOut) )
|
||||||
{
|
{
|
||||||
PCondFlushLine( doc, indent );
|
PCondFlushLineSmart( doc, indent );
|
||||||
PPrintTag( doc, mode, indent, node );
|
PPrintTag( doc, mode, indent, node );
|
||||||
/* TY_(PFlushLine)( doc, indent ); */
|
/* TY_(PFlushLine)( doc, indent ); */
|
||||||
}
|
}
|
||||||
|
@ -2382,7 +2427,7 @@ void TY_(PPrintXMLTree)( TidyDocImpl* doc, uint mode, uint indent, Node *node )
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
PCondFlushLine( doc, indent );
|
PCondFlushLineSmart( doc, indent );
|
||||||
|
|
||||||
if ( TY_(XMLPreserveWhiteSpace)(doc, node) )
|
if ( TY_(XMLPreserveWhiteSpace)(doc, node) )
|
||||||
{
|
{
|
||||||
|
@ -2397,13 +2442,13 @@ void TY_(PPrintXMLTree)( TidyDocImpl* doc, uint mode, uint indent, Node *node )
|
||||||
|
|
||||||
PPrintTag( doc, mode, indent, node );
|
PPrintTag( doc, mode, indent, node );
|
||||||
if ( !mixed && node->content )
|
if ( !mixed && node->content )
|
||||||
TY_(PFlushLine)( doc, cindent );
|
TY_(PFlushLineSmart)( doc, cindent );
|
||||||
|
|
||||||
for ( content = node->content; content; content = content->next )
|
for ( content = node->content; content; content = content->next )
|
||||||
TY_(PPrintXMLTree)( doc, mode, cindent, content );
|
TY_(PPrintXMLTree)( doc, mode, cindent, content );
|
||||||
|
|
||||||
if ( !mixed && node->content )
|
if ( !mixed && node->content )
|
||||||
PCondFlushLine( doc, indent );
|
PCondFlushLineSmart( doc, indent );
|
||||||
|
|
||||||
PPrintEndTag( doc, mode, indent, node );
|
PPrintEndTag( doc, mode, indent, node );
|
||||||
/* PCondFlushLine( doc, indent ); */
|
/* PCondFlushLine( doc, indent ); */
|
||||||
|
|
20
src/tags.c
20
src/tags.c
|
@ -160,8 +160,8 @@ static CheckAttribs CheckHTML;
|
||||||
#define VERS_ELEM_WBR (xxxx|xxxx|xxxx|xxxx|xxxx|xxxx|xxxx|xxxx|xxxx|xxxx|xxxx|xxxx|xxxx|HT50|XH50)
|
#define VERS_ELEM_WBR (xxxx|xxxx|xxxx|xxxx|xxxx|xxxx|xxxx|xxxx|xxxx|xxxx|xxxx|xxxx|xxxx|HT50|XH50)
|
||||||
|
|
||||||
/*\
|
/*\
|
||||||
* Issue #167 & #169
|
* Issue #167 & #169 & #232
|
||||||
* Tody defaults to HTML5 mode
|
* Tidy defaults to HTML5 mode
|
||||||
* but allow this table to be ADJUSTED if NOT HTML5
|
* but allow this table to be ADJUSTED if NOT HTML5
|
||||||
* was static const Dict tag_defs[] =
|
* was static const Dict tag_defs[] =
|
||||||
\*/
|
\*/
|
||||||
|
@ -232,7 +232,7 @@ static Dict tag_defs[] =
|
||||||
{ TidyTag_META, "meta", VERS_ELEM_META, &TY_(W3CAttrsFor_META)[0], (CM_HEAD|CM_BLOCK|CM_EMPTY), TY_(ParseEmpty), NULL },
|
{ TidyTag_META, "meta", VERS_ELEM_META, &TY_(W3CAttrsFor_META)[0], (CM_HEAD|CM_BLOCK|CM_EMPTY), TY_(ParseEmpty), NULL },
|
||||||
{ TidyTag_NOFRAMES, "noframes", VERS_ELEM_NOFRAMES, &TY_(W3CAttrsFor_NOFRAMES)[0], (CM_BLOCK|CM_FRAMES), TY_(ParseNoFrames), NULL },
|
{ TidyTag_NOFRAMES, "noframes", VERS_ELEM_NOFRAMES, &TY_(W3CAttrsFor_NOFRAMES)[0], (CM_BLOCK|CM_FRAMES), TY_(ParseNoFrames), NULL },
|
||||||
{ TidyTag_NOSCRIPT, "noscript", VERS_ELEM_NOSCRIPT, &TY_(W3CAttrsFor_NOSCRIPT)[0], (CM_HEAD|CM_BLOCK|CM_INLINE|CM_MIXED), TY_(ParseBlock), NULL },
|
{ TidyTag_NOSCRIPT, "noscript", VERS_ELEM_NOSCRIPT, &TY_(W3CAttrsFor_NOSCRIPT)[0], (CM_HEAD|CM_BLOCK|CM_INLINE|CM_MIXED), TY_(ParseBlock), NULL },
|
||||||
{ TidyTag_OBJECT, "object", VERS_ELEM_OBJECT, &TY_(W3CAttrsFor_OBJECT)[0], (CM_OBJECT|CM_HEAD|CM_IMG|CM_INLINE|CM_PARAM), TY_(ParseBlock), NULL },
|
{ TidyTag_OBJECT, "object", VERS_ELEM_OBJECT, &TY_(W3CAttrsFor_OBJECT)[0], (CM_OBJECT|CM_IMG|CM_INLINE|CM_PARAM), TY_(ParseBlock), NULL },
|
||||||
{ TidyTag_OL, "ol", VERS_ELEM_OL, &TY_(W3CAttrsFor_OL)[0], (CM_BLOCK), TY_(ParseList), NULL },
|
{ TidyTag_OL, "ol", VERS_ELEM_OL, &TY_(W3CAttrsFor_OL)[0], (CM_BLOCK), TY_(ParseList), NULL },
|
||||||
{ TidyTag_OPTGROUP, "optgroup", VERS_ELEM_OPTGROUP, &TY_(W3CAttrsFor_OPTGROUP)[0], (CM_FIELD|CM_OPT), TY_(ParseOptGroup), NULL },
|
{ TidyTag_OPTGROUP, "optgroup", VERS_ELEM_OPTGROUP, &TY_(W3CAttrsFor_OPTGROUP)[0], (CM_FIELD|CM_OPT), TY_(ParseOptGroup), NULL },
|
||||||
{ TidyTag_OPTION, "option", VERS_ELEM_OPTION, &TY_(W3CAttrsFor_OPTION)[0], (CM_FIELD|CM_OPT), TY_(ParseText), NULL },
|
{ TidyTag_OPTION, "option", VERS_ELEM_OPTION, &TY_(W3CAttrsFor_OPTION)[0], (CM_FIELD|CM_OPT), TY_(ParseText), NULL },
|
||||||
|
@ -762,6 +762,20 @@ void TY_(AdjustTags)( TidyDocImpl *doc )
|
||||||
tagsEmptyHash( doc, tags );
|
tagsEmptyHash( doc, tags );
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*\
|
||||||
|
* Issue #232
|
||||||
|
* TidyTag_OBJECT not in head in HTML5,
|
||||||
|
* but still allowed in HTML4
|
||||||
|
\*/
|
||||||
|
np = (Dict *)TY_(LookupTagDef)( TidyTag_OBJECT );
|
||||||
|
if (np)
|
||||||
|
{
|
||||||
|
np->model |= CM_HEAD; /* add back allowed in head */
|
||||||
|
#if ELEMENT_HASH_LOOKUP
|
||||||
|
tagsEmptyHash( doc, tags );
|
||||||
|
#endif
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void TY_(FreeTags)( TidyDocImpl* doc )
|
void TY_(FreeTags)( TidyDocImpl* doc )
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
@REM call alltest1 ..\bin\tidy.exe .\tmp
|
@REM call alltest1 ..\bin\tidy.exe .\tmp
|
||||||
@REM ########################################################################
|
@REM ########################################################################
|
||||||
@REM This is the location of the cmake build output using the MSVC Generator
|
@REM This is the location of the cmake build output using the MSVC Generator
|
||||||
@set TMPEXE=..\build\cmake\Release\tidy5.exe
|
@set TMPEXE=..\build\cmake\Release\tidy.exe
|
||||||
@REM === some other test EXE I can use for compare ===
|
@REM === some other test EXE I can use for compare ===
|
||||||
@REM set TMPEXE=C:\Projects\tidy\tidy-cvs\build\msvc\Release\tidy.exe
|
@REM set TMPEXE=C:\Projects\tidy\tidy-cvs\build\msvc\Release\tidy.exe
|
||||||
@REM set TMPEXE=C:\MDOS\tidydev.exe
|
@REM set TMPEXE=C:\MDOS\tidydev.exe
|
||||||
|
|
|
@ -1,2 +1,2 @@
|
||||||
5.1.2
|
5.1.7
|
||||||
2015.07.14
|
2015.08.22
|
||||||
|
|
Loading…
Reference in a new issue