From fa0799597d686a4e870bf0a6d76a9addb8114756 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Tue, 30 Nov 2010 18:35:14 -0700 Subject: [PATCH] Fix #7746 (Converting prc->epub: names of streets and lakes) --- src/calibre/ebooks/mobi/reader.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/calibre/ebooks/mobi/reader.py b/src/calibre/ebooks/mobi/reader.py index f80d15359c..48ece79f45 100644 --- a/src/calibre/ebooks/mobi/reader.py +++ b/src/calibre/ebooks/mobi/reader.py @@ -504,6 +504,9 @@ class MobiReader(object): 'x-large': '5', 'xx-large': '6', } + def barename(x): + return x.rpartition(':')[-1] + mobi_version = self.book_header.mobi_version for x in root.xpath('//ncx'): x.getparent().remove(x) @@ -512,8 +515,9 @@ class MobiReader(object): for x in tag.attrib: if ':' in x: del tag.attrib[x] - if tag.tag in ('country-region', 'place', 'placetype', 'placename', - 'state', 'city', 'street', 'address', 'content', 'form'): + if tag.tag and barename(tag.tag.lower()) in \ + ('country-region', 'place', 'placetype', 'placename', + 'state', 'city', 'street', 'address', 'content', 'form'): tag.tag = 'div' if tag.tag in ('content', 'form') else 'span' for key in tag.attrib.keys(): tag.attrib.pop(key)