diff --git a/calibre-plugin/plugin-defaults.ini b/calibre-plugin/plugin-defaults.ini index 6720a9ac..b9ed012a 100644 --- a/calibre-plugin/plugin-defaults.ini +++ b/calibre-plugin/plugin-defaults.ini @@ -312,7 +312,7 @@ keep_summary_html:true ## Example: To add 'style', 'title' and 'align' to the list to keep, ## in your personal.ini [defaults] put: ## add_to_keep_html_attrs:,style,title,align -keep_html_attrs:href,name,class,id +keep_html_attrs:href,name,class,id,colspan,rowspan ## Tags listed here will be replaced with . ## For example: underlined text becomes @@ -323,6 +323,12 @@ keep_html_attrs:href,name,class,id ## HTML and EPUB standards. replace_tags_with_spans:u,big,small +## By default, empty tags are removed as part of cleaning up the +## source HTML. However, a few tags should be kept even if empty. +## (Whitespace only, including   is considered empty.) This +## setting can adjust which tags are kept. +keep_empty_tags:p,td,th + ## If a chapter range was given, use this pattern for the book title. ## replace_metadata and include/exclude will be applied *after* this. ## Set to empty value to disable. diff --git a/fanficfare/adapters/base_adapter.py b/fanficfare/adapters/base_adapter.py index a21518fb..fc3c2135 100644 --- a/fanficfare/adapters/base_adapter.py +++ b/fanficfare/adapters/base_adapter.py @@ -456,7 +456,7 @@ class BaseSiteAdapter(Configurable): t['class']=t.name t.name='div' # removes paired, but empty non paragraph tags. - if t.name not in ('p') and t.string != None and len(t.string.strip()) == 0 : + if t.name not in self.getConfigList('keep_empty_tags',['p','td','th']) and t.string != None and len(t.string.strip()) == 0 : t.extract() # remove script tags cross the board. diff --git a/fanficfare/configurable.py b/fanficfare/configurable.py index 4f1a0057..e62e518e 100644 --- a/fanficfare/configurable.py +++ b/fanficfare/configurable.py @@ -372,6 +372,7 @@ def get_valid_keywords(): 'keep_title_attr', 'keep_html_attrs', 'replace_tags_with_spans', + 'keep_empty_tags', 'keep_summary_html', 'logpage_end', 'logpage_entries', diff --git a/fanficfare/defaults.ini b/fanficfare/defaults.ini index 59276c85..decea770 100644 --- a/fanficfare/defaults.ini +++ b/fanficfare/defaults.ini @@ -315,7 +315,7 @@ keep_summary_html:true ## Example: To add 'style', 'title' and 'align' to the list to keep, ## in your personal.ini [defaults] put: ## add_to_keep_html_attrs:,style,title,align -keep_html_attrs:href,name,class,id +keep_html_attrs:href,name,class,id,colspan,rowspan ## Tags listed here will be replaced with . ## For example: underlined text becomes @@ -326,6 +326,12 @@ keep_html_attrs:href,name,class,id ## HTML and EPUB standards. replace_tags_with_spans:u,big,small +## By default, empty tags are removed as part of cleaning up the +## source HTML. However, a few tags should be kept even if empty. +## (Whitespace only, including   is considered empty.) This +## setting can adjust which tags are kept. +keep_empty_tags:p,td,th + ## If a chapter range was given, use this pattern for the book title. ## replace_metadata and include/exclude will be applied *after* this. ## Set to empty value to disable.