Skip to content
Permalink
Browse files
publication_list: process some bibtex strings before passing them to …
…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 bf8989ee2dae78a1dc6e913299552efe8c55f0bd
Showing with 12 additions and 2 deletions.
  1. +12 −2 v7/publication_list/publication_list.py
@@ -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"
@@ -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'],

0 comments on commit bf8989e

Please sign in to comment.