diff --git a/constants.py b/constants.py index 9f14afb..89b0ef0 100644 --- a/constants.py +++ b/constants.py @@ -157,7 +157,6 @@ acceptable_elements = ['a', 'abbr', 'acronym', 'address', 'area', 'b', 'big', acceptable_attributes = ['href'] # entity list from http://code.google.com/p/doctype/wiki/CharacterEntitiesConsistent -# when version without ; is allowed, make sure to put the version with first. entities = { 'á' : 'á', 'Á' : 'Á', 'Á' : 'Á', diff --git a/output.py b/output.py index e756ca5..5244ceb 100644 --- a/output.py +++ b/output.py @@ -339,7 +339,8 @@ def removeEntities(text): # replace several named entities with character, such as — -> - # see constants.py for the list. - for e in entities: + # reverse sort will put entities with ; before the same one without, when valid. + for e in reversed(sorted(entities.keys())): v = entities[e] try: text = text.replace(e, v)