Skip to content

Commit 2276b9a

Browse files
authored
Merge pull request htacg#1 from readdle/fix/spark-pre-fix
Fix tidy pre block parsing
2 parents c8c3b7b + ecd8bd3 commit 2276b9a

File tree

3 files changed

+15
-5
lines changed

3 files changed

+15
-5
lines changed

include/tidyenum.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ typedef enum
176176
TidyEscapeScripts, /**< Escape items that look like closing tags in script tags */
177177

178178
TidyPreserveSpaces, /**< Preserve white spaces and new line characters */
179-
179+
TidyAllowEverythingInPre,/** Allow divs in pre block */
180180
N_TIDY_OPTIONS /**< Must be last */
181181
} TidyOptionId;
182182

src/config.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -326,6 +326,7 @@ static const TidyOptionImpl option_defs[] =
326326
{ TidyStrictTagsAttr, MU, "strict-tags-attributes", BL, no, ParseBool, boolPicks }, /* 20160209 - Issue #350 */
327327
{ TidyEscapeScripts, PP, "escape-scripts", BL, yes, ParseBool, boolPicks }, /* 20160227 - Issue #348 */
328328
{ TidyPreserveSpaces, PP, "preserve-spaces", BL, no, ParseBool, boolPicks },
329+
{ TidyAllowEverythingInPre, PP, "complex-pre", BL, no, ParseBool, boolPicks },
329330
{ N_TIDY_OPTIONS, XX, NULL, XY, 0, NULL, NULL }
330331
};
331332

src/parser.c

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1408,10 +1408,16 @@ void TY_(ParseBlock)( TidyDocImpl* doc, Node *element, GetTokenMode mode)
14081408
if (node->implicit)
14091409
TY_(ReportError)(doc, element, node, INSERTING_TAG );
14101410

1411-
/* Issue #212 - WHY is this hard coded to 'IgnoreWhitespace' while an
1412-
effort has been made above to set a 'MixedContent' mode in some cases?
1413-
WHY IS THE 'mode' VARIABLE NOT USED HERE???? */
1414-
ParseTag( doc, node, IgnoreWhitespace /*MixedContent*/ );
1411+
if ( nodeIsPRE(node) || IsPreDescendant(node)) {
1412+
ParseTag( doc, node, Preformatted );
1413+
}
1414+
else {
1415+
/* Issue #212 - WHY is this hard coded to 'IgnoreWhitespace' while an
1416+
effort has been made above to set a 'MixedContent' mode in some cases?
1417+
WHY IS THE 'mode' VARIABLE NOT USED HERE???? */
1418+
1419+
ParseTag( doc, node, mode /*MixedContent*/ );
1420+
}
14151421
continue;
14161422
}
14171423

@@ -3235,6 +3241,9 @@ void TY_(ParsePre)( TidyDocImpl* doc, Node *pre, GetTokenMode ARG_UNUSED(mode) )
32353241
/* strip unexpected tags */
32363242
if ( !PreContent(doc, node) )
32373243
{
3244+
if (cfgBool(doc, TidyAllowEverythingInPre) && nodeIsDIV(node)) {
3245+
continue;
3246+
}
32383247
Node *newnode;
32393248

32403249
/* fix for http://tidy.sf.net/bug/772205 */

0 commit comments

Comments
 (0)