Commits

Anonymous committed 038e51e

support for original Python Markdown

Comments (0)

Files changed (3)

 from google.appengine.ext import db
 
 # bug on import; workaround in fix_path.py
-from lib import markdown2
+from lib.markdown2 import markdown
+from lib import markdown as markdown_original
 
-def md_to_html(content):
+def md2_to_html(content):
     ''' convert markdown to html
+        using markdown2
     '''
     if content:
-        content_html = markdown2.markdown(content, extras=['code-color'])
+        content_html = markdown(content, safe_mode=True, 
+            extras=['code-color'])
         return content_html
     else:
         return 0
 
-    
+def md_to_html(content):
+    ''' the original Python Markdown 
+        not currently using as of 2010-04-22
+    '''
+    # Setup Markdown with the code highlighter
+    md = markdown_original.Markdown(extensions=['codehilite'])
+
+    # convert markdown to html
+    if content != None:
+        content_html = md.convert(content)
+        return content_html
+    else:
+        return 0
+        
+        
 class BlogPost(db.Model):
     title = db.StringProperty()
     uri = db.StringProperty()
-    #teaser = db.TextProperty()
-    #teaser_html = db.TextProperty(default=None)
     content = db.TextProperty()
     content_html = db.TextProperty(default=None)
     tags = db.StringListProperty()
 
     def htmlify(self):
         self.content_html = md_to_html(self.content)
-        #self.teaser_html = md_to_html(self.teaser)
         
     def put(self):
         # Delete the cached tag list whenever created/updated
     
     def htmlify(self):
         ''' Apply markdown. '''
-        self.content_html = md_to_html(self.content)
+        self.content_html = md2_to_html(self.content)
         
     def put(self):
         ''' Delete cached tag list whenever created/updated. '''

templates/base.html

                 <a class="no_u" href="http://in-beta.appspot.com/feed"><img alt="RSS feed" src="/static/img/feed-icon-14x14.png" /></a>
             </h3>
             
-            <div id="content">{%block content%}{%endblock%}</div>
+            <div id="content">
+                {% block content %}{% endblock %}
+            </div>
 
             <div id="nav">
                 <p class="loud">

templates/index.html

 {% extends "base.html" %}
 
-{% block title %}
-    {{ title }}
-{% endblock %}
+{% block title %}{{ title }}{% endblock %}
 
 {% block content %}
 
         </a>
     </div>
     
+    {{ blog_post.content_html }}
+    
     <div>
-        {{ blog_post.content_html }}
         <a href="/post/{{ blog_post.key.id }}/{{ blog_post.uri }}">
         Add a comment</a>
     </div>
             updated: {{ blog_post.updated|date:"Y-m-d" }}
         {% endif %}
     </div>
-    <br />
 {% endfor %}
 
 {% if prev_page %}