File tree Expand file tree Collapse file tree
src/Strategies/TextNodeStrategies Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -8,7 +8,7 @@ namespace Egil.AngleSharp.Diffing.Strategies.TextNodeStrategies
88{
99 public class TextNodeComparer
1010 {
11- private const string PRE_ELEMENTNAME = "PRE" ;
11+ private static readonly string [ ] DefaultPreserveElement = new string [ ] { "PRE" , "SCRIPT" , "STYLE" } ;
1212 private const string WHITESPACE_ATTR_NAME = "diff:whitespace" ;
1313 private const string IGNORECASE_ATTR_NAME = "diff:ignorecase" ;
1414 private const string REGEX_ATTR_NAME = "diff:regex" ;
@@ -81,14 +81,15 @@ private static bool GetIsRegexComparison(IText controlTextNode)
8181 private WhitespaceOption GetWhitespaceOption ( IText textNode )
8282 {
8383 var parent = textNode . ParentElement ;
84-
85- if ( parent . NodeName . Equals ( PRE_ELEMENTNAME , StringComparison . Ordinal ) )
84+ foreach ( var tagName in DefaultPreserveElement )
8685 {
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+ }
9092 }
91-
9293 return parent . GetInlineOptionOrDefault < WhitespaceOption > ( WHITESPACE_ATTR_NAME , Whitespace ) ;
9394 }
9495
You can’t perform that action at this time.
0 commit comments