diff --git a/calibre-plugin/plugin-defaults.ini b/calibre-plugin/plugin-defaults.ini index e8888bf..d4606e9 100644 --- a/calibre-plugin/plugin-defaults.ini +++ b/calibre-plugin/plugin-defaults.ini @@ -266,12 +266,32 @@ keep_summary_html:true ## If set true, any style attributes on tags in the story HTML will be ## kept. Useful for keeping extra colors & formatting from original. +## DEPRECATED - use keep_html_attrs (or add_to_keep_html_attrs) instead. #keep_style_attr: false ## If set true, any title attributes on tags in the story HTML will be ## kept. Some sites(AO3) use Foreign language +## DEPRECATED - use keep_html_attrs (or add_to_keep_html_attrs) instead. #keep_title_attr: false +## Some attributes cause problems for EBook readers. By default, +## FanFicFare will remove all attributes except the ones specified +## from all tags. (The only exception is that tags will also +## keep src, alt and longdesc attributes.) +## 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 + +## Tags listed here will be replaced with . +## For example: underlined text becomes +## underlined text +## Note that the output_css should contain the class .u, .big, etc for +## the spans to be useful. +## This feature is for replacing old tags deprecated/removed in newer +## HTML and EPUB standards. +replace_tags_with_spans:u,big,small + ## 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. @@ -507,6 +527,8 @@ output_css: .smcap {font-variant: small-caps;} .u {text-decoration: underline;} .bold {font-weight: bold;} + .big { font-size: larger; } + .small { font-size: smaller; } [txt] ## Add URLs since there aren't links. @@ -587,6 +609,8 @@ output_css: .smcap {font-variant: small-caps;} .u {text-decoration: underline;} .bold {font-weight: bold;} + .big { font-size: larger; } + .small { font-size: smaller; } ## include images from img tags in the body and summary of ## stories. Images will be converted to jpg for size if possible. diff --git a/fanficfare/adapters/base_adapter.py b/fanficfare/adapters/base_adapter.py index dda319b..0cf6746 100644 --- a/fanficfare/adapters/base_adapter.py +++ b/fanficfare/adapters/base_adapter.py @@ -561,11 +561,13 @@ class BaseSiteAdapter(Configurable): if not fetch: fetch=self._fetchUrlRaw - acceptable_attributes = ['href','name','class','id'] + acceptable_attributes = self.getConfigList('keep_html_attrs',['href','name','class','id']) + if self.getConfig("keep_style_attr"): acceptable_attributes.append('style') if self.getConfig("keep_title_attr"): acceptable_attributes.append('title') + #print("include_images:"+self.getConfig('include_images')) if self.getConfig('include_images'): acceptable_attributes.extend(('src','alt','longdesc')) @@ -590,7 +592,7 @@ class BaseSiteAdapter(Configurable): # these are not acceptable strict XHTML. But we do already have # CSS classes of the same names defined if t and hasattr(t,'name') and t.name is not None: - if t.name in ('u'): + if t.name in self.getConfigList('replace_tags_with_spans',['u']): t['class']=t.name t.name='span' if t.name in ('center'): diff --git a/fanficfare/configurable.py b/fanficfare/configurable.py index 71bf187..bc7407d 100644 --- a/fanficfare/configurable.py +++ b/fanficfare/configurable.py @@ -111,6 +111,8 @@ def get_valid_list_entries(): 'authorId', 'authorUrl', 'lastupdate', + 'keep_html_attrs', + 'replace_tags_with_spans', ]) boollist=['true','false'] @@ -273,6 +275,8 @@ def get_valid_keywords(): 'join_string_authorHTML', 'keep_style_attr', 'keep_title_attr', + 'keep_html_attrs', + 'replace_tags_with_spans', 'keep_summary_html', 'logpage_end', 'logpage_entries', @@ -449,15 +453,18 @@ class Configuration(ConfigParser.SafeConfigParser): return val # split and strip each. - def get_config_list(self, sections, key): + def get_config_list(self, sections, key, default=[]): vlist = re.split(r'(?Foreign language +## DEPRECATED - use keep_html_attrs (or add_to_keep_html_attrs) instead. #keep_title_attr: false +## Some attributes cause problems for EBook readers. By default, +## FanFicFare will remove all attributes except the ones specified +## from all tags. (The only exception is that tags will also +## keep src, alt and longdesc attributes.) +## 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 + +## Tags listed here will be replaced with . +## For example: underlined text becomes +## underlined text +## Note that the output_css should contain the class .u, .big, etc for +## the spans to be useful. +## This feature is for replacing old tags deprecated/removed in newer +## HTML and EPUB standards. +replace_tags_with_spans:u,big,small + ## 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. @@ -511,6 +531,8 @@ output_css: .smcap {font-variant: small-caps;} .u {text-decoration: underline;} .bold {font-weight: bold;} + .big { font-size: larger; } + .small { font-size: smaller; } [txt] ## Add URLs since there aren't links. @@ -592,6 +614,8 @@ output_css: .smcap {font-variant: small-caps;} .u {text-decoration: underline;} .bold {font-weight: bold;} + .big { font-size: larger; } + .small { font-size: smaller; } ## include images from img tags in the body and summary of ## stories. Images will be converted to jpg for size if possible.