Jan's Markdown Preview

robert mcgonegal robert37 at gmail.com
Sat Nov 12 20:15:34 EST 2005


I couldn't find mention of this in the archives but on the BBEdit
list, Jan Erik Moström posted a great idea for using Apache's
ScriptAlias command to create a localhost "preview folder" which
preprocesses Markdown documents. This is especially handy for
Markdown documents created within BBEdit but it also works with any
web browser.

Has anyone created a Perl version of Jan's script?

Robert McGonegal



<http://blog.mostrom.pp.se/?p=63>

#! /usr/local/bin/python

import cgi
import cgitb
import sys
import os
import os.path

cgitb.enable()
sys.stderr = sys.stdout

sys.path.append( '/Users/jem/Documents/Codelib/Python/' )

import markdown
import metadoc

docfolder = '/Users/jem/Aktuellt/MarkdownPreview'
template = '/Users/jem/Documents/Templates/Web/lokalt/
markdownpreview.html'

print 'Content-type: text/html\n\n'

(vars, body ) = metadoc.documentData( os.path.join( docfolder,
os.environ.get('PATH_INFO')[1:] ) )
formatted = markdown.markdown( body )

f = open( template )
h = f.read()
f.close()

print h.replace( '##markdown##',formatted )


More information about the Markdown-Discuss mailing list