| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -20,6 +20,8 @@ See the [Contributing Guide](contributing.md) for details. | |||
| 20 | 20 | performance for repeated inline patterns (#1619). | |
| 21 | 21 | * Officially support Python 3.15 and drop support for Python 3.10 | |
| 22 | 22 | * Walk backtick runs in `BacktickInlineProcessor` without a regex (#1620). | |
| 23 | + * Switch static site generator for documentation from MkDocs to Zensical | ||
| 24 | + (#1627, #1635, #1637, and #1638). | ||
| 23 | 25 | ||
| 24 | 26 | ### Fixed | |
| 25 | 27 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -20,22 +20,56 @@ Python-Markdown's command line script takes advantage of Python's `-m` flag. | |||
| 20 | 20 | Therefore, assuming the python executable is on your system path, use the | |
| 21 | 21 | following format: | |
| 22 | 22 | ||
| 23 | - ```bash | ||
| 23 | + ``` shell | ||
| 24 | 24 | python -m markdown [options] [args] | |
| 25 | 25 | ``` | |
| 26 | 26 | ||
| 27 | 27 | That will run the module as a script with the options and arguments provided. | |
| 28 | 28 | ||
| 29 | 29 | At its most basic usage, one would simply pass in a file name as the only argument: | |
| 30 | 30 | ||
| 31 | - ```bash | ||
| 31 | + ``` shell | ||
| 32 | 32 | python -m markdown input_file.txt | |
| 33 | 33 | ``` | |
| 34 | 34 | ||
| 35 | 35 | Use the `--help` option for a list of all available options and arguments: | |
| 36 | 36 | ||
| 37 | - ```bash | ||
| 38 | - python -m markdown --help | ||
| 37 | + ``` console | ||
| 38 | + $ python -m markdown --help | ||
| 39 | + Usage: __main__.py [options] [INPUTFILE] | ||
| 40 | + (STDIN is assumed if no INPUTFILE is given) | ||
| 41 | + | ||
| 42 | + A Python implementation of John Gruber's Markdown. https://python- | ||
| 43 | + markdown.github.io/ | ||
| 44 | + | ||
| 45 | + Options: | ||
| 46 | + --version show program's version number and exit | ||
| 47 | + -h, --help show this help message and exit | ||
| 48 | + -f OUTPUT_FILE, --file=OUTPUT_FILE | ||
| 49 | + Write output to OUTPUT_FILE. Defaults to STDOUT. | ||
| 50 | + -e ENCODING, --encoding=ENCODING | ||
| 51 | + Encoding for input and output files. | ||
| 52 | + -o OUTPUT_FORMAT, --output_format=OUTPUT_FORMAT | ||
| 53 | + Use output format 'xhtml' (default) or 'html'. | ||
| 54 | + -x EXTENSION, --extension=EXTENSION | ||
| 55 | + Load extension EXTENSION. | ||
| 56 | + -c CONFIG_FILE, --extension_configs=CONFIG_FILE | ||
| 57 | + Read extension configurations from CONFIG_FILE. | ||
| 58 | + CONFIG_FILE must be of JSON or YAML format. YAML | ||
| 59 | + format requires that a python YAML library be | ||
| 60 | + installed. The parsed JSON or YAML must result in a | ||
| 61 | + python dictionary which would be accepted by the | ||
| 62 | + 'extension_configs' keyword on the markdown.Markdown | ||
| 63 | + class. The extensions must also be loaded with the | ||
| 64 | + `--extension` option. | ||
| 65 | + -q, --quiet Suppress all warnings. | ||
| 66 | + -v, --verbose Print all warnings. | ||
| 67 | + --noisy Print debug messages. | ||
| 68 | + | ||
| 69 | + WARNING: The Python-Markdown library does NOT sanitize its HTML output. If you | ||
| 70 | + are processing Markdown input from an untrusted source, it is your | ||
| 71 | + responsibility to ensure that it is properly sanitized. For more information | ||
| 72 | + see <https://python-markdown.github.io/sanitization/>. | ||
| 39 | 73 | ``` | |
| 40 | 74 | ||
| 41 | 75 | !!! warning | |
@@ -50,14 +84,15 @@ python -m markdown --help | |||
| 50 | 84 | Piping input and output (on `STDIN` and `STDOUT`) is fully supported. | |
| 51 | 85 | For example: | |
| 52 | 86 | ||
| 53 | - ```bash | ||
| 87 | + ``` shell { title="Console" } | ||
| 54 | 88 | echo "Some **Markdown** text." | python -m markdown > output.html | |
| 55 | 89 | ``` | |
| 56 | 90 | ||
| 57 | - The above command would generate a file named `output.html` with the following content: | ||
| 58 | - ```html | ||
| 91 | + /// html | div.result | ||
| 92 | + ```html { title='output.html'} | ||
| 59 | 93 | <p>Some <strong>Markdown</strong> Text.</p> | |
| 60 | 94 | ``` | |
| 95 | + /// | ||
| 61 | 96 | ||
| 62 | 97 | As Python-Markdown only ever outputs HTML fragments (no `<html>`, `<head>`, | |
| 63 | 98 | and `<body>` tags), it is generally expected that the command line interface | |
@@ -67,20 +102,20 @@ otherwise empty `<html>`, `<head>`, and `<body>` tags, | |||
| 67 | 102 | [JustHTML](https://emilstenstrom.github.io/justhtml/) can do that with with | |
| 68 | 103 | a single command: | |
| 69 | 104 | ||
| 70 | - ```bash | ||
| 105 | + ``` shell { title="Console" } | ||
| 71 | 106 | echo "Some **Markdown** text." | python -m markdown | justhtml - --fragment > output.html | |
| 72 | 107 | ``` | |
| 73 | 108 | ||
| 74 | - The above command would generate a file named `output.html` with the following content: | ||
| 75 | - | ||
| 76 | - ```html | ||
| 109 | + /// html | div.result | ||
| 110 | + ```html { title='output.html'} | ||
| 77 | 111 | <html> | |
| 78 | 112 | <head></head> | |
| 79 | 113 | <body> | |
| 80 | 114 | <p>Some <strong>Markdown</strong> Text.</p> | |
| 81 | 115 | </body> | |
| 82 | 116 | </html> | |
| 83 | 117 | ``` | |
| 118 | + /// | ||
| 84 | 119 | ||
| 85 | 120 | If you don't need or want JustHTML's HTML sanitation, you can disable it with the | |
| 86 | 121 | `--unsafe` flag, although that is not recommended. See JustHTML's | |
@@ -98,27 +133,27 @@ notation to point to an extension | |||
| 98 | 133 | For example, to load an extension with the assigned entry point name `myext`, | |
| 99 | 134 | run the following command: | |
| 100 | 135 | ||
| 101 | - ```bash | ||
| 136 | + ``` shell | ||
| 102 | 137 | python -m markdown -x myext input.txt | |
| 103 | 138 | ``` | |
| 104 | 139 | ||
| 105 | 140 | And to load an extension with Python's dot notation: | |
| 106 | 141 | ||
| 107 | - ```bash | ||
| 142 | + ``` shell | ||
| 108 | 143 | python -m markdown -x path.to.module:MyExtClass input.txt | |
| 109 | 144 | ``` | |
| 110 | 145 | ||
| 111 | 146 | To load multiple extensions, specify an `-x` option for each extension: | |
| 112 | 147 | ||
| 113 | - ```bash | ||
| 148 | + ``` shell | ||
| 114 | 149 | python -m markdown -x myext -x path.to.module:MyExtClass input.txt | |
| 115 | 150 | ``` | |
| 116 | 151 | ||
| 117 | 152 | If the extension supports configuration options (see the documentation for the | |
| 118 | 153 | extension you are using to determine what settings it supports, if any), you | |
| 119 | 154 | can pass them in as well: | |
| 120 | 155 | ||
| 121 | - ```bash | ||
| 156 | + ``` shell | ||
| 122 | 157 | python -m markdown -x myext -c config.yml input.txt | |
| 123 | 158 | ``` | |
| 124 | 159 | ||
@@ -128,15 +163,15 @@ map to a Python Dictionary in the format required by the | |||
| 128 | 163 | [`extension_configs`][ec] keyword of the `markdown.Markdown` class. Therefore, | |
| 129 | 164 | the file `config.yaml` referenced in the above example might look like this: | |
| 130 | 165 | ||
| 131 | - ```yaml | ||
| 166 | + ``` yaml | ||
| 132 | 167 | myext: | |
| 133 | 168 | option1: 'value1' | |
| 134 | 169 | option2: True | |
| 135 | 170 | ``` | |
| 136 | 171 | ||
| 137 | 172 | Similarly, a JSON configuration file might look like this: | |
| 138 | 173 | ||
| 139 | - ```json | ||
| 174 | + ``` json | ||
| 140 | 175 | { | |
| 141 | 176 | "myext": | |
| 142 | 177 | { | |
@@ -216,18 +251,18 @@ path. | |||
| 216 | 251 | ||
| 217 | 252 | To use `markdown_py` from the command line, run it as | |
| 218 | 253 | ||
| 219 | - ```bash | ||
| 254 | + ``` shell | ||
| 220 | 255 | markdown_py input_file.txt | |
| 221 | 256 | ``` | |
| 222 | 257 | ||
| 223 | 258 | or | |
| 224 | 259 | ||
| 225 | - ```bash | ||
| 260 | + ``` shell | ||
| 226 | 261 | markdown_py input_file.txt > output_file.html | |
| 227 | 262 | ``` | |
| 228 | 263 | ||
| 229 | 264 | For a complete list of options, run | |
| 230 | 265 | ||
| 231 | - ```bash | ||
| 266 | + ``` shell | ||
| 232 | 267 | markdown_py --help | |
| 233 | 268 | ``` | |
| Back | FazBrowse Home | New Git URL |
0 commit comments