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
**html-differ** compares HTML using the following criteria:
@@ -54,12 +84,12 @@ For example, the following two code samples will be considered to be equivalent:
54
84
```
55
85
56
86
**CAUTION!**<br>
57
-
**html-differ** does not check the validity of HTML, but compares them using the above shown criteria and specified options (see the list of possible options in the [API](https://github.com/bem/html-differ#api)).
87
+
**html-differ** does not check the validity of HTML, but compares them using the above shown criteria and specified options (see the list of possible [options](https://github.com/bem/html-differ/tree/master#options)).
58
88
59
89
## Install
60
90
61
91
```bash
62
-
$ npm install html-differ -g
92
+
$ npm install html-differ
63
93
```
64
94
65
95
## API
@@ -71,9 +101,11 @@ var HtmlDiffer = require('html-differ').HtmlDiffer,
71
101
htmlDiffer =newHtmlDiffer(options);
72
102
```
73
103
74
-
where `options` is an object:
104
+
where `options` is an object.
105
+
106
+
####Options####
75
107
76
-
***ignoreAttributes: [Array]**
108
+
#####ignoreAttributes: [Array]#####
77
109
78
110
Sets what kind of respective attributes' content will be ignored during the comparison (default: `[]`).
79
111
@@ -90,7 +122,7 @@ The following two code samples will be considered to be equivalent:
90
122
<inputid="sfsdfksdf">
91
123
```
92
124
93
-
***compareAttributesAsJSON: [Array]**
125
+
#####compareAttributesAsJSON: [Array]#####
94
126
95
127
Sets what kind of respective attributes' content will be compared as JSON objects, but not as strings (default: `[]`).<br>
96
128
In cases when the value of the attribute is an invalid JSON or can not be wrapped into a function, it will be compared as `undefined`.
@@ -118,7 +150,7 @@ The following two code samples will be considered to be equivalent:
118
150
The first element of the array could be written in a short form as string:<br>
Makes **html-differ** ignore whitespaces (spaces, tabs, new lines etc.) during the comparison (default: `true`).
124
156
@@ -150,7 +182,7 @@ The following two code samples will be considered to be equivalent:
150
182
151
183
```
152
184
153
-
***ignoreComments: Boolean**
185
+
#####ignoreComments: Boolean#####
154
186
155
187
Makes **html-differ** ignore HTML comments during the comparison (default: `true`).
156
188
@@ -199,7 +231,7 @@ Text
199
231
</html>
200
232
```
201
233
202
-
***ignoreEndTags: Boolean**
234
+
#####ignoreEndTags: Boolean#####
203
235
204
236
Makes **html-differ** ignore end tags during the comparison (default: `false`).
205
237
@@ -214,7 +246,7 @@ The following two code samples will be considered to be equivalent:
214
246
<span>Text</spane>
215
247
```
216
248
217
-
***ignoreDuplicateAttributes: Boolean**
249
+
#####ignoreDuplicateAttributes: Boolean#####
218
250
219
251
Makes **html-differ** ignore tags' duplicate attributes during the comparison.<br>
220
252
From the list of the same tag's attributes, the attribute which goes the first will be taken for comparison, others will be ignored (default: `false`).
@@ -230,40 +262,35 @@ For example, the following two code samples will be considered to be equivalent:
230
262
<spanid="blah">Text</span>
231
263
```
232
264
233
-
**BEM preset**
265
+
####Presets####
266
+
267
+
*[bem](https://github.com/bem/html-differ/blob/master/presets/bem.json) - sets predefined options for [BEM](http://bem.info/).
268
+
234
269
235
-
You can set predefined options for [BEM](http://bem.info/) using the _preset_:
270
+
#####Usage#####
271
+
272
+
Passing of a preset via the constructor:
236
273
237
274
```js
238
275
var HtmlDiffer =require('html-differ').HtmlDiffer,
**@returns***{Array of objects}* - [array with diffs](https://github.com/kpdecker/jsdiff#change-objects) between HTML
265
292
266
-
**htmlDiffer.isEqual**<br>
293
+
#####htmlDiffer.isEqual#####
267
294
**@param***{String}* - the 1-st HTML code<br>
268
295
**@param***{String}* - the 2-nd HTML code<br>
269
296
**@returns***{Boolean}*
@@ -277,16 +304,16 @@ var logger = require('html-differ/lib/logger');
277
304
278
305
####Methods####
279
306
280
-
**logger.getDiffText**<br>
281
-
**@param***{Array of objects}* - the result of the work of the method **htmlDiffer.diffHtml**<br>
307
+
#####logger.getDiffText#####
308
+
**@param***{Array of objects}* - the result of the work of the method [htmlDiffer.diffHtml](https://github.com/bem/html-differ/tree/master#htmldifferdiffhtml)<br>
282
309
**@param***{Object}* - options:<br>
283
310
284
311
***charsAroundDiff: Number** - the number of characters around the diff result between two HTML (default: `40`).
285
312
286
313
**@returns***{String}*
287
314
288
-
**logger.logDiffText**<br>
289
-
**@param***{Array of objects}* - the result of the work of the method **htmlDiffer.diffHtml**<br>
315
+
#####logger.logDiffText#####
316
+
**@param***{Array of objects}* - the result of the work of the method [htmlDiffer.diffHtml](https://github.com/bem/html-differ/tree/master#htmldifferdiffhtml)<br>
290
317
**@param***{Object}* - options:<br>
291
318
292
319
***charsAroundDiff: Number** - the number of characters around the diff result between two HTML (default: `40`).
@@ -336,8 +363,9 @@ Usage:
336
363
Options:
337
364
-h, --help : Help
338
365
-v, --version : Shows the version number
339
-
--config=CONFIG : Path to configuration JSON file
340
-
--bem : Uses predefined options for BEM
366
+
--config=CONFIG : Path to a configuration JSON file
367
+
--bem : Uses predefined options for BEM (deprecated)
368
+
-p PRESET, --preset=PRESET : Name of a preset
341
369
--chars-around-diff=CHARSAROUNDDIFF : The number of characters around the diff (default: 40)
0 commit comments