File tree Expand file tree Collapse file tree 1 file changed +8
-7
lines changed
src/Strategies/TextNodeStrategies Expand file tree Collapse file tree 1 file changed +8
-7
lines changed Original file line number Diff line number Diff line change @@ -8,7 +8,7 @@ namespace Egil.AngleSharp.Diffing.Strategies.TextNodeStrategies
8
8
{
9
9
public class TextNodeComparer
10
10
{
11
- private const string PRE_ELEMENTNAME = "PRE" ;
11
+ private static readonly string [ ] DefaultPreserveElement = new string [ ] { "PRE" , "SCRIPT" , "STYLE" } ;
12
12
private const string WHITESPACE_ATTR_NAME = "diff:whitespace" ;
13
13
private const string IGNORECASE_ATTR_NAME = "diff:ignorecase" ;
14
14
private const string REGEX_ATTR_NAME = "diff:regex" ;
@@ -81,14 +81,15 @@ private static bool GetIsRegexComparison(IText controlTextNode)
81
81
private WhitespaceOption GetWhitespaceOption ( IText textNode )
82
82
{
83
83
var parent = textNode . ParentElement ;
84
-
85
- if ( parent . NodeName . Equals ( PRE_ELEMENTNAME , StringComparison . Ordinal ) )
84
+ foreach ( var tagName in DefaultPreserveElement )
86
85
{
87
- return parent . TryGetAttrValue ( WHITESPACE_ATTR_NAME , out WhitespaceOption option )
88
- ? option
89
- : WhitespaceOption . Preserve ;
86
+ if ( parent . NodeName . Equals ( tagName , StringComparison . Ordinal ) )
87
+ {
88
+ return parent . TryGetAttrValue ( WHITESPACE_ATTR_NAME , out WhitespaceOption option )
89
+ ? option
90
+ : WhitespaceOption . Preserve ;
91
+ }
90
92
}
91
-
92
93
return parent . GetInlineOptionOrDefault < WhitespaceOption > ( WHITESPACE_ATTR_NAME , Whitespace ) ;
93
94
}
94
95
You can’t perform that action at this time.
0 commit comments