From 38b3b2a06da7770083a3d8229f40d9558390c1a5 Mon Sep 17 00:00:00 2001 From: Louis Date: Fri, 27 Jun 2014 15:14:44 +0200 Subject: [PATCH] It is now possible to decide how authors and titles are rendered in the indexes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit J'avais proposé cela il y a longtemps http://www.patacrep.com/forum/viewtopic.php?pid=669#p669 Mais cela a dû être perdu au cours des merge, branches, etc. --- patacrep/authors.py | 8 ++++---- patacrep/data/latex/patacrep.sty | 13 +++++++++++++ patacrep/index.py | 14 +++++++------- 3 files changed, 24 insertions(+), 11 deletions(-) diff --git a/patacrep/authors.py b/patacrep/authors.py index 32afb09a..769f2090 100644 --- a/patacrep/authors.py +++ b/patacrep/authors.py @@ -168,10 +168,10 @@ def processauthors_invert_names(authors_list): for author in authors_list: first, last = split_author_names(author) if first: - dest.append("%(last)s, %(first)s" % { - 'first': first.lstrip(), - 'last': last.lstrip(), - }) + dest.append(r"\indexauthor{{{first}}}{{{last}}}".format( + first=first.strip(), + last=last.strip(), + )) else: dest.append(last.lstrip()) return dest diff --git a/patacrep/data/latex/patacrep.sty b/patacrep/data/latex/patacrep.sty index d070ec2b..084e5866 100644 --- a/patacrep/data/latex/patacrep.sty +++ b/patacrep/data/latex/patacrep.sty @@ -402,4 +402,17 @@ } %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% Title and author rendering in the index + +% Usage: \indexauthor{First name}{Last name} +% Example: \indexauthor{Edgar Allan}{Poe} +\newcommand{\indexauthor}[2]{#2, #1} + +% Usage: \indextitle{Article}{Main part} +% Example: \indextitle{The}{Raven} +\newcommand{\indextitle}[2]{#2 (#1)} + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + \endinput diff --git a/patacrep/index.py b/patacrep/index.py index 1420272b..cd83668e 100755 --- a/patacrep/index.py +++ b/patacrep/index.py @@ -128,13 +128,13 @@ class Index(object): match = pattern.match(key.encode('utf-8')) if match: self._raw_add( - "{} ({})".format( - match.group(2) + match.group(3), - match.group(1) - ), - number, - link - ) + r"\indextitle{{{}}}{{{}}}".format( + match.group(1).strip(), + (match.group(2) + match.group(3)).strip(), + ), + number, + link + ) return self._raw_add(key, number, link)