From 191e13bfadf698cdabd81b82bed71ef62b906e6f Mon Sep 17 00:00:00 2001 From: Jim Miller Date: Wed, 6 Jan 2016 17:39:31 -0600 Subject: [PATCH] Fix so ships_CHARS and sort_ships_splits work together. --- calibre-plugin/plugin-defaults.ini | 8 +++----- fanficfare/defaults.ini | 8 +++----- fanficfare/story.py | 7 ++++++- 3 files changed, 12 insertions(+), 11 deletions(-) diff --git a/calibre-plugin/plugin-defaults.ini b/calibre-plugin/plugin-defaults.ini index 4d99b24..a1283d8 100644 --- a/calibre-plugin/plugin-defaults.ini +++ b/calibre-plugin/plugin-defaults.ini @@ -380,11 +380,9 @@ sort_ships:false ## ships entry and then, after => the string to use to merge the parts ## back together. \s == blank space. ## Each part will have replace_metadata with key ships_CHARS applied. -## By default, sort_ships_splits:/=>/ -## Here's possible an example for AO3: -#sort_ships_splits: -# [ ]*/[ ]*=>/ -# [ ]*&[ ]*=>\s&\s +sort_ships_splits: + [ ]*/[ ]*=>/ + [ ]*&[ ]*=>\s&\s ## join_string_ options -- FanFicFare list entries are comma ## separated by default. You can use this to change that. For example, diff --git a/fanficfare/defaults.ini b/fanficfare/defaults.ini index 38e93e0..a7592f2 100644 --- a/fanficfare/defaults.ini +++ b/fanficfare/defaults.ini @@ -379,11 +379,9 @@ sort_ships:false ## ships entry and then, after => the string to use to merge the parts ## back together. \s == blank space. ## Each part will have replace_metadata with key ships_CHARS applied. -## By default, sort_ships_splits:/=>/ -## Here's possible an example for AO3: -#sort_ships_splits: -# [ ]*/[ ]*=>/ -# [ ]*&[ ]*=>\s&\s +sort_ships_splits: + [ ]*/[ ]*=>/ + [ ]*&[ ]*=>\s&\s ## join_string_ options -- FanFicFare list entries are comma ## separated by default. You can use this to change that. For example, diff --git a/fanficfare/story.py b/fanficfare/story.py index 4b26c14..25076f5 100644 --- a/fanficfare/story.py +++ b/fanficfare/story.py @@ -816,10 +816,15 @@ class Story(Configurable): for x in retlist: curlist = [] for y in re.split(splitre,x): + ## logger.debug("x:(%s) y:(%s)"%(x,y)) ## for SPLIT_META(\,) - if doreplacements: + if x != y and doreplacements: # doreplacements always true here (currently) y = self.doReplacements(y,'ships_CHARS',return_list=True) + else: + ## needs to be a list to extend curlist. + y=[x] curlist.extend(y) + ## logger.debug("curlist:%s"%(curlist,)) newretlist.append( splitmerge.join(sorted(curlist)) ) retlist = newretlist