Django

Code

root/django/trunk/tests/othertests/markup.py

Revision 467, 1.2 kB (checked in by jacob, 5 years ago)

Fixed #241 -- added django.contrib.markup app with markup templatetags for Textile, ReST and Markdown

Line 
1 # Quick tests for the markup templatetags (django.contrib.markup)
2 #
3 # Requires that all supported markup modules be installed
4 # (http://dealmeida.net/projects/textile/,
5 # http://www.freewisdom.org/projects/python-markdown,  and
6 # http://docutils.sf.net/)
7
8
9 from django.core.template import Template, Context
10 import django.contrib.markup.templatetags.markup # this registers the filters
11
12 # simple examples 'cause this isn't actually testing the markup, just
13 # that the filters work as advertised
14
15 textile_content = """Paragraph 1
16
17 Paragraph 2 with "quotes" and @code@"""
18
19 markdown_content = """Paragraph 1
20
21 ## An h2 with *italics*"""
22
23 rest_content = """Paragraph 1
24
25 Paragraph 2 with a link_
26
27 .. _link: http://www.example.com/"""
28
29 t = Template("""{{ textile_content|textile }}
30 ----
31 {{ markdown_content|markdown }}
32 ----
33 {{ rest_content|restructuredtext }}""")
34
35 rendered = t.render(Context(locals()))
36
37 assert rendered.strip() == """<p>Paragraph 1</p>
38
39 <p>Paragraph 2 with &#8220;quotes&#8221; and <code>code</code></p>
40 ----
41 <p>Paragraph 1</p><h2>An h2 with *italics*</h2>
42
43 ----
44 <p>Paragraph 1</p>
45 <p>Paragraph 2 with a <a class="reference" href="http://www.example.com/">link</a></p>"""
Note: See TracBrowser for help on using the browser.