Skip to content

Commit 932dc50

Browse files
committedMar 9, 2016
publication_list: Exclude the bibtex fields used by this extension in the bibtex file for download.
1 parent c32ee5c commit 932dc50

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed
 

‎tests/data/publication_list/test.bib

+2-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ @article{a2015
55
journal = {Great Journal},
66
volume = 1,
77
page = {1--10},
8-
fulltext = {/pdf/a2015.pdf}
8+
fulltext = {/pdf/a2015.pdf},
9+
abstract = {The abstract}
910
}
1011

1112
@book{b2010,

‎v7/publication_list/publication_list.py

+10-2
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131

3232
from nikola.plugin_categories import RestExtension
3333

34-
from pybtex.database import BibliographyData
34+
from pybtex.database import BibliographyData, Entry
3535
from pybtex.database.input.bibtex import Parser
3636
from pybtex.plugin import find_plugin
3737

@@ -117,7 +117,15 @@ def run(self):
117117
html += '<li class="publication">' + pub_html
118118

119119
extra_links = ""
120-
bib_data = BibliographyData(dict({label: entry})) # detail_page_dir may need it later
120+
bibtex_fields = dict(entry.fields)
121+
# Remove some fields for the publicly available BibTeX file since they are mostly only
122+
# used by this plugin.
123+
for field_to_remove in ('abstract', 'fulltext'):
124+
if field_to_remove in bibtex_fields:
125+
del bibtex_fields[field_to_remove]
126+
bibtex_entry = Entry(entry.type, bibtex_fields, entry.persons)
127+
# detail_page_dir may need bib_data later
128+
bib_data = BibliographyData(dict({label: bibtex_entry}))
121129
if bibtex_dir: # write bib files to bibtex_dir for downloading
122130
bib_link = '{}/{}.bib'.format(bibtex_dir, label)
123131
bib_data.to_file('/'.join([self.output_folder, bib_link]), 'bibtex')

0 commit comments

Comments
 (0)
Please sign in to comment.