CSV catalog: Convert HTML comments to plain text

This commit is contained in:
Kovid Goyal 2011-06-15 09:06:44 -06:00
commit 76d9868b1f
3 changed files with 11 additions and 1 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 25 KiB

After

Width:  |  Height:  |  Size: 25 KiB

View File

@ -135,7 +135,8 @@ class ITUNES(DriverBase):
'''
Calling sequences:
Initialization:
can_handle() or can_handle_windows()
can_handle() | can_handle_windows()
_launch_iTunes()
reset()
open()
card_prefix()

View File

@ -149,6 +149,15 @@ class CSV_XML(CatalogPlugin): # {{{
elif field == 'comments':
item = item.replace(u'\r\n',u' ')
item = item.replace(u'\n',u' ')
# Convert HTML to markdown text
if type(item) is unicode:
opening_tag = re.search('<(\w+)(\x20|>)',item)
if opening_tag:
closing_tag = re.search('<\/%s>$' % opening_tag.group(1), item)
if closing_tag:
item = html2text(item)
outstr.append(u'"%s"' % unicode(item).replace('"','""'))
outfile.write(u','.join(outstr) + u'\n')