mirror of
git://github.com/kovidgoyal/calibre.git
synced 2026-05-09 11:14:02 +02:00
CSV catalog: Convert HTML comments to plain text
This commit is contained in:
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 |
|
|
@ -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()
|
||||
|
|
|
|||
|
|
@ -149,6 +149,15 @@ def run(self, path_to_output, opts, db, notification=DummyReporter()):
|
|||
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')
|
||||
|
|
|
|||
Loading…
Reference in a new issue