mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
CSV catalog: Convert HTML comments to plain text
This commit is contained in:
commit
76d9868b1f
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:
|
Calling sequences:
|
||||||
Initialization:
|
Initialization:
|
||||||
can_handle() or can_handle_windows()
|
can_handle() | can_handle_windows()
|
||||||
|
_launch_iTunes()
|
||||||
reset()
|
reset()
|
||||||
open()
|
open()
|
||||||
card_prefix()
|
card_prefix()
|
||||||
|
@ -149,6 +149,15 @@ class CSV_XML(CatalogPlugin): # {{{
|
|||||||
elif field == 'comments':
|
elif field == 'comments':
|
||||||
item = item.replace(u'\r\n',u' ')
|
item = item.replace(u'\r\n',u' ')
|
||||||
item = item.replace(u'\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('"','""'))
|
outstr.append(u'"%s"' % unicode(item).replace('"','""'))
|
||||||
|
|
||||||
outfile.write(u','.join(outstr) + u'\n')
|
outfile.write(u','.join(outstr) + u'\n')
|
||||||
|
Loading…
x
Reference in New Issue
Block a user