Skip to content

Commit

Permalink
publication_list: process some bibtex strings before passing them to …
Browse files Browse the repository at this point in the history
…the template.

Double quotes and single quotes need to be processed, which are
different in BibTeX than HTML.
  • Loading branch information
xuhdev committed Feb 15, 2016
1 parent 99ea083 commit bf8989e
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions v7/publication_list/publication_list.py
Expand Up @@ -36,6 +36,16 @@
from pybtex.plugin import find_plugin


def process_bibtex_string(s):
"""
Process the BibTeX string to make it compatible with HTML.
"""
# replace the special quote characters with the HTML version
s = s.replace("``", "“").replace("''", "”")
s = s.replace("`", "‘").replace("'", "’")
return s


class Plugin(RestExtension):

name = "publication_list"
Expand Down Expand Up @@ -125,8 +135,8 @@ def run(self):
html += ' [<a href="{}">abstract and details</a>]'.format(
self.site.config['BASE_URL'] + page_url)
context = {
'title': entry.fields['title'],
'abstract': entry.fields['abstract'] if 'abstract' in entry.fields else '',
'title': process_bibtex_string(entry.fields['title']),
'abstract': process_bibtex_string(entry.fields['abstract']) if 'abstract' in entry.fields else '',
'bibtex': bib_data.to_string('bibtex'),
'bibtex_link': '/' + bib_link if bibtex_dir else '',
'default_lang': self.site.config['DEFAULT_LANG'],
Expand Down

0 comments on commit bf8989e

Please sign in to comment.