add option "-C" ("--force-color")
3 files changed, 16 insertions(+), 5 deletions(-)

M ChangeLog.md
M README.md
M xdiff.py
M ChangeLog.md +6 -0
@@ 1,3 1,9 @@ 
+2019-10-07:
+
+  * add option `-C` (`--force-color`)
+  * bump version to 2.1
+
+
 2019-08-24:
 
   * add option `-w` (`--words`)

          
M README.md +4 -1
@@ 24,6 24,7 @@ Usage:
 
     xdiff.py [-a] [--all-context]
              [-c] [--comments]
+             [-C] [--force-color]
              [-i] [--indent]
              [-n] [--no-context]
              [-N] [--no-meta]

          
@@ 42,7 43,9 @@ default. The `-a` option outputs all con
 outputs none. The option `-N` suppresses metadata output (files header and hunk
 numbers). If the option `-i` is set, the diff is constructed from indented XML
 trees. The option `-w` option compares the content word-wise (one word per
-line). Comments in the XML files are ignored unless the `-c` option is used.
+line). Comments in the XML files are ignored unless the `-c` option is used. The
+`-C` option preserves color and formatting codes when piping output through [GNU
+less](http://www.gnu.org/software/less/) and similar programs.
 
 The `-q` suppresses output altogether, but still returns the exit status (`1` if
 there are structural or textual differences, `0` if there are none, and `2` for

          
M xdiff.py +6 -4
@@ 1,6 1,6 @@ 
 #! /usr/bin/python3
 # xdiff.py -- compare XML files
-# Andreas Nolda 2019-08-24
+# Andreas Nolda 2019-10-07
 
 import sys
 import argparse

          
@@ 9,9 9,7 @@ from blessings import Terminal
 from lxml import etree
 from difflib import unified_diff
 
-version=2.0
-
-term = Terminal()
+version=2.1
 
 parser = argparse.ArgumentParser()
 parser.add_argument("file1", help="XML file 1")

          
@@ 20,6 18,8 @@ parser.add_argument("-a", "--all-context
                     help="output all context lines")
 parser.add_argument("-c", "--comments", action="store_true",
                     help="preserve comments in output")
+parser.add_argument("-C", "--force-color", action="store_true",
+                    help="preserve color and formatting when piping output")
 parser.add_argument("-i", "--indent", action="store_true",
                     help="indent XML trees")
 parser.add_argument("-n", "--no-context", action="store_true",

          
@@ 34,6 34,8 @@ parser.add_argument("-w", "--words", act
                     help="compare words")
 args = parser.parse_args()
 
+term = Terminal(force_styling=args.force_color)
+
 def parse_file(file):
     try:
         xml_parser = etree.XMLParser(remove_blank_text=True)