You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/site/docs/verification/semantic-html-comparison.md
+35-15Lines changed: 35 additions & 15 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -26,6 +26,16 @@ The [AngleSharp Diffing](https://github.com/AngleSharp/AngleSharp.Diffing/) libr
26
26
27
27
The [AngleSharp Diffing](https://github.com/AngleSharp/AngleSharp.Diffing/) library also allows us to customize the comparison process by adding special attributes to the _"control" markup_, i.e. the expected markup we want to use in verification.
28
28
29
+
All the customization options below will match with the following markup:
30
+
31
+
```html
32
+
<header>
33
+
<h1id="head-1">
34
+
Hello <em>world</em>
35
+
</h1>
36
+
</header>
37
+
```
38
+
29
39
Here are the customization options you have available to you:
30
40
31
41
-**Ignore comments (enabled by default):** Comments in markup and inside `<style>` tags are automatically ignored and not part of the comparison process.
@@ -34,39 +44,39 @@ Here are the customization options you have available to you:
34
44
35
45
```html
36
46
<header>
37
-
<h1class="heading-1"diff:ignore>Hello world</h1>
47
+
<h1diff:ignore></h1>
38
48
</header>
39
49
```
40
50
41
-
-**Ignore attribute:** To ignore an attribute during comparison, add the `:ignore` modifier to the attribute (no value is needed). For example, to ignore the `class` attribute:
51
+
-**Ignore attribute:** To ignore an attribute during comparison, add the `:ignore` modifier to the attribute (no value is needed). For example, to ignore the `id` attribute:
42
52
43
53
```html
44
54
<header>
45
-
<h1class:ignore>Hello world</h1>
55
+
<h1id:ignore>Hello <em>world</em></h1>
46
56
</header>
47
57
```
48
58
49
59
-**Ignore children:** Use the `diff:ignoreChildren` attribute (no value is needed) to ignore all child nodes/elements of an element. This does not include attributes. For example, to ignore all child nodes of the `h1` element, do the following:
> The `diff:ignoreChildren` and `diff:ignoreAttributes` attributes can be combined to ignore all child nodes/element *and* attributes of an element, but still verify that the element itself exists. For example:
- **Configure whitespace handling:** By default, all nodes and elements are compared using the `Normalize` whitespace handling option. The `Normalize` option will trim all text nodes and replace two or more whitespace characters with a single space character. The other options are `Preserve`, which will leave all whitespace unchanged, and `RemoveWhitespaceNodes`, which will only remove empty text nodes.
@@ -75,41 +85,51 @@ Here are the customization options you have available to you:
-**Perform case-insensitive comparison:** By default, all text comparison is case sensitive, but if you want to perform a case-insensitive comparison of text inside elements or attributes, use the `diff:ignoreCase` attribute on elements and `:ignoreCase` modifier on attributes. For example, to perform a case insensitive comparison of the text in the following `h1` element , do the following:
-**Use RegEx during comparison:** To use a regular expression when comparing the text inside an element or inside an attribute, use the `diff:regex` attribute on elements and the `:regex` modifier on attributes.
102
120
103
-
For example, to use a regular expression during comparison of the text in the `h1` element, add the `diff:regex` attribute to the element and place the regular expression in the body of the element:
121
+
For example, to use a regular expression during comparison of the text in the `em` element, add the `diff:regex` attribute to the element and place the regular expression in the body of the element:
104
122
105
123
```html
106
-
<h1diff:regexdiff:ignoreCase>Hello World \d{4}</h1>
124
+
<header>
125
+
<h1id="head-1">Hello <emdiff:regex>\w</em></h1>
126
+
</header>
107
127
```
108
128
109
-
To use a regular expression during comparison of the text inside the `title` attribute, add the `:regex` modifier to the attribute and add the regular expression in the attribute's value:
129
+
To use a regular expression during comparison of the text inside the `id` attribute, add the `:regex` modifier to the attribute and add the regular expression in the attribute's value:
0 commit comments