def ajax_richtext_preview(request, obj_type, obj_ref, obj_revi): """ Ajax view to get an HTML preview of a raw content (in richtext syntax). GET paramerer: ``content`` raw content to be rendered This view returns a JSON response with one key, ``html``, the rendered content that can be included in a div element. """ content = request.GET["content"] if obj_type in ("create", "object"): return {"html": richtext(content, None)} obj = get_obj(obj_type, obj_ref, obj_revi, request.user) obj.check_readable() return {"html": richtext(content, obj)}
def richtext_filter(content, obj=None): """ This template filter takes a string value and passes it through the function specified by the RICHTEXT_FILTER setting. """ return richtext(content, obj)
def test_richtext_test(self): html = richtext("test", self.ctrl) self.assertHTMLEqual(html, "TEST")
def test_richtext_disabled(self): html = richtext(SIMPLE_TEXT, self.ctrl) self.assertHTMLEqual(html, u"<p>%s</p>" % SIMPLE_TEXT) self.assertTrue(isinstance(html, SafeData))
def test_richtext_default_settings(self): html = richtext(SIMPLE_TEXT, self.ctrl) self.assertHTMLEqual(html, u"<p><em>a</em> simple text</p>") self.assertTrue(isinstance(html, SafeData))