Skip to content

Commit

Permalink
Fix mixed-case keys in bibtex entries (cite completion)
Browse files Browse the repository at this point in the history
  • Loading branch information
msiniscalchi committed Jun 30, 2013
1 parent 21bdf91 commit 0210c56
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions latex_cite_completions.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ def get_cite_completions(view, point, autocompleting=False):

# This may speed things up
# So far this captures: the tag, and the THREE possible groups
multip = re.compile(r'\b(author|title|year|editor|journal|eprint)\s*=\s*(?:\{|"|\b)(.+?)(?:\}|"|\b)\s*,?\s*\Z',re.IGNORECASE)
multip = re.compile(r'\b(author|title|year|editor|journal|eprint)\s*=\s*(?:\{|"|\b)(.+?)(?:\}+|"|\b)\s*,?\s*\Z',re.IGNORECASE)

for bibfname in bib_files:
# # THIS IS NO LONGER NEEDED as find_bib_files() takes care of it
Expand Down Expand Up @@ -247,7 +247,7 @@ def get_cite_completions(view, point, autocompleting=False):
for line in bib:
line = line.strip()
# Let's get rid of irrelevant lines first
if line == "":
if line == "" or line[0] == '%':
continue
if line.lower()[0:8] == "@comment":
continue
Expand Down Expand Up @@ -282,12 +282,17 @@ def get_cite_completions(view, point, autocompleting=False):
# Note: we capture only the first line, but that's OK for our purposes
multip_match = multip.search(line)
if multip_match:
key = multip_match.group(1).decode('ascii','ignore')
key = multip_match.group(1).decode('ascii','ignore').lower()
value = multip_match.group(2).decode('ascii','ignore')
# print key,value
entry[key] = value
continue

# at the end, we are left with one bib entry
keywords.append(entry["keyword"])
titles.append(entry["title"])
years.append(entry["year"])
authors.append(entry["author"] or entry["editor"] or "????")
journals.append(entry["journal"] or entry["eprint"] or "????")

print "Found %d total bib entries" % (len(keywords),)

Expand Down

0 comments on commit 0210c56

Please sign in to comment.