From cf866b48b1a08ab5b91ddbd511d69999ccc111d0 Mon Sep 17 00:00:00 2001 From: Louis Date: Fri, 8 Mar 2013 23:23:33 +0100 Subject: [PATCH] Autorisation de la commande \titleprefixword --- songbook-makeindex.py | 12 ++++++++++-- sortindex.py | 1 + 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/songbook-makeindex.py b/songbook-makeindex.py index 8509aa61..5a0b822b 100755 --- a/songbook-makeindex.py +++ b/songbook-makeindex.py @@ -18,7 +18,7 @@ import sortindex import locale # Pattern set to ignore latex command in title prefix -keywordPattern = re.compile(r"^%(\w+)\s?(\w*)") +keywordPattern = re.compile(r"^%(\w+)\s?(.*)$") firstLetterPattern = re.compile(r"^(?:\{?\\\w+\}?)*[^\w]*(\w)") class index: @@ -37,9 +37,17 @@ class index: self.keywords[key].append(word) def compileKeywords(self): - pass + self.prefix_patterns = [] + if 'prefix' in self.keywords: + for prefix in self.keywords['prefix']: + self.prefix_patterns.append(re.compile(r"^(%s)\b\s*(.*)$" % prefix)) def add(self, key, number, link): + for pattern in self.prefix_patterns: + match = pattern.match(key) + if match: + key = "%s (%s)" % (match.group(2), match.group(1)) + break # Only one match per key (first, key) = self.filter(key) if not self.data.has_key(first): self.data[first] = dict() diff --git a/sortindex.py b/sortindex.py index dd3d5d50..4333e5f2 100644 --- a/sortindex.py +++ b/sortindex.py @@ -28,6 +28,7 @@ replacePattern = { '~n' : 'ñ', "c C" : 'Ç', "c c" : 'ç', + "textquoteright" : "'", } def sortkey(value):