diff --git a/src/pprint.c b/src/pprint.c index 20900c7..2411156 100644 --- a/src/pprint.c +++ b/src/pprint.c @@ -312,6 +312,7 @@ void TY_(InitPrintBuf)( TidyDocImpl* doc ) InitIndent( &doc->pprint.indent[0] ); InitIndent( &doc->pprint.indent[1] ); doc->pprint.allocator = doc->allocator; + doc->pprint.line = 0; } void TY_(FreePrintBuf)( TidyDocImpl* doc ) @@ -613,6 +614,7 @@ static void WrapLine( TidyDocImpl* doc ) TY_(WriteChar)( '\\', doc->docOut ); TY_(WriteChar)( '\n', doc->docOut ); + pprint->line++; ResetLineAfterWrap( pprint ); } @@ -666,6 +668,7 @@ static void WrapAttrVal( TidyDocImpl* doc ) TY_(WriteChar)( ' ', doc->docOut ); TY_(WriteChar)( '\n', doc->docOut ); + pprint->line++; ResetLineAfterWrap( pprint ); } @@ -686,7 +689,7 @@ static void PFlushLineImpl( TidyDocImpl* doc ) for ( i = 0; i < pprint->linelen; ++i ) TY_(WriteChar)( pprint->linebuf[i], doc->docOut ); - + if ( IsInString(pprint) ) TY_(WriteChar)( '\\', doc->docOut ); ResetLine( pprint ); @@ -701,6 +704,7 @@ void TY_(PFlushLine)( TidyDocImpl* doc, uint indent ) PFlushLineImpl( doc ); TY_(WriteChar)( '\n', doc->docOut ); + pprint->line++; pprint->indent[ 0 ].spaces = indent; } @@ -713,6 +717,7 @@ static void PCondFlushLine( TidyDocImpl* doc, uint indent ) PFlushLineImpl( doc ); TY_(WriteChar)( '\n', doc->docOut ); + pprint->line++; pprint->indent[ 0 ].spaces = indent; } } @@ -733,6 +738,7 @@ void TY_(PFlushLineSmart)( TidyDocImpl* doc, uint indent ) /* Issue #228 - cfgBool( doc, TidyVertSpace ); */ if(TidyAddVS) { TY_(WriteChar)( '\n', doc->docOut ); + pprint->line++; } pprint->indent[ 0 ].spaces = indent; @@ -749,6 +755,7 @@ static void PCondFlushLineSmart( TidyDocImpl* doc, uint indent ) /* Issue #228 - cfgBool( doc, TidyVertSpace ); */ if(TidyAddVS) { TY_(WriteChar)( '\n', doc->docOut ); + pprint->line++; } pprint->indent[ 0 ].spaces = indent; diff --git a/src/pprint.h b/src/pprint.h index 4b36a21..8d473a4 100644 --- a/src/pprint.h +++ b/src/pprint.h @@ -53,6 +53,7 @@ typedef struct _TidyPrintImpl uint lbufsize; uint linelen; uint wraphere; + uint line; uint ixInd; TidyIndent indent[2]; /* Two lines worth of indent state */