Created
November 3, 2011 20:34
-
-
Save OddBloke/1337709 to your computer and use it in GitHub Desktop.
PyBlosxom reST Preview
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from pprint import pformat | |
import sys | |
from docutils.core import publish_parts | |
content = [] | |
meta = {} | |
def _handle_line(line): | |
if not line.startswith('#'): | |
content.append(line) | |
else: | |
key, value = line.strip('#\n').split(' ', 1) | |
meta[key] = value | |
for line in open(sys.argv[1]): | |
_handle_line(line) | |
sys.stderr.write(pformat(meta)) | |
sys.stderr.write('\n') | |
title = content[0] | |
title_underline = "-" * len(title) | |
content.insert(1, title_underline + '\n') | |
print publish_parts(''.join(content), writer_name='html')['html_body'] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment