Skip to content
Permalink
Browse files
publication_list: Add support for specifying multiple bibtex files.
Close #261
  • Loading branch information
xuhdev committed Mar 28, 2018
1 parent b5e14b7 commit 35303d90d060b53d87af1df212d3ac164a1e2540
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 12 deletions.
@@ -17,10 +17,3 @@ @book{b2010
publisher = {Nikola Tesla Publishing Group},
fulltext = {http://example.org/b2010.pdf}
}

@inproceedings{p2015,
title = {One Conference in 2015},
booktitle = {Nikola Tesla Conference},
author = {Nikola Tesla},
year = 2015
}
@@ -0,0 +1,6 @@
@inproceedings{p2015,
title = {One Conference in 2015},
booktitle = {Nikola Tesla Conference},
author = {Nikola Tesla},
year = 2015
}
@@ -43,8 +43,9 @@ def test_default(self):
'<a href="http://example.org/b2010.pdf">full text</a>.*</li>'
'</ul></div>'
)
self.sample = '.. publication_list:: tests/data/publication_list/' + \
'test.bib\n\t:highlight_author: Nikola Tesla'
self.sample = ('.. publication_list:: tests/data/publication_list/test.bib '
'tests/data/publication_list/test1.bib'
'\n\t:highlight_author: Nikola Tesla')
self.deps = 'tests/data/publication_list/test.bib'
self.basic_test()
assert re.search(
@@ -83,7 +83,12 @@ where `my-publications.bib` contains:
year = 2015
}

A live example is available [here](http://www.shudan.me/).
If you have multiple bibtex files, you can specify them in one line, separated
by spaces. For example:

... publication_list:: my-novels.bib my-research-papers.bib my-collections.bib

A live example of this plugin is available [here](http://www.shudan.me/).

## Customize Details Pages

@@ -25,6 +25,7 @@
# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

import os
import sys

from docutils import nodes
from docutils.parsers.rst import Directive, directives
@@ -76,6 +77,7 @@ class PublicationList(Directive):
"""
has_content = False
required_arguments = 1
optional_arguments = sys.maxsize
option_spec = {
'bibtex_dir': directives.unchanged,
'detail_page_dir': directives.unchanged,
@@ -95,9 +97,11 @@ def run(self):

parser = Parser()

all_entries = []
for a in self.arguments:
all_entries.extend(parser.parse_file(a).entries.items())
# Sort the publication entries by year reversed
data = sorted(parser.parse_file(self.arguments[0]).entries.items(),
key=lambda e: e[1].fields['year'], reverse=True)
data = sorted(all_entries, key=lambda e: e[1].fields['year'], reverse=True)

html = '<div class="publication-list">\n'
cur_year = None

0 comments on commit 35303d9

Please sign in to comment.