Issue #133 - hopefully a better fix.
As predicted the previous fix had adverse consequences on say script text, which then lost the indent, and was reverted. This introduces a new service, nodeIsTextLike, which naturally returns yes if it is text, but also is an AspTag. Maybe other text like nodes need to be added.
This commit is contained in:
parent
5d2cbd10dc
commit
cff3fdd308
21
src/pprint.c
21
src/pprint.c
|
@ -1732,10 +1732,29 @@ static int TextEndsWithNewline(Lexer *lexer, Node *node, uint mode )
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*\
|
||||||
|
* Issue #133 - creeping indent - a very OLD bug - 2nd tidy run increases the indent!
|
||||||
|
* If the node is text, then remove any white space equal to the indent,
|
||||||
|
* but this also applies to the AspTag, which is text like...
|
||||||
|
* And may apply to other text like nodes as well.
|
||||||
|
*
|
||||||
|
* Here the total white space is returned, and then a sister service, IncrWS()
|
||||||
|
* will advance the start of the lexer output by the amount of the indent.
|
||||||
|
\*/
|
||||||
|
static Bool TY_(nodeIsTextLike)( Node *node )
|
||||||
|
{
|
||||||
|
if ( TY_(nodeIsText)(node) )
|
||||||
|
return yes;
|
||||||
|
if ( node->type == AspTag )
|
||||||
|
return yes;
|
||||||
|
/* add other text like nodes... */
|
||||||
|
return no;
|
||||||
|
}
|
||||||
|
|
||||||
static int TextStartsWithWhitespace( Lexer *lexer, Node *node, uint start, uint mode )
|
static int TextStartsWithWhitespace( Lexer *lexer, Node *node, uint start, uint mode )
|
||||||
{
|
{
|
||||||
assert( node != NULL );
|
assert( node != NULL );
|
||||||
if ( (mode & (CDATA|COMMENT)) && TY_(nodeIsText)(node) && node->end > node->start && start >= node->start )
|
if ( (mode & (CDATA|COMMENT)) && TY_(nodeIsTextLike)(node) && node->end > node->start && start >= node->start )
|
||||||
{
|
{
|
||||||
uint ch, ix = start;
|
uint ch, ix = start;
|
||||||
/* Skip whitespace. */
|
/* Skip whitespace. */
|
||||||
|
|
Loading…
Reference in a new issue