Skip to content

Commit

Permalink
publication_list: Exclude the bibtex fields used by this extension in…
Browse files Browse the repository at this point in the history
… the bibtex file for download.
  • Loading branch information
xuhdev committed Mar 9, 2016
1 parent c32ee5c commit 932dc50
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
3 changes: 2 additions & 1 deletion tests/data/publication_list/test.bib
Expand Up @@ -5,7 +5,8 @@ @article{a2015
journal = {Great Journal},
volume = 1,
page = {1--10},
fulltext = {/pdf/a2015.pdf}
fulltext = {/pdf/a2015.pdf},
abstract = {The abstract}
}

@book{b2010,
Expand Down
12 changes: 10 additions & 2 deletions v7/publication_list/publication_list.py
Expand Up @@ -31,7 +31,7 @@

from nikola.plugin_categories import RestExtension

from pybtex.database import BibliographyData
from pybtex.database import BibliographyData, Entry
from pybtex.database.input.bibtex import Parser
from pybtex.plugin import find_plugin

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

extra_links = ""
bib_data = BibliographyData(dict({label: entry})) # detail_page_dir may need it later
bibtex_fields = dict(entry.fields)
# Remove some fields for the publicly available BibTeX file since they are mostly only
# used by this plugin.
for field_to_remove in ('abstract', 'fulltext'):
if field_to_remove in bibtex_fields:
del bibtex_fields[field_to_remove]
bibtex_entry = Entry(entry.type, bibtex_fields, entry.persons)
# detail_page_dir may need bib_data later
bib_data = BibliographyData(dict({label: bibtex_entry}))
if bibtex_dir: # write bib files to bibtex_dir for downloading
bib_link = '{}/{}.bib'.format(bibtex_dir, label)
bib_data.to_file('/'.join([self.output_folder, bib_link]), 'bibtex')
Expand Down

0 comments on commit 932dc50

Please sign in to comment.