Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Another (more flexible) approach may be to convert the values to a bibtex-like value before sending them to your template. You'll probably need to do this anyway to escape some of the characters that bibtex/latex can't handle. Here's something similar I prepared earlier:</p> <pre><code>import datetime class BibTeXString(unicode): pass def bibtex_repr(obj): """ A version of the string repr method, that always outputs variables suitable for BibTeX. """ # If this has already been processed, it's ok if isinstance(obj, BibTeXString): return obj # Translate strings if isinstance(obj, basestring): value = unicode(obj).translate(CHAR_ESCAPES).strip() return BibTeXString('{%s}' % value) # Dates elif isinstance(obj, datetime.date): return BibTeXString('{%02d-%02d-%02d}' % (obj.year, obj.month, obj.day)) # Integers if isinstance(obj, (int, long)): return BibTeXString(str(obj)) else: return BibTeXString(repr(obj)) CHAR_ESCAPES = { ord(u'$'): u'\\$', ord(u'&amp;'): u'\\&amp;', ord(u'%'): u'\\%', ord(u'#'): u'\\#', ord(u'_'): u'\\_', ord(u'\u2018'): u'`', ord(u'\u2019'): u"'", ord(u'\u201c'): u"``", ord(u'\u201d'): u"''" , ord(u'\u2014'): u'---', ord(u'\u2013'): u'--', } </code></pre> <p>You could even use this as a template filter if you wanted, making your template look like:</p> <pre><code>@{{ pubentry.type }{, author = {% filter bibtex %}{% for author in pubentry.authors.all %}{{ author.first_name }} {{ author.middle_name }} {{ author.last_name }}{% if not forloop.last %} and {% endif %}{% endfor %}}{% endfilter %}, title = {{ pubentry.title|bibtex }}, journal = {{ pubentry.journal|bibtex }} } </code></pre> <p>But I would escape the content before it gets to the template, so that your template just needs to do this:</p> <pre><code>@{{ pubentry.type }{, {% for field in fields %}{{ field }}{% if not forloop.last %},{% endif %}{% endfor %} } </code></pre> <p>Or even leave out the template altogether at this stage. Good luck!</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload