Parse input CLI arguments.
(args: Sequence[str] | None)
| 80 | |
| 81 | |
| 82 | def parse_args(args: Sequence[str] | None) -> argparse.Namespace: |
| 83 | """Parse input CLI arguments.""" |
| 84 | parser = argparse.ArgumentParser( |
| 85 | description="Parse one or more markdown files, " |
| 86 | "convert each to HTML, and print to stdout", |
| 87 | # NOTE: Remember to update README.md w/ the output of `markdown-it -h` |
| 88 | epilog=( |
| 89 | f""" |
| 90 | Interactive: |
| 91 | |
| 92 | $ markdown-it |
| 93 | markdown-it-py [version {__version__}] (interactive) |
| 94 | Type Ctrl-D to complete input, or Ctrl-C to exit. |
| 95 | >>> # Example |
| 96 | ... > markdown *input* |
| 97 | ... |
| 98 | <h1>Example</h1> |
| 99 | <blockquote> |
| 100 | <p>markdown <em>input</em></p> |
| 101 | </blockquote> |
| 102 | |
| 103 | Batch: |
| 104 | |
| 105 | $ markdown-it README.md README.footer.md > index.html |
| 106 | """ |
| 107 | ), |
| 108 | formatter_class=argparse.RawDescriptionHelpFormatter, |
| 109 | ) |
| 110 | parser.add_argument("-v", "--version", action="version", version=version_str) |
| 111 | parser.add_argument( |
| 112 | "--stdin", action="store_true", help="read Markdown from standard input" |
| 113 | ) |
| 114 | parser.add_argument( |
| 115 | "filenames", nargs="*", help="specify an optional list of files to convert" |
| 116 | ) |
| 117 | return parser.parse_args(args) |
| 118 | |
| 119 | |
| 120 | def print_heading() -> None: |
no outgoing calls
no test coverage detected
searching dependent graphs…