return None
assert response.charset == 'utf-8'
document = response.content.decode(response.charset)
- lxml.etree.fromstring(document)
+ print 'For url %s got page:\n%s' % (url, document)
+ lxml.etree.fromstring(document.replace('<br>', '<br/>'))
assert '<script>' not in document
return document
import bleach
def valid_html(value):
- return bleach.clean(value, bleach.ALLOWED_TAGS + ['p'])
+ return bleach.clean(value, bleach.ALLOWED_TAGS + ['p', 'br'])
class HTMLField(tinymce.models.HTMLField):
def pre_save(self, model_instance, add):
import re
from django.db import DatabaseError, transaction
+from django.utils.html import linebreaks
from quotes.models import QuoteTag, Quote, Work, Author
quote.tags.add(tag)
def paragraphize(text):
- paragraph = ""
- for line in text.splitlines():
- line = line.strip()
- if not line: continue
- paragraph += "<p>%s</p>" % line
- # rest of the HTML will be bleach.clean()'d
- return paragraph
+ text = text.strip()
+ return linebreaks(text)
def create_quote(quotetext, authorname, workname, tagline, resultcontext):
author = get_or_create_author(authorname, resultcontext)