source: remit/util/templatetags/latex.py @ dcaa9c0

client
Last change on this file since dcaa9c0 was dcaa9c0, checked in by Alex Dehnert <adehnert@…>, 17 years ago

Generate LaTeX source of all the vouchers

  • Property mode set to 100644
File size: 557 bytes
Line 
1#!/usr/bin/python
2# Inspired by and partially copied from ESP's backslash stuff
3
4from django import template
5register = template.Library()
6
7@register.filter
8def texescape(value):
9    value = unicode(value).strip()
10    special_backslash = '!!!12345623456!!!'
11    value = value.replace('\\', special_backslash)
12    for char in '&$%#_{}':
13        value = value.replace(char, '\\' + char)
14    value = value.replace('^', '\\textasciicircum')
15    value = value.replace('~', '$\sim$')
16    value = value.replace(special_backslash, '$\\backslash$')
17    return value
Note: See TracBrowser for help on using the repository browser.