aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xbin/markdown_py5
-rw-r--r--docs/command_line.txt50
-rw-r--r--markdown/__init__.py2
-rw-r--r--markdown/__main__.py (renamed from markdown/commandline.py)20
4 files changed, 49 insertions, 28 deletions
diff --git a/bin/markdown_py b/bin/markdown_py
index 111b2c1..220c666 100755
--- a/bin/markdown_py
+++ b/bin/markdown_py
@@ -29,7 +29,6 @@ Copyright 2004 Manfred Stienstra (the original version)
License: BSD (see docs/LICENSE for details).
"""
-from markdown import commandline
-
if __name__ == '__main__':
- commandline.run()
+ from markdown.__main__ import run
+ run()
diff --git a/docs/command_line.txt b/docs/command_line.txt
index 0d7bab8..4ade8c1 100644
--- a/docs/command_line.txt
+++ b/docs/command_line.txt
@@ -6,24 +6,42 @@ included as well. While there are many other command line implementations
of Markdown, you may not have them installed, or you may prefer to use
Python-Markdown's various extensions.
+Generally, you will want to have the Markdown library fully installed on your
+system (``setup.py install`` or ``easy_install markdown``) to run the command
+line script.
+
+Assuming the `python` executable is on your system path, just run the following:
+
+ python -m markdown [options] [args]
+
+That will run the module as a script. Note that on older python versions (2.5
+and 2.6), you may need to specify the appropriate module:
+
+ python -m markdown.__main__ [options] [args]
+
+Use the `--help` option for available options:
+
+ python -m markdown --help
+
+If you are using Python 2.4 or you don't want to have to call the python
+executable directly, follow the instructions below:
+
Setup
-----
-Generally, you will want to have the may Markdown library fully installed on your
-system (``setup.py install`` or ``easy_install markdown``) to run the command line
-script. Upon installation, the ``markdown_py`` script will have been copied to
+Upon installation, the ``markdown_py`` script will have been copied to
your Python "Scripts" directory. Different systems require different methods to
ensure that any files in the Python "Scripts" directory are on your system
path.
* **Windows**:
- Assuming a default install of Python on Windows, your "Scripts" directory is
- most likely something like ``C:\\Python26\Scripts``. Verify the location of
- your "Scripts" directory and add it to you system path.
+ Assuming a default install of Python on Windows, your "Scripts" directory
+ is most likely something like ``C:\\Python26\Scripts``. Verify the location
+ of your "Scripts" directory and add it to you system path.
- Calling ``markdown_py`` from the command line will call the wrapper batch file
- ``markdown_py.bat`` in the "Scripts" directory created during install.
+ Calling ``markdown_py`` from the command line will call the wrapper batch
+ file ``markdown_py.bat`` in the "Scripts" directory created during install.
* __*nix__ (Linux, OSX, BSD, Unix, etc.):
@@ -42,16 +60,16 @@ path.
As an alternative, you could just ``cd`` into the directory which contains
the source distribution, and run it from there. However, remember that your
- markdown text files will not likely be in that directory, so it is much more
- convenient to have ``markdown_py`` on your path.
+ markdown text files will not likely be in that directory, so it is much
+ more convenient to have ``markdown_py`` on your path.
__Note:__ Python-Markdown uses "markdown_py" as a script name because
the Perl implementation has already taken the more obvious name "markdown".
-Additionally, the default Python configuration on some systems would cause a script
-named "markdown.py" to fail by importing itself rather than the markdown library.
-Therefore, the script has been named "markdown_py" as a compromise. If you prefer
-a different name for the script on your system, it is suggested that you create
-a symbolic link to `markdown_py` with your preferred name.
+Additionally, the default Python configuration on some systems would cause a
+script named "markdown.py" to fail by importing itself rather than the markdown
+library. Therefore, the script has been named "markdown_py" as a compromise. If
+you prefer a different name for the script on your system, it is suggested that
+you create a symbolic link to `markdown_py` with your preferred name.
Usage
-----
@@ -71,7 +89,7 @@ For a complete list of options, run
Using Extensions
----------------
-For an extension to be ran from the command line it must be provided in a module
+For an extension to be run from the command line it must be provided in a module
which should be in your python path (see [[writing_extensions]] for details).
It can then be invoked by the name of that module:
diff --git a/markdown/__init__.py b/markdown/__init__.py
index ce68e9a..0291891 100644
--- a/markdown/__init__.py
+++ b/markdown/__init__.py
@@ -412,5 +412,3 @@ def markdownFromFile(*args, **kwargs):
kwargs.get('output', None),
kwargs.get('encoding', None))
-
-
diff --git a/markdown/commandline.py b/markdown/__main__.py
index e2ef264..56afc10 100644
--- a/markdown/commandline.py
+++ b/markdown/__main__.py
@@ -25,27 +25,27 @@ def parse_options():
parser = optparse.OptionParser(usage=usage, description=desc, version=ver)
parser.add_option("-f", "--file", dest="filename", default=sys.stdout,
- help="write output to OUTPUT_FILE",
+ help="Write output to OUTPUT_FILE. Defaults to STDOUT.",
metavar="OUTPUT_FILE")
parser.add_option("-e", "--encoding", dest="encoding",
- help="encoding for input and output files",)
+ help="Encoding for input and output files.",)
parser.add_option("-q", "--quiet", default = CRITICAL,
action="store_const", const=CRITICAL+10, dest="verbose",
- help="suppress all messages")
+ help="Suppress all warnings.")
parser.add_option("-v", "--verbose",
action="store_const", const=INFO, dest="verbose",
- help="print info messages")
+ help="Print all warnings.")
parser.add_option("-s", "--safe", dest="safe", default=False,
metavar="SAFE_MODE",
help="'replace', 'remove' or 'escape' HTML tags in input")
parser.add_option("-o", "--output_format", dest="output_format",
default='xhtml1', metavar="OUTPUT_FORMAT",
- help="'xhtml1' (default) or 'html4'.")
+ help="'xhtml1' (default), 'html4' or 'html5'.")
parser.add_option("--noisy",
action="store_const", const=DEBUG, dest="verbose",
- help="print debug messages")
+ help="Print debug messages.")
parser.add_option("-x", "--extension", action="append", dest="extensions",
- help = "load extension EXTENSION", metavar="EXTENSION")
+ help = "Load extension EXTENSION.", metavar="EXTENSION")
parser.add_option("-n", "--no_lazy_ol", dest="lazy_ol",
action='store_false', default=True,
help="Observe number of first item of ordered lists.")
@@ -79,3 +79,9 @@ def run():
# Run
markdown.markdownFromFile(**options)
+
+if __name__ == '__main__':
+ # Support running module as a commandline command.
+ # Python 2.5 & 2.6 do: `python -m markdown.__main__ [options] [args]`.
+ # Python 2.7 & 3.x do: `python -m markdown [options] [args]`.
+ run()