diff --git a/patacrep/authors.py b/patacrep/authors.py index 3bdb6b9a..b902bb02 100644 --- a/patacrep/authors.py +++ b/patacrep/authors.py @@ -164,17 +164,21 @@ def processauthors(authors_string, after=None, ignore=None, sep=None): For example, we are processing: # processauthors( - # "Lyrics by William Blake (from Milton, 1808), - music by Hubert Parry (1916), - and sung by The Royal\ Choir~of~Nowhere - (just here to show you how processing is done)", + # [ + # " + # Lyrics by William Blake (from Milton, 1808), + # music by Hubert Parry (1916), + # and sung by The Royal\ Choir~of~Nowhere + # (just here to show you how processing is done) + # ", + # ], # after = ["by"], # ignore = ["anonymous"], # sep = [re.compile('^(.*) and (.*)$')], # ) - The "authors_string" string is processed as: + The "authors_string" is processed as: 1) First, parenthesis (and its content) are removed. # "Lyrics by William Blake, music by Hubert Parry, @@ -220,3 +224,10 @@ def processauthors(authors_string, after=None, ignore=None, sep=None): ignore) ) ] + +def process_listauthors(authors_list): + """Process a list of authors, and return the list of resulting authors.""" + return sum([ + processauthors(string) + for string in authors_list + ]) diff --git a/patacrep/index.py b/patacrep/index.py index 6a4300a2..8540d433 100644 --- a/patacrep/index.py +++ b/patacrep/index.py @@ -19,7 +19,6 @@ EOL = "\n" KEYWORD_PATTERN = re.compile(r"^%(\w+)\s?(.*)$", re.LOCALE) FIRST_LETTER_PATTERN = re.compile(r"^(?:\{?\\\w+\}?)*[^\w]*(\w)", re.LOCALE) - def process_sxd(filename): """Parse sxd file. @@ -162,7 +161,11 @@ class Index(object): def entry_to_str(self, key, entry): """Return the LaTeX code corresponding to the entry.""" - return (r'\idxentry{{{0}}}{{{1}}}' + EOL).format( + return r"""\idxentry{{ + {0} + }}{{ + {1} + }}""".format( self.key_to_str(key), r'\\'.join([self.ref_to_str(ref) for ref in entry]), ) @@ -182,13 +185,13 @@ class Index(object): ] string = r'\begin{idxblock}{' + letter + '}' + EOL for key in sorted(entries, key=sortkey): - string += self.entry_to_str(key, entries[key]['entries']) - string += r'\end{idxblock}' + EOL + string += " " + self.entry_to_str(key, entries[key]['entries']) + string += EOL + r'\end{idxblock}' return string def entries_to_str(self): """Return the LaTeX code corresponding to the index.""" string = "" for letter in sorted(self.data.keys()): - string += self.idxblock_to_str(letter, self.data[letter]) + string += self.idxblock_to_str(letter, self.data[letter]) + EOL return string diff --git a/patacrep/songs/latex/__init__.py b/patacrep/songs/latex/__init__.py index 2de16338..93fbccc7 100644 --- a/patacrep/songs/latex/__init__.py +++ b/patacrep/songs/latex/__init__.py @@ -16,7 +16,14 @@ class LatexSong(Song): def parse(self, content): """Parse content, and return the dictinory of song data.""" - return parse_song(content, self.fullpath) + with encoding.open_read(self.fullpath, encoding=self.encoding) as song: + self.data = parse_song(song.read(), self.fullpath) + self.titles = self.data['@titles'] + del self.data['@titles'] + self.languages = self.data['@languages'] + del self.data['@languages'] + self.authors = [self.data['by']] + del self.data['by'] def tex(self, output): """Return the LaTeX code rendering the song."""