Remove empty tags in info

This commit is contained in:
Sengian 2011-01-15 21:51:37 +01:00
parent 77ce7b9c76
commit 8cf62f9feb

View File

@ -15,7 +15,7 @@
# # # #
# # # #
######################################################################### #########################################################################
import sys, os, tempfile import sys, os, tempfile, re
from calibre.ebooks.rtf2xml import copy from calibre.ebooks.rtf2xml import copy
@ -51,6 +51,7 @@ class Info:
""" """
self.__text_string = '' self.__text_string = ''
self.__state = 'before_info_table' self.__state = 'before_info_table'
self.rmspace = re.compile(r'\s+')
self.__state_dict = { self.__state_dict = {
'before_info_table': self.__before_info_table_func, 'before_info_table': self.__before_info_table_func,
'after_info_table': self.__after_info_table_func, 'after_info_table': self.__after_info_table_func,
@ -167,6 +168,8 @@ class Info:
""" """
if self.__token_info == 'mi<mk<docinf-end': if self.__token_info == 'mi<mk<docinf-end':
self.__state = 'in_info_table' self.__state = 'in_info_table'
#Don't print empty tags
if len(self.rmspace.sub('',self.__text_string)):
self.__write_obj.write( self.__write_obj.write(
'mi<tg<open______<%s\n' 'mi<tg<open______<%s\n'
'tx<nu<__________<%s\n' 'tx<nu<__________<%s\n'