Skip to content

Instantly share code, notes, and snippets.

@schocco
schocco / gist:1762611
Created February 7, 2012 22:36
encode any string to html
# can be used to hide email addresses in the html source of Web sites from spiders
def html_encode(email):
'''
Takes a unicode string as only parameter and returns
a sequence of html encoded chars.
>>> html_encode(u"test@website.org")
'test@website.or&#103'
'''
@schocco
schocco / tex.py
Created December 29, 2011 00:36
Django filters, needed when creating LaTeX files with the django template language
# -*- coding: utf-8 -*-
'''
Django filters, needed when creating LaTeX files with the django template language
'''
from django.template.defaultfilters import stringfilter, register
from django.template.loader import render_to_string
@register.filter
@stringfilter
def brackets(value):