|
4 | 4 |
|
5 | 5 | ## The comparison algorithm |
6 | 6 |
|
7 | | -`html-differ` compares `HTML` codes using the following criteria: |
| 7 | +`HTML` codes are compared as **browsers** do, to be more exact `html-differ` compares `HTML` codes using the following criteria: |
8 | 8 |
|
9 | | -1. Two respective lists of attributes are considered to be equivalent even if they are specified in different order. |
10 | | -2. Two respective attributes `class` are considered to be equivalent if they refer to the same groups of `CSS` styles. |
| 9 | +* Two respective lists of attributes are considered to be equivalent even if they are specified in different order. |
11 | 10 |
|
12 | 11 | For example, the following two code samples will be considered to be equivalent: |
13 | 12 |
|
14 | 13 | ```html |
15 | | -<html> |
16 | | -<head> |
17 | | -<title>Test</title> |
18 | | -</head> |
19 | | -<body> |
20 | | - <label>label for input</label> |
21 | | - <input id="random" class="ab bc cd" tabIndex="1"> |
22 | | -</body> |
23 | | -</html> |
| 14 | +<span id="blah" class="ololo" tabIndex="1">Text</span> |
24 | 15 | ``` |
25 | 16 |
|
26 | 17 | ```html |
27 | | -<html> |
28 | | -<head> |
29 | | -<title>Test</title> |
30 | | -</head> |
31 | | -<body> |
32 | | - <label>label for input</label> |
33 | | - <input class=" cd ab bc" tabIndex="1" id="random"> |
34 | | -</body> |
35 | | -</html> |
| 18 | +<span tabIndex="1" id="blah" class="ololo">Text</span> |
| 19 | +``` |
| 20 | + |
| 21 | +* Two respective attributes `class` are considered to be equivalent if they refer to the same groups of `CSS` styles. |
| 22 | + |
| 23 | +For example, the following two code samples will be considered to be equivalent: |
| 24 | + |
| 25 | +```html |
| 26 | +<span class="ab bc cd">Text</span> |
| 27 | +``` |
| 28 | + |
| 29 | +```html |
| 30 | +<span class=" cd ab bc">Text</span> |
36 | 31 | ``` |
37 | 32 |
|
| 33 | +* From the list of the same tag's attributes, the attrubute which goes the first will be taken for comparison, others will be ignored. |
| 34 | + |
| 35 | +For example, the following two code samples will be considered to be equivalent: |
| 36 | + |
| 37 | +```html |
| 38 | +<span id="blah" id="ololo">Text</span> |
| 39 | +``` |
| 40 | + |
| 41 | +```html |
| 42 | +<span id="blah">Text</span> |
| 43 | +``` |
| 44 | + |
| 45 | +* Closing tags are not compared. |
| 46 | + |
| 47 | +For example, the following two code samples will be considered to be equivalent: |
| 48 | + |
| 49 | +```html |
| 50 | +<span>Text</span> |
| 51 | +``` |
| 52 | + |
| 53 | +```html |
| 54 | +<span>Text</spane> |
| 55 | +``` |
| 56 | + |
| 57 | +**CAUTION!** `html-differ` does not check the validity of `HTML` codes, but compares them using the above shown criteria and specified options (see the list of possible options in the [usage](https://github.com/bem/html-differ#usage)). |
| 58 | + |
38 | 59 | ## Install |
39 | 60 |
|
40 | 61 | ```bash |
@@ -222,7 +243,7 @@ Sets predefined options for `BEM` (default: `false`). |
222 | 243 |
|
223 | 244 | ```bash |
224 | 245 | $ html-differ --help |
225 | | -Compares two HTML files |
| 246 | +Compares two HTML codes |
226 | 247 |
|
227 | 248 | Usage: |
228 | 249 | html-differ [OPTIONS] [ARGS] |
|
0 commit comments