#6 — Fixing crossreference on importing BibTex
by
Jan Drugowitsch
—
last modified
Jan 08, 2009 02:38 PM
| State | Unconfirmed |
|---|---|
| Version: | 0.8.0 |
| Area | Functionality |
| Issue type | Patch |
| Severity | Medium |
| Submitted by | Jan Drugowitsch |
| Submitted on | Feb 13, 2006 |
| Responsible |
—
|
| Target release: |
—
|
Currently, importing references with tools/parsers/bibtex.py does not support cross-references. Adding the following to the class BibtexParser might fix it. It's not very elegant, but it works.
def getEntries(self, source):
"""Overrides the base function as we also sort out the crossreferences here.
"""
entries = BibliographyParser.getEntries(self, source)
return self.substituteCrossrefs(entries)
def substituteCrossrefs(self, entries):
"""If an entry contains the field 'crossref', then the items of the
entry references to are added to the original entry, and the field
'crossref' is removed.
"""
for entry in entries:
# ignore entries without crossreferences
if not entry.has_key('crossref'):
continue
crossref = entry['crossref']
# find the entry that the crossreference refers to
crossref_entry = None
for ref_entry in entries:
if ref_entry['pid'] == crossref:
crossref_entry = ref_entry
break
# ignore no reference or self-reference
if not crossref_entry or crossref_entry == entry:
continue
# add all values of the crossref for which there is no item
# in the current entry, or the item is empty.
for k, v in crossref_entry.items():
if not entry.get(k, None):
entry[k] = v
# remove the cross reference
del entry['crossref']
return entries
Added by
Bernd Rellermeyer
on
May 12, 2007 02:53 PM
The patch does not work with the editor field. The result is a list of editors. See also issue #29.
It would be nice to implement a full crossref handling here, but this would certainly be more effort. The bibtex crossref handling makes really nice bibliography lists, and its a pity to lose this feature.
No responses can be added.
If you can, please log in before submitting a reaction.
