aboutsummaryrefslogtreecommitdiffstats
path: root/markdown.py
diff options
context:
space:
mode:
authorYuri Takhteyev <yuri@freewisdom.org>2008-10-13 00:33:08 -0700
committerYuri Takhteyev <yuri@freewisdom.org>2008-10-13 00:33:08 -0700
commit7741fe10831c5986866ce584211012d8fccbcd3f (patch)
treead8c1a69086daff501923688d2fabf258d57dfae /markdown.py
parentf76b532c21be5ef95dbfbcee52bda3760587b7fc (diff)
downloadmarkdown-7741fe10831c5986866ce584211012d8fccbcd3f.tar.gz
markdown-7741fe10831c5986866ce584211012d8fccbcd3f.tar.bz2
markdown-7741fe10831c5986866ce584211012d8fccbcd3f.zip
Fixed command-line handling.
Diffstat (limited to 'markdown.py')
-rwxr-xr-xmarkdown.py13
1 files changed, 5 insertions, 8 deletions
diff --git a/markdown.py b/markdown.py
index a41b1c8..e6acd05 100755
--- a/markdown.py
+++ b/markdown.py
@@ -1856,7 +1856,6 @@ class Markdown:
configs = extension_configs)
self.reset()
-
def registerExtensions(self, extensions, configs):
"""
Register extensions with this instance of Markdown.
@@ -1953,7 +1952,7 @@ class Markdown:
return xml.strip()
- def convertFile(input = None, output = None, encoding = None):
+ def convertFile(self, input = None, output = None, encoding = None):
"""Converts a markdown file and returns the HTML as a unicode string.
Decodes the file using the provided encoding (defaults to utf-8),
@@ -2041,7 +2040,6 @@ class Extension:
"""
pass
-
def load_extension(ext_name, configs = []):
"""Load extension by name, then return the module.
@@ -2091,6 +2089,7 @@ def load_extensions(ext_names):
extension = load_extension(ext_name)
if extension:
extensions.append(extension)
+ return extensions
# Extensions should use "markdown.etree" instead of "etree" (or do `from
# markdown import etree`). Do not import it by yourself.
@@ -2133,9 +2132,8 @@ def markdownFromFile(input = None,
extensions = [],
encoding = None,
safe = False):
-
- md = Markdown(extensions=load_extensions(extensions),
- safe_mode = safe_mode)
+ """Read markdown code from a file and write it to a file or a stream."""
+ md = Markdown(extensions=load_extensions(extensions), safe_mode = safe)
md.convertFile(input, output, encoding)
@@ -2174,7 +2172,7 @@ def parse_options():
return None, None
parser = optparse.OptionParser(usage="%prog INPUTFILE [options]")
- parser.add_option("-f", "--file", dest="filename",
+ parser.add_option("-f", "--file", dest="filename", default=sys.stdout,
help="write output to OUTPUT_FILE",
metavar="OUTPUT_FILE")
parser.add_option("-e", "--encoding", dest="encoding",
@@ -2211,7 +2209,6 @@ def parse_options():
'extensions': options.extensions,
'encoding': options.encoding }, options.verbose
-
def command_line_run():
"""Run Markdown from the command line."""