CLI API
Command-line interface for markdown-validator.
Entry point: md-validate (defined in pyproject.toml).
Usage examples::
# Validate a single file
md-validate validate article.md --rules rules/tutorial.json
# Validate all .md files in a directory
md-validate validate docs/ --rules rules/tutorial.json --output results/
# Output JSON report
md-validate validate article.md --rules rules/tutorial.json --format json
# Verbose logging
md-validate --verbose validate article.md --rules rules/tutorial.json
cli(ctx: click.Context, verbose: bool, quiet: bool) -> None
Markdown Validator — rule-based document validation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ctx
|
Context
|
Click context object. |
required |
verbose
|
bool
|
Enable DEBUG-level output when True. |
required |
quiet
|
bool
|
Suppress INFO/DEBUG output when True. |
required |
Source code in markdown_validator/cli/main.py
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 | |
validate(ctx: click.Context, target: str, rules: str, output: str | None, output_format: str, workflows: bool) -> None
Validate TARGET (file or directory) against RULES.
TARGET may be a single .md file or a directory; when a directory is
given, all .md files within it are validated recursively.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ctx
|
Context
|
Click context object. |
required |
target
|
str
|
Path to the markdown file or directory. |
required |
rules
|
str
|
Path to the rule-set JSON file. |
required |
output
|
str | None
|
Optional output directory for persisting reports. |
required |
output_format
|
str
|
Format for report output ( |
required |
workflows
|
bool
|
Whether to execute workflow chains after rule evaluation. |
required |
Source code in markdown_validator/cli/main.py
69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 | |
Interactive REPL for developing and testing validation rules.
Provides a :class:ValidatorREPL class (cmd.Cmd subclass) that lets
developers probe documents interactively without writing a full rule set.
Start the REPL::
python -m markdown_validator.cli.repl
or via the CLI::
md-validate repl
ValidatorREPL
Bases: Cmd
Interactive REPL for exploring and testing validation rules.
Attributes:
| Name | Type | Description |
|---|---|---|
intro |
str
|
Introductory message displayed on startup. |
prompt |
str
|
Shell prompt string. |
Source code in markdown_validator/cli/repl.py
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 | |
do_EOF(line: str) -> bool
Exit on Ctrl-D.
Source code in markdown_validator/cli/repl.py
168 169 170 171 | |
do_dump(line: str) -> None
Dump document content. Options: metadata | html | raw
Usage: dump metadata dump html
Source code in markdown_validator/cli/repl.py
71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 | |
do_eval(line: str) -> None
Evaluate a rule JSON payload against the loaded document.
Usage: eval
Example: eval {"name":"check-h1","id":1,"type":"body","query":"/html/body/h1","flag":"count","operation":"==","value":"1"}
Source code in markdown_validator/cli/repl.py
117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 | |
do_exit(line: str) -> bool
Exit the REPL.
Source code in markdown_validator/cli/repl.py
164 165 166 | |
do_get(line: str) -> None
Get a metadata value by key.
Usage: get
Source code in markdown_validator/cli/repl.py
140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 | |
do_help(arg: str) -> None
Show help.
Source code in markdown_validator/cli/repl.py
177 178 179 | |
do_load(line: str) -> None
Load a Markdown file for subsequent queries.
Usage: load
Source code in markdown_validator/cli/repl.py
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 | |
do_query(line: str) -> None
Run an XPath query against the loaded document.
Usage: query
Flags: text (default), count, dom Example: query /html/body/h1 text query /html/body/h2 count
Source code in markdown_validator/cli/repl.py
92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 | |
do_quit(_line: str) -> bool
Exit the REPL.
Source code in markdown_validator/cli/repl.py
160 161 162 | |
main() -> None
Start the interactive REPL.
Source code in markdown_validator/cli/repl.py
182 183 184 185 186 187 188 189 | |