Commits

Gordon Hemsley committed 9021d38

Fix #16: Sort attributes alphabetically by default, but provide a parameter to turn this behavior off.

  • Participants
  • Parent commits 214954a

Comments (0)

Files changed (5)

     parser.add_argument("--escape-rcdata", action="store_true",
                         dest="escape_rcdata", help=SUPPRESS)
 
+    parser.add_argument("--no-alphabetical-attributes", action="store_false",
+                        dest="alphabetical_attributes", help=SUPPRESS)
+
     parser.add_argument("--output-encoding", action="store", type=str,
                         dest="output_encoding", help="Output encoding")
 
         space_before_trailing_solidus=False,
         escape_lt_in_attrs=False,
         escape_rcdata=False,
+        alphabetical_attributes=True,
         output_encoding="utf-8",
         dump_refs='',
         dump_xrefs='',
             assert not set(default_processes) & set(new_processes)
             kwargs["processes"] = default_processes + new_processes
 
+            # Sort attributes alphabetically by default.
+            kwargs["alphabetical_attributes"] = True
+
             try:
                 output = StringIO.StringIO()
 
                 input = open(file_name, "rb")
                 tree = generator.fromFile(input, **kwargs)
                 input.close()
-                
+
                 # Get the output
                 generator.toFile(tree, output, **kwargs)
 

File tests/alphabetical_attributes.html

+<!DOCTYPE html><meta charset=utf-8><a class=test data-aaa="" data-abc="" data-def="" data-zaa="" data-zzz="" href="" id=test target=_blank>Sort these attributes!</a>

File tests/alphabetical_attributes.options

+{
+	"alphabetical_attributes": true
+}

File tests/alphabetical_attributes.src.html

+<!DOCTYPE html>
+<a id="test" class="test" href="" data-zzz="" data-zaa="" data-def="" data-abc="" data-aaa="" target="_blank">Sort these attributes!</a>