X-Git-Url: https://git.phdru.name/?a=blobdiff_plain;f=Robots%2Fparse_html.py;h=888e27c9f79a2f7d6310dd3129454d8b6b360d67;hb=ca8624faf5b9a31e76b7bf3d441f446c8b62c8f6;hp=dbca770543d7b6cc7b4e4c367413e53d505b1b5d;hpb=3054de4d1a2dc190c06943d021fdb836464e6b19;p=bookmarks_db.git diff --git a/Robots/parse_html.py b/Robots/parse_html.py index dbca770..888e27c 100755 --- a/Robots/parse_html.py +++ b/Robots/parse_html.py @@ -33,23 +33,18 @@ num_entity_re = re.compile("(&#[0-9]+;)") def recode_entities(title, charset): output = [] - for part in num_entity_re.split(title): + for part in entity_re.split(title): + if entity_re.match(part): + part = entitydefs.get(part[1:-1], part) + output.append(part) + + output2 = [] + for part in num_entity_re.split(''.join(output)): if num_entity_re.match(part): try: part = unichr(int(part[2:-1])).encode(charset) except UnicodeEncodeError: pass # Leave the entity as is - output.append(part) - - output2 = [] - for part in entity_re.split(''.join(output)): - if entity_re.match(part): - part = entitydefs.get(part[1:-1], part) - if num_entity_re.match(part): - try: - part = unichr(int(part[2:-1])).encode(charset) - except UnicodeEncodeError: - pass # Leave the entity as is output2.append(part) return ''.join(output2)