commit 16081c9ed9e008ecdff6c2939af00ba209d01d87
parent 258a1234c01913a59752d58b33e1f3b16de5e60b
Author: Dan Callaghan <djc@djc.id.au>
Date: Sun, 8 Jun 2008 00:50:05 +1000
mini_markdown for titles
committer: Dan Callaghan <djc@djc.id.au>
--HG--
extra : convert_revision : 6de23e4e4b99c7fa5da7f5f20373c2ee15ae56ce
Diffstat:
2 files changed, 13 insertions(+), 6 deletions(-)
diff --git a/blog.py b/blog.py
@@ -1,7 +1,8 @@
-import os
+import os, re
from datetime import datetime
from itertools import chain
import markdown
+import genshi
import yaml
@@ -20,6 +21,12 @@ def cleanup_metadata(meta):
cleaned[k] = v
return cleaned
+def mini_markdown(s):
+ # XXX find a more efficient way to do this?
+ m = markdown.Markdown(extensions=['typography']).convert(s)
+ the_p, = re.match(u'<p>(.*)\n</p>', m).groups()
+ return genshi.Markup(the_p)
+
class EntryNotFoundError(ValueError): pass
@@ -94,9 +101,9 @@ class Entry(object):
self.raw = open(os.path.join(self.dir, 'content.txt'), 'r').read().decode('utf-8')
md = markdown.Markdown(extensions=['meta', 'typography'])
- self.body = md.convert(self.raw)
+ self.body = genshi.Markup(md.convert(self.raw))
self.metadata = cleanup_metadata(md.Meta)
- self.title = self.metadata['title']
+ self.title = mini_markdown(self.metadata['title'])
raw_cats = self.metadata.get('categories', '').strip()
if raw_cats:
@@ -127,7 +134,7 @@ class Entry(object):
class ReadingLogEntry(object):
def __init__(self, yaml_dict):
- self.title = yaml_dict['Title']
+ self.title = mini_markdown(yaml_dict['Title'])
self.author = yaml_dict['Author']
self.publication_date = self.modified_date = self.date = yaml_dict['Date']
self.url = yaml_dict.get('URL', None)
diff --git a/templates/_entry.xml b/templates/_entry.xml
@@ -23,7 +23,7 @@
</div>
<div class="entrybody">
- ${Markup(entry.body)}
+ ${entry.body}
<p py:if="entry.tags">
<img src="${BASE_URL}/static/images/tag_blue.png" alt="Tags:" />
<a py:for="tag in entry.tags" rel="tag" href="${BASE_URL}/+tags/${tag}">${tag}</a>
@@ -70,7 +70,7 @@
</div>
<div class="commenttext">
<div class="commentp">
- ${Markup(comment.body)}
+ ${comment.body}
</div>
</div>
</li>