from django.template import Library
from docutils.core import publish_parts

@register.filter
def rest(value, arg):
    arg = arg or 'html'
    parts = publish_parts(value, writer_name=arg)
    return parts['html_body']