markdown wiki

discuss the markdown format

Python wrapper around the official Markdown.pl script

You will have to download the official Markdown.pl and keep it in the same dir as this script.

#!/usr/bin/env python
# encoding: utf-8
"""
untitled.py

This script is in the public domain

"""

import sys import getopt import os

help_message = ''' This is just a wrapper around Markdown.pl feed it any arguments you would to the perl version '''

class Usage(Exception): def __init__(self, msg): self.msg = msg

def main(argv=None): if argv is None: argv = sys.argv try: try: opts, args = getopt.getopt(argv[1:], "ho:v", ["help"]) except getopt.error, msg: raise Usage(msg)

    # option processing
    for option, value in opts:
        if option in ('-h', '--help';):
            raise Usage(help_message)

    (child_stdin, child_stdout_stderr) = os.popen4("./Markdown.pl %s" %(' '.join(argv[1:])))
    child_stdin.close()
    print child_stdout_stderr.read()

except Usage, err:
    print >> sys.stderr, sys.argv[0].split("/")[-1] + ": " + str(err.msg)
    print >> sys.stderr, "\t for help use --help"
    return 2

def markdown(text) : (child_stdin, child_stdout_stderr) = os.popen4('./Markdown.pl') child_stdin.write(text) child_stdin.close() return child_stdout_stderr.read()

if __name__ == "__main__": sys.exit(main())

Prom dress Prom gown Oil paintings