Last change
on this file was
f298bd7,
checked in by Alex Dehnert <adehnert@…>, 11 years ago
|
Allow using a virtualenv's Python
Rather than starting each script with #!/usr/bin/python, we change to
#!/usr/bin/env python, to allow using Python's supplied by a virtualenv we're
running in.
|
-
Property mode set to
100644
|
File size:
539 bytes
|
Line | |
---|
1 | # Inspired by and partially copied from ESP's backslash stuff |
---|
2 | |
---|
3 | from django import template |
---|
4 | register = template.Library() |
---|
5 | |
---|
6 | @register.filter |
---|
7 | def texescape(value): |
---|
8 | value = unicode(value).strip() |
---|
9 | special_backslash = '!!!12345623456!!!' |
---|
10 | value = value.replace('\\', special_backslash) |
---|
11 | for char in '&$%#_{}': |
---|
12 | value = value.replace(char, '\\' + char) |
---|
13 | value = value.replace('^', '\\textasciicircum') |
---|
14 | value = value.replace('~', '$\sim$') |
---|
15 | value = value.replace(special_backslash, '$\\backslash$') |
---|
16 | return value |
---|
Note: See
TracBrowser
for help on using the repository browser.