Skip to content

Commit

Permalink
ci
Browse files Browse the repository at this point in the history
  • Loading branch information
rreece committed Oct 9, 2018
1 parent 1dd23b7 commit 46df7be
Showing 1 changed file with 18 additions and 14 deletions.
32 changes: 18 additions & 14 deletions markdown2bib.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,21 +42,22 @@

## local modules


#------------------------------------------------------------------------------
# globals
#------------------------------------------------------------------------------

# Note: \w = [a-zA-Z0-9_], \S = [^ \t\n\r\f\v]

# Baker, D.J. (2009). Against field interpretations of quantum field theory. *The British Journal for the Philosophy of Science*, 60(3), 585--609.
# Baker, D.J. (2015). The Philosophy of Quantum Field Theory. [Preprint]
rep_article_s = ''.join([r"(?P<author>([^(),.]+(,\s+\w\.(\s*\w\.)?(\s*\w\.)?)?(,?\s+(&\s+)?)?){1,6}(\s+et\s+al\.)?)[,.]?",
r"\s+\((?P<year>\d+)\)[,.]",
# r"\s+(?P<title>[^.?!\[\]]+[?!]?)[,.]?",
r"\s+(?P<title>[^*\[\]]+)[,.]?",
r"(?!\s+https?://)(\s+\*(?P<journal>[^*]+)\*[,.]?)",
r"(?!\s+<?https?://)(\s+\*(?P<journal>[^*]+)\*[,.]?)",
r"(\s+\*?(?P<volume>\d+)\*?(\((?P<number>\d+)\))?[,.]?)?",
r"(\s+(?P<pages>(P|p)?\d+-*\d*)[,.]?)?",
r"(\s+(Retrieved\s+from\s+)?(?P<url>https?://\S+)[,.]?)?",
r"(\s+(Retrieved\s+from\s+)?<?(?P<url>https?://[^ \t\n\r\f\v<>]+)>?[,.]?)?",
r"(\s+\[?(?P<note>[^\[\]]+)\]?\.?)?",
])
rep_article = re.compile(rep_article_s)
Expand All @@ -66,8 +67,8 @@
r"\s+\*(?P<title>[^*]+)\*[,.]?",
r"(\s+\((?P<edition>\d+)\w*\s+ed\.\)[,.]?)?",
r"(\s+\(((?P<editor>[^()]+),\s+Eds?\.)?(\s+&\s+)?((?P<translator>[^()]+),\s+Trans\.)?\)[,.]?)?",
r"((?!\s+https?://)\s+((?P<address>[^.:\[\]]+):\s+)?(?P<publisher>[^.\[\]]+))?[,.]?",
r"(\s+(Retrieved\s+from\s+)?(?P<url>https?://\S+)[,.]?)?",
r"((?!\s+<?https?://)\s+((?P<address>[^.:\[\]]+):\s+)?(?P<publisher>[^.\[\]]+))?[,.]?",
r"(\s+(Retrieved\s+from\s+)?<?(?P<url>https?://[^ \t\n\r\f\v<>]+)>?[,.]?)?",
r"(\s+\[?(?P<note>[^\[\]]+)\]?\.?)?",
])
rep_book = re.compile(rep_book_s)
Expand All @@ -77,25 +78,25 @@
r"\s+(?P<title>[^.?!\[\]]+[?!]?)[,.]?",
r"\s+In",
r"(\s+(?P<editor>[^()*]+)(\s+\(Eds?\.\))?[,.]?)?",
r"(?!\s+https?://)(\s+\*(?P<booktitle>[^*]+)\*[,.]?)",
r"(?!\s+<?https?://)(\s+\*(?P<booktitle>[^*]+)\*[,.]?)",
r"(\s+\(((?P<edition>\d+)\w*\s+ed\.,?\s*)?p+\.\s+(?P<pages>(P|p)?\d+-*\d*)\)[,.]?)?",
r"(?!\s+https?://)(\s+((?P<address>[^.:\[\]]+):\s+)?(?P<publisher>[^.\[\]]+))?[,.]?",
r"(\s+(Retrieved\s+from\s+)?(?P<url>https?://\S+)[,.]?)?",
r"(?!\s+<?https?://)(\s+((?P<address>[^.:\[\]]+):\s+)?(?P<publisher>[^.\[\]]+))?[,.]?",
r"(\s+(Retrieved\s+from\s+)?<?(?P<url>https?://[^ \t\n\r\f\v<>]+)>?[,.]?)?",
r"(\s+\[?(?P<note>[^\[\]]+)\]?\.?)?",
])
rep_incollection = re.compile(rep_incollection_s)
# ATLAS Collaboration. (2011). Updated Luminosity Determination in pp Collisions at $\sqrt{s}=7 TeV using the ATLAS Detector. ATLAS-CONF-2010-011. http://cdsweb.cern.ch/record/1334563
rep_misc_s = ''.join([r"(?P<author>([^(),.]+(,\s+\w\.(\s*\w\.)?(\s*\w\.)?)?(,?\s+(&\s+)?)?){1,6}(\s+et\s+al\.)?)[,.]?",
r"\s+\((?P<year>\d+)\)[,.]",
r"\s+(?P<title>[^.?!\[\]]+[?!]?)[,.]?",
r"((?!\s+https?://)\s+(?P<howpublished>[^.\[\]]+)[,.]?)?",
r"(\s+(Retrieved\s+from\s+)?(?P<url>https?://\S+)[,.]?)?",
r"((?!\s+<?https?://)\s+(?P<howpublished>[^.\[\]]+)[,.]?)?",
r"(\s+(Retrieved\s+from\s+)?<?(?P<url>https?://[^ \t\n\r\f\v<>]+)>?[,.]?)?",
r"(\s+\[?(?P<note>[^\[\]]+)\]?\.?)?",
])
rep_misc = re.compile(rep_misc_s)
rep_author_s = r"(?P<a1>[^(),.]+(,\s+\w\.(\s*\w\.)?(\s*\w\.)?)?)(?P<etal>\s+et\s+al)?(,?\s+(&\s+)?(?P<a2>[^(),.]+(,\s+\w\.(\s*\w\.)?(\s*\w\.)?)?))?(,?\s+(&\s+)?(?P<a3>[^(),.]+(,\s+\w\.(\s*\w\.)?(\s*\w\.)?)?))?(,?\s+(&\s+)?(?P<a4>[^(),.]+(,\s+\w\.(\s*\w\.)?(\s*\w\.)?)?))?(,?\s+(&\s+)?(?P<a5>[^(),.]+(,\s+\w\.(\s*\w\.)?(\s*\w\.)?)?))?(,?\s+(&\s+)?(?P<a6>[^(),.]+(,\s+\w\.(\s*\w\.)?(\s*\w\.)?)?))?"
rep_author = re.compile(rep_author_s)
rep_url_s = r"(https?://\S+)"
rep_url_s = r"<?(https?://[^ \t\n\r\f\v<>]+)>?"
rep_url = re.compile(rep_url_s)
rep_ascii_s = r'[a-zA-Z0-9_.\-]'
rep_ascii = re.compile(rep_ascii_s)
Expand Down Expand Up @@ -672,15 +673,18 @@ def clean_author(s):
if reo.group('etal'):
assert reo.group('a1')
# s = '%s and others' % reo.group('a1')
s = '%s \\emph{et al}.' % reo.group('a1')
# s = '%s \\emph{et al}.' % reo.group('a1')
s = '%s et al.' % reo.group('a1')
elif reo.group('a6'):
assert reo.group('a1')
# s = '%s and others' % reo.group('a1')
s = '%s \\emph{et al}.' % reo.group('a1')
# s = '%s \\emph{et al}.' % reo.group('a1')
s = '%s et al.' % reo.group('a1')
elif reo.group('a5'):
assert reo.group('a1')
# s = '%s and others' % reo.group('a1')
s = '%s \\emph{et al}.' % reo.group('a1')
# s = '%s \\emph{et al}.' % reo.group('a1')
s = '%s et al.' % reo.group('a1')
else:
authors = []
if reo.group('a1'):
Expand Down

0 comments on commit 46df7be

Please sign in to comment.