| Crates.io | markdown-tool |
| lib.rs | markdown-tool |
| version | 2.1.1 |
| created_at | 2025-04-30 19:05:45.379078+00 |
| updated_at | 2025-12-11 13:00:46.306605+00 |
| description | A CLI utility for converting Markdown into AST and vice versa |
| homepage | https://github.com/johnlepikhin/markdown-tool#readme |
| repository | https://github.com/johnlepikhin/markdown-tool |
| max_upload_size | |
| id | 1655349 |
| size | 72,728 |
markdown-tool is a powerful command-line utility for converting and formatting
Markdown documents to various formats including HTML, LaTeX, and abstract syntax
tree (AST) representations.
Install via crates.io (requires Rust and Cargo):
cargo install markdown-tool
Alternatively, download pre-built packages:
Debian (.deb):
sudo dpkg -i markdown-tool_
## Usage
The tool uses a modern subcommand structure for better organization:
```text
Usage: markdown-tool <COMMAND>
Commands:
convert-to Convert to various output formats
format Format markdown files
help Print this message or the help of the given subcommand(s)
Options:
-h, --help Print help
-V, --version Print version
Convert documents between different formats:
Usage: markdown-tool convert-to [OPTIONS] <COMMAND>
Commands:
markdown Convert to Markdown format
html Convert to HTML format
latex Convert to LaTeX format
ast-json Convert to AST JSON format
ast-yaml Convert to AST YAML format
Options:
-f, --from <FROM> Input format: markdown, ast-json, ast-yaml [default: markdown]
-h, --help Print help
Format and beautify Markdown files:
Usage: markdown-tool format [OPTIONS] <FILES>...
Arguments:
<FILES>... Files to format
Options:
--width <WIDTH>
Width for markdown output formatting [default: 80]
--spaces-before-list-item <SPACES_BEFORE_LIST_ITEM>
Number of spaces before list items (0-3) [default: 1]
--no-empty-line-before-list
Disable empty line before lists
-n, --dry-run
Check if files need formatting without modifying them
-h, --help
Print help
Most common use cases:
Convert Markdown to HTML:
echo "# Hello World" | markdown-tool convert-to html
# Output: <h1>Hello World</h1>
Format Markdown files:
# Format single file
markdown-tool format README.md
# Format multiple files
markdown-tool format *.md
# Check if files need formatting (dry-run)
markdown-tool format --dry-run *.md
# or with short option
markdown-tool format -n *.md
| Format | Input | Output | Description |
|---|---|---|---|
| markdown | ✅ | ✅ | Standard Markdown text |
| html | ❌ | ✅ | HTML-formatted text |
| latex | ❌ | ✅ | LaTeX document format |
| ast-json | ✅ | ✅ | JSON-formatted abstract syntax tree |
| ast-yaml | ✅ | ✅ | YAML-formatted abstract syntax tree |
Convert Markdown to HTML (default input format):
markdown-tool convert-to html < input.md > output.html
Convert Markdown to LaTeX with custom formatting:
markdown-tool convert-to latex --table-style booktabs --code-style minted < input.md > output.tex
Convert Markdown to JSON AST:
markdown-tool convert-to ast-json < input.md > ast.json
Convert JSON AST back to Markdown:
markdown-tool convert-to -f ast-json markdown < ast.json > output.md
Convert YAML AST to Markdown with custom width:
markdown-tool convert-to -f ast-yaml markdown --width 120 < ast.yaml > output.md
Pretty-print Markdown with custom formatting:
markdown-tool convert-to markdown --width 100 --spaces-before-list-item 2 < unformatted.md > formatted.md
Format Markdown files in place with consistent styling:
# Format a single file
markdown-tool format document.md
# Format multiple files at once
markdown-tool format README.md CHANGELOG.md docs/*.md
# Format with custom options
markdown-tool format --width 120 --spaces-before-list-item 0 *.md
# Check if files need formatting without modifying them
markdown-tool format --dry-run src/**/*.md
# Exit code 1 if any files need formatting (useful for CI)
if markdown-tool format -n *.md; then
echo "All files are properly formatted"
else
echo "Some files need formatting"
markdown-tool format *.md
fi
markdown-tool convert-to markdown --width 120 --spaces-before-list-item 2 --no-empty-line-before-list
markdown-tool convert-to html --width 100 --anchor-prefix "section-"
markdown-tool convert-to latex --width 80 --table-style booktabs --code-style minted
Available LaTeX options:
tabular (default), longtabu, booktabsverbatim (default), listings, mintedDepending on the options used, you may need these LaTeX packages:
hyperref - for links (\href)graphicx - for images (\includegraphics)ulem - for strikethrough (\sout)booktabs - if using --table-style booktabslongtabu - if using --table-style longtabulistings - if using --code-style listingsminted - if using --code-style minted (requires Python + Pygments)Contributions, issues, and feature requests are welcome! Feel free to open an issue or submit a pull request on GitHub.
Dual-licensed under MIT. See LICENSE for details.