Format markdown code snippets using your favorite code formatters.
mdsf 0.2.3
Format markdown code snippets using your favorite code formatters
Mads Hougesen <[email protected]>
Usage: mdsf <COMMAND>
Commands:
format Run formatters on input files
verify Verify files are formatted
init Create a new mdsf config
completions Generate shell completion
cache-prune Remove old caches
help Print this message or the help of the given subcommand(s)
Options:
-h, --help Print help
-V, --version Print version
The latest version of mdsf
can be downloaded directly from github.com/hougesen/mdsf/releases.
Install using the published crate:
cargo install mdsf --locked
or directly from source:
git clone [email protected]:hougesen/mdsf.git
cargo install --path ./mdsf --bin mdsf
mdsf format <NAME_OF_FOLDER_OR_FOLDER>
Run formatters on input files
Usage: mdsf format [OPTIONS] <PATH>
Arguments:
<PATH> Path to file or directory
Options:
--config <CONFIG> Path to config
--debug Log stdout and stderr of formatters
--log-level <LOG_LEVEL> [possible values: trace, debug, info, warn, error, off]
--threads <THREADS> Amount of threads to use. Defaults to 0 (auto)
--cache Only format changed codeblocks
-h, --help Print help
-V, --version Print version
mdsf verify <NAME_OF_FOLDER_OR_FOLDER>
Verify files are formatted
Usage: mdsf verify [OPTIONS] <PATH>
Arguments:
<PATH> Path to file or directory
Options:
--config <CONFIG> Path to config
--debug Log stdout and stderr of formatters
--log-level <LOG_LEVEL> [possible values: trace, debug, info, warn, error, off]
--threads <THREADS> Amount of threads to use. Defaults to 0 (auto)
-h, --help Print help
-V, --version Print version
The default configuration of mdsf
aims to as sane as possible. For that reason the default formatter for each language is the one most people have installed.
If you are interested in customizing which formatter is run, you can create a new mdsf
configuration file by running
mdsf init
mdsf
supports running multiple formatters on the save code snippet.
{
// Only run `ruff` on Python snippets,
"python": "ruff",
// Run `usort` on file and then `black`
"python": ["usort", "black"],
// Run `usort`, if that fails run `isort`, finally run `black`
"python": [["usort", "isort"], "black"]
}
Note
mdsf is not a package manager.
Only tools that are already installed will be used.
mdsf
currently supports 174 tools. Feel free to open an issue/pull-request if your favorite tool is missing! 😃
Shell completions can be generated using mdsf completions <SHELL>
.
Generate shell completion
Usage: mdsf completions <SHELL>
Arguments:
<SHELL> [possible values: bash, elvish, fish, powershell, zsh]
Options:
-h, --help Print help
-V, --version Print version
Add the following to your .bashrc
.
eval "$(mdsf completions bash)"
Add the following to your .zshrc
.
eval "$(mdsf completions zsh)"
Add the following to ~/.config/fish/config.fish
.
mdsf completions fish | source
Add the following to your PowerShell configuration (Can be found by running $PROFILE
).
Invoke-Expression (&mdsf completions powershell)
Add the following to ~/.elvish/rc.elv
.
eval (mdsf completions elvish)
mdsf was inspired by the amazing neovim formatting plugin conform.nvim.
- conform.nvim using
injected
mode. - mdformat.