Skip to content

Instantly share code, notes, and snippets.

@albertsun
albertsun / linebreaks_wp.py
Created August 21, 2011 05:44
Python port of WordPress's wpautop filter
import re
from django import template
from django.utils.functional import allow_lazy
from django.template.defaultfilters import stringfilter
from django.utils.safestring import mark_safe, SafeData
from django.utils.encoding import force_unicode
from django.utils.html import escape
from django.utils.text import normalize_newlines
register = template.Library()