File tree Expand file tree Collapse file tree 2 files changed +69
-12
lines changed Expand file tree Collapse file tree 2 files changed +69
-12
lines changed Original file line number Diff line number Diff line change 3535pip install markdown-it-py
3636```
3737
38- ## Basic usage
38+ ## Usage
39+
40+ ### Python API Usage
41+ Render markdown to HTML with markdown-it-py and a custom configuration
42+ with and without plugins and features:
3943
4044``` python
4145from markdown_it import MarkdownIt
@@ -66,17 +70,39 @@ tokens = md.parse(text)
6670html_text = md.render(text)
6771```
6872
69- Also you can use it from the command-line:
73+ ### Command-line Usage
74+ Render markdown to HTML with markdown-it-py from the
75+ command-line:
7076
7177``` console
72- $ markdown-it
73- markdown-it-py [version 0.1.0] (interactive)
74- Type Ctrl-D to complete input, or Ctrl-C to exit.
75- >>> > **hallo** there!
76- ...
77- <blockquote>
78- <p><strong>hallo</strong> there!</p>
79- </blockquote>
78+ usage: markdown-it [-h] [-v] [filenames [filenames ...]]
79+
80+ Parse one or more markdown files, convert each to HTML, and print to stdout
81+
82+ positional arguments:
83+ filenames specify an optional list of files to convert
84+
85+ optional arguments:
86+ -h, --help show this help message and exit
87+ -v, --version show program's version number and exit
88+
89+ Interactive:
90+
91+ $ markdown-it
92+ markdown-it-py [version 0.0.0] (interactive)
93+ Type Ctrl-D to complete input, or Ctrl-C to exit.
94+ >>> # Example
95+ ... > markdown *input*
96+ ...
97+ <h1>Example</h1>
98+ <blockquote>
99+ <p>markdown <em>input</em></p>
100+ </blockquote>
101+
102+ Batch:
103+
104+ $ markdown-it README.md README.footer.md > index.html
105+
80106```
81107
82108## References / Thanks
Original file line number Diff line number Diff line change 1- from argparse import ArgumentParser
1+ #!/usr/bin/env python
2+ """
3+ CLI interface to markdown-it-py
4+
5+ Parse one or more markdown files, convert each to HTML, and print to stdout.
6+ """
7+ import argparse
28import sys
39
410from markdown_it import __version__
@@ -59,7 +65,32 @@ def interactive(import_readline=False):
5965
6066def parse_args (args ):
6167 """Parse input CLI arguments."""
62- parser = ArgumentParser ()
68+ parser = argparse .ArgumentParser (
69+ description = "Parse one or more markdown files, "
70+ "convert each to HTML, and print to stdout" ,
71+ # NOTE: Remember to update README.md w/ the output of `markdown-it -h`
72+ epilog = (
73+ """
74+ Interactive:
75+
76+ $ markdown-it
77+ markdown-it-py [version 0.0.0] (interactive)
78+ Type Ctrl-D to complete input, or Ctrl-C to exit.
79+ >>> # Example
80+ ... > markdown *input*
81+ ...
82+ <h1>Example</h1>
83+ <blockquote>
84+ <p>markdown <em>input</em></p>
85+ </blockquote>
86+
87+ Batch:
88+
89+ $ markdown-it README.md README.footer.md > index.html
90+ """
91+ ),
92+ formatter_class = argparse .RawDescriptionHelpFormatter ,
93+ )
6394 parser .add_argument ("-v" , "--version" , action = "version" , version = version_str )
6495 parser .add_argument (
6596 "filenames" , nargs = "*" , help = "specify an optional list of files to convert"
You can’t perform that action at this time.
0 commit comments