From dc3f66ed0f37ab967ae646dd136f67d8c1f16f91 Mon Sep 17 00:00:00 2001 From: Dirk Thomas Date: Wed, 31 Aug 2016 13:29:01 -0700 Subject: [PATCH] Sort declarations in `style` attribute (#107) --- scour/scour.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/scour/scour.py b/scour/scour.py index 31cf1e7..4a2c1b3 100644 --- a/scour/scour.py +++ b/scour/scour.py @@ -3000,6 +3000,9 @@ def serializeXML(element, options, ind = 0, preserveWhitespace = False): quot = "'" attrValue = makeWellFormed( attr.nodeValue ) + if attr.nodeName == 'style': + # sort declarations + attrValue = '; '.join([p for p in sorted(attrValue.split(';'))]) outParts.append(' ') # preserve xmlns: if it is a namespace prefix declaration