James Rivett-Carnac avatar James Rivett-Carnac committed 525e854

restructured text, markdown and textile now colourize. test cases needed for markdown and textile. ReST passes

Comments (0)

Files changed (3)

diario/settings.py

 
 # ReST colours, set up the directives options
 if DIARIO_USE_COLOURS:
-    DIARIO_RST_INLINESTYLES = gettattr(settings, 'DIARIO_RST_INLINESTYLES',
+    DIARIO_RST_INLINESTYLES = getattr(settings, 'DIARIO_RST_INLINESTYLES',
                                        False)
 
     # Add name -> formatter pairs for every variant you want to use
-    DIARIO_RST_VARIANTS = gettattr(settings,'DIARIO_RST_VARIANTS',
+    DIARIO_RST_VARIANTS = getattr(settings,'DIARIO_RST_VARIANTS',
             {
             # 'linenos': HtmlFormatter(noclasses=DIARIO_RST_INLINESTYLES,
                                       # linenos=True),
-            }
+            })
 
 # django-tagging support
 try:

diario/tests/utils.py

 from django.test.utils import override_settings
 from diario.utils import rst_helper
 
-BASIC_RST = """
+BASIC_RST = u"""
 This is a Title
 ===============
 
 
 a paragraph"""
 
-BASIC_HTML = """
-<h1>This is a Title</h1>
-<ul>
+BASIC_HTML = u"""
+<div class="document" id="this-is-a-title">
+<h1 class="title">This is a Title</h1>
+<ul class="simple">
   <li>A List</li>
   <li>with 2 items</li>
 </ul>
-<p>a paragraph</p>"""
+<p>a paragraph</p>
+</div>"""
 
 #Now for that with sourcode
-CODE_RST = """
+CODE_RST = u"""
 This is a Title
 ===============
 
     #!/usr/bin/env python
     print "Hello World!"
 
-a pargraph"""
+a paragraph"""
 
-CODE_HTML = """
-<h1>This is a Title</h1>
-<pre>
-<code>
-#!/usr/bin/env python
-print "Hello World!"
-</code>
-</pre>
-<p>a paragraph</p>"""
+CODE_HTML = u"""
+<div class="document" id="this-is-a-title">
+<h1 class="title">This is a Title</h1>
+<div class="highlight"><pre><span class="c">#!/usr/bin/env python</span>
+<span class="k">print</span> <span class="s">&quot;Hello World!&quot;</span>
+</pre></div>
+<p>a paragraph</p>
+</div>"""
 
 from django.conf import settings
 

diario/utils/markup.py

         output = markdown(value)
     elif markup == 'rest':
         if DIARIO_USE_COLOURS:
-            from utils import rst_directive
+            from diario.utils import rst_helper
+            return rst_helper.html_body(value)
+        # No colours specified for Diario, so use built in (and it is up to
+        # the user to deal with hilighting
         from django.contrib.markup.templatetags.markup import restructuredtext
-        output = restructuredtext(value)
+        return restructuredtext(value)
     elif markup == 'textile':
+        # textile isn't as easy to extend, so you need to do it the messy
+        # way.
         from django.contrib.markup.templatetags.markup import textile
-        output = textile(value)
+        if DIARIO_USE_COLOURS:
+            return colourize(textile(output))
+        return textile(value)
     else:
         return value            # raw
-    if DIARIO_USE_COLOURS:
-        # Markdown uses the the codehilite extension and should
-        # return before getting here.
-        return colourize(output)
-    else:
-        return output
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.