Skip to content

Commit

Permalink
added support for multiple institution affiliations per author
Browse files Browse the repository at this point in the history
  • Loading branch information
bmcfee committed Jun 11, 2015
1 parent 922d00d commit c72a9e9
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 13 deletions.
6 changes: 6 additions & 0 deletions papers/00_vanderwalt/00_vanderwalt.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
:author: Gaius Caesar
:email: [email protected]
:institution: Senate House, S.P.Q.R.
:institution: Egyptian Embassy, S.P.Q.R.

:author: Mark Anthony
:email: [email protected]
Expand All @@ -9,6 +10,11 @@
:author: Jarrod Millman
:email: [email protected]
:institution: Egyptian Embassy, S.P.Q.R.
:institution: Yet another place, S.P.Q.R.

:author: Brutus
:email: [email protected]
:institution: Unaffiliated

:video: http://www.youtube.com/watch?v=dhRUe-gz690

Expand Down
30 changes: 17 additions & 13 deletions publisher/writer/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ def __init__(self, *args, **kwargs):

self.author_names = []
self.author_institutions = []
self.author_institution_map = dict()
self.author_emails = []
self.paper_title = ''
self.abstract_text = []
Expand All @@ -56,6 +57,7 @@ def depart_docinfo(self, node):

def visit_author(self, node):
self.author_names.append(self.encode(node.astext()))
self.author_institution_map[self.author_names[-1]] = []
raise nodes.SkipNode

def depart_author(self, node):
Expand All @@ -78,6 +80,7 @@ def visit_field_body(self, node):
self.author_emails.append(text)
elif self.current_field == 'institution':
self.author_institutions.append(text)
self.author_institution_map[self.author_names[-1]].append(text)
elif self.current_field == 'video':
self.video_url = text

Expand All @@ -95,8 +98,9 @@ def depart_document(self, node):

# build map: institution -> (author1, author2)
institution_authors = OrderedDict()
for auth, inst in zip(self.author_names, self.author_institutions):
institution_authors.setdefault(inst, []).append(auth)
for auth in self.author_institution_map:
for inst in self.author_institution_map[auth]:
institution_authors.setdefault(inst, []).append(auth)

def footmark(n):
"""Insert footmark #n. Footmark 1 is reserved for
Expand All @@ -118,13 +122,12 @@ def footmark(n):
title = self.paper_title
authors = []
institutions_mentioned = set()
for n, (auth, inst) in enumerate(zip(self.author_names,
self.author_institutions)):
for n, auth in enumerate(self.author_names):
# Corresponding author
if n == 0:
authors += [r'%(author)s$^{%(footmark)s}$' % \
{'author': auth,
'footmark': ''.join(footmark(1)) + ''.join(institute_footmark[inst])}]
'footmark': ''.join(footmark(1)) + ''.join([''.join(institute_footmark[inst]) for inst in self.author_institution_map[auth]])}]

fm_counter, fm = footmark(1)
authors[-1] += corresponding_auth_template % \
Expand All @@ -135,16 +138,17 @@ def footmark(n):
else:
authors += [r'%(author)s$^{%(footmark)s}$' %
{'author': auth,
'footmark': ''.join(institute_footmark[inst])}]
'footmark': ''.join([''.join(institute_footmark[inst]) for inst in self.author_institution_map[auth]])}]

if not inst in institutions_mentioned:
fm_counter, fm = institute_footmark[inst]
authors[-1] += r'%(footmark_counter)s\thanks{%(footmark)s %(institution)s}' % \
{'footmark_counter': fm_counter,
'footmark': fm,
'institution': inst}
for inst in self.author_institution_map[auth]:
if not inst in institutions_mentioned:
fm_counter, fm = institute_footmark[inst]
authors[-1] += r'%(footmark_counter)s\thanks{%(footmark)s %(institution)s}' % \
{'footmark_counter': fm_counter,
'footmark': fm,
'institution': inst}

institutions_mentioned.add(inst)
institutions_mentioned.add(inst)


## Add copyright
Expand Down

0 comments on commit c72a9e9

Please sign in to comment.