mirror of
git://github.com/kovidgoyal/calibre.git
synced 2026-05-08 19:22:40 +02:00
For CSV_XML output, convert fields of type unicode from HTML to markup text.
This commit is contained in:
parent
de4534e150
commit
0e79b86f8a
1 changed files with 9 additions and 0 deletions
|
|
@ -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