README.md in compare-xml-0.5.1 vs README.md in compare-xml-0.5.2
- old
+ new
@@ -58,24 +58,44 @@
```ruby
require 'compare-xml'
```
-## Options
+## Options at a Glance
CompareXML has a variety of options that can be invoked as an optional argument, e.g.:
```ruby
-CompareXML.equivalent?(doc1, doc2, {squeeze_whitespace: true, verbose: true})
+CompareXML.equivalent?(doc1, doc2, {ignore_comments: false, verbose: true, ...})
```
+- `ignore_attr_order: {true|false}` default: **`true`**
+ - when `true`, ignores attribute order within tags
-----------
+- `ignore_attrs: {css}` default: **`{}`**
+ - when provided, ignores specific *attributes* using [CSS selectors](http://www.w3schools.com/cssref/css_selectors.asp)
+- `ignore_comments: {true|false}` default: **`true`**
+ - when `true`, ignores comments, such as `<!-- comment -->`
-- ####`ignore_attr_order: {true|false}` default: **`true`**
+- `ignore_nodes: {css}` default: **`{}`**
+ - when provided, ignores specific *nodes* using [CSS selectors](http://www.w3schools.com/cssref/css_selectors.asp)
+- `ignore_text_nodes: {true|false}` default: **`false`**
+ - when `true`, ignores all text content within a document
+
+- `collapse_whitespace: {true|false}` default: **`true`**
+ - when `true`, trims and collapses whitespace
+
+- `verbose: {true|false}` default: **`false`**
+ - when `true`, instead of a boolean, `CompareXML.equivalent?` returns an array of discrepancies.
+
+
+## Options in Depth
+
+- `ignore_attr_order: {true|false}` default: **`true`**
+
When `true`, all attributes are sorted before comparison and only attributes of the same type are compared.
**Usage Example:** `CompareXML.equivalent?(doc1, doc2, {ignore_attr_order: true})`
**Example:** When `true` the following HTML strings are considered equal:
@@ -98,15 +118,13 @@
href="/admin" == href="/admin"
=! rel="nofollow"
target="_blank" == target="_blank"
-----------
+- `ignore_attrs: {css}` default: **`{}`**
-- ####`ignore_attrs: {css}` default: **`{}`**
-
When provided, ignores all **attributes** that satisfy a particular rule using [CSS selectors](http://www.w3schools.com/cssref/css_selectors.asp).
**Usage Example:** `CompareXML.equivalent?(doc1, doc2, {ignore_attrs: ['a[rel="nofollow"]', 'input[type="hidden"']})`
**Example:** With `ignore_attrs: ['a[rel="nofollow"]', 'a[target]']` the following HTML strings are considered equal:
@@ -118,15 +136,13 @@
<a href="http://google.ca" class="primary button">Link</a>
<a href="https://google.com" class="primary button rounded">Link</a>
-----------
+- `ignore_comments: {true|false}` default: **`true`**
-- ####`ignore_comments: {true|false}` default: **`true`**
-
When `true`, ignores comments, such as `<!-- This is a comment -->`.
**Usage Example:** `CompareXML.equivalent?(doc1, doc2, {ignore_comments: true})`
**Example:** When `true` the following HTML strings are considered equal:
@@ -138,15 +154,13 @@
<a href="/admin"><!-- This is a comment -->Link</a>
<a href="/admin">Link</a>
-----------
+- `ignore_nodes: {css}` default: **`{}`**
-- ####`ignore_nodes: {css}` default: **`{}`**
-
When provided, ignores all **nodes** that satisfy a particular rule using [CSS selectors](http://www.w3schools.com/cssref/css_selectors.asp).
**Usage Example:** `CompareXML.equivalent?(doc1, doc2, {ignore_nodes: ['script', 'object']})`
**Example:** With `ignore_nodes: ['a[rel="nofollow"]', 'a[target]']` the following HTML strings are considered equal:
@@ -158,15 +172,13 @@
<a href="/admin"><i class"icon bulb"></i><b>Warning:</b> Link</a>
<a href="/admin"><i class"icon info"></i><b>Message:</b> Link</a>
-----------
+- `ignore_text_nodes: {true|false}` default: **`false`**
-- ####`ignore_text_nodes: {true|false}` default: **`false`**
-
When `true`, ignores all text content. Text content is anything that is included between an opening and a closing tag, e.g. `<tag>THIS IS TEXT CONTENT</tag>`.
**Usage Example:** `CompareXML.equivalent?(doc1, doc2, {ignore_text_nodes: true})`
**Example:** When `true` the following HTML strings are considered equal:
@@ -178,19 +190,17 @@
<i class="icon></i> <b>Warning:</b>
<i class="icon> </i> <b>Message:</b>
-----------
+- `collapse_whitespace: {true|false}` default: **`true`**
-- ####`squeeze_whitespace: {true|false}` default: **`true`**
+ When `true`, all text content within the document is trimmed (i.e. space removed from left and right) and whitespace is collapsed (i.e. tabs, new lines, multiple whitespace characters are replaced by a single whitespace).
- When `true`, all text content within the document is trimmed (i.e. space removed from left and right) and whitespace is squeezed (i.e. tabs, new lines, multiple whitespaces are all replaced by a single whitespace).
+ **Usage Example:** `CompareXML.equivalent?(doc1, doc2, {collapse_whitespace: true})`
- **Usage Example:** `CompareXML.equivalent?(doc1, doc2, {squeeze_whitespace: true})`
-
**Example:** When `true` the following HTML strings are considered equal:
<a href="/admin"> SOME TEXT CONTENT </a>
<a href="/index"> SOME TEXT CONTENT </a>
@@ -203,13 +213,11 @@
</html>
<html><title>This is my title</title></html>
-----------
-
-- ####`verbose: {true|false}` default: **`false`**
+- `verbose: {true|false}` default: **`false`**
When `true`, instead of returning a boolean value `CompareXML.equivalent?` returns an array of all errors encountered when performing a comparison.
> **Warning:** When `true`, the comparison takes longer! Not only because more processing is required to produce meaningful error messages, but also because in this mode, comparison does **NOT** stop when a first error is encountered, because the goal is to capture as many discrepancies as possible.
\ No newline at end of file