mdsf 0.1.2

Format markdown code snippets using your favorite code formatters
Documentation

mdsf

Format markdown code snippets using your favorite code formatters.

Installation

The latest version of mdsf can be downloaded directly from github.com/hougesen/mdsf/releases.

Cargo

Install using the published crate:

cargo install mdsf --locked

or directly from source:

git clone git@github.com:hougesen/mdsf.git

cargo install --path ./mdsf --bin mdsf

Usage

mdsf format <NAME_OF_FOLDER_OR_FOLDER>

Shell completions

Shell completions can be generated using mdsf completions <SHELL>.

Bash

Add the following to your .bashrc.

eval "$(mdsf completions bash)"

Bash

Add the following to your .zshrc.

eval "$(mdsf completions zsh)"

Fish

Add the following to ~/.config/fish/config.fish.

mdsf completions fish | source

PowerShell

Add the following to your PowerShell configuration (Can be found by running $PROFILE).

Invoke-Expression (&mdsf completions powershell)

Elvish

Add the following to ~/.elvish/rc.elv.

eval (mdsf completions elvish)

Configuration

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"]
}

Supported tools

[!NOTE] mdsf is not a package manager.

Only tools that are already installed will be used.

mdsf currently supports 146 tools.

Formatter Description
alejandra https://github.com/kamadorueda/alejandra
asmfmt https://github.com/klauspost/asmfmt
astyle https://astyle.sourceforge.net
auto-optional https://pypi.org/project/auto-optional/
autocorrect https://github.com/huacnlee/autocorrect
autoflake https://github.com/pycqa/autoflake
autopep8 https://pypi.org/project/autopep8/
beautysh https://pypi.org/project/beautysh/
bicep_format https://github.com/Azure/bicep
biome https://biomejs.dev
biome_check https://biomejs.dev
biome_lint https://biomejs.dev
black https://github.com/psf/black
blade-formatter https://github.com/shufo/blade-formatter
blue https://blue.readthedocs.io/en/latest/
bpfmt https://source.android.com/docs/setup/reference/androidbp
bsfmt https://github.com/rokucommunity/brighterscript-formatter
buf https://buf.build/docs/reference/cli/buf/format
buildifier https://github.com/bazelbuild/buildtools
cabal_format https://www.haskell.org/cabal/
caramel_fmt https://caramel.run
clang-format https://docs.kernel.org/process/clang-format.html
clang-tidy https://clang.llvm.org/extra/clang-tidy
cljstyle https://github.com/greglook/cljstyle
codespell https://github.com/codespell-project/codespell
crlfmt https://github.com/cockroachdb/crlfmt
crystal_format https://crystal-lang.org/
csharpier https://csharpier.com/
d2 https://d2lang.com/
dart_fix https://dart.dev/tools/dart-fix
dart_format https://dart.dev/tools/dart-format
dcm_fix https://dcm.dev/docs/cli/fix/
dcm_format https://dcm.dev/docs/cli/format/
deno_fmt https://docs.deno.com/runtime/manual/tools/formatter
deno_lint https://docs.deno.com/runtime/manual/tools/linter
dfmt https://github.com/dlang-community/dfmt
djlint https://www.djlint.com/
docformatter https://pypi.org/project/docformatter/
docstrfmt https://pypi.org/project/docstrfmt/
dotenv-linter https://github.com/dotenv-linter/dotenv-linter
dprint https://dprint.dev
efmt https://github.com/sile/efmt
elm-format https://github.com/avh4/elm-format
erb-formatter https://github.com/nebulab/erb-formatter
erlfmt https://github.com/WhatsApp/erlfmt
eslint https://eslint.org
fantomas https://github.com/fsprojects/fantomas
findent https://pypi.org/project/findent/
fish_indent https://fishshell.com/docs/current/cmds/fish_indent.html
fixjson https://github.com/rhysd/fixjson
fnlfmt https://git.sr.ht/~technomancy/fnlfmt
forge_fmt https://docs.rs/forge-fmt/latest/forge_fmt/
fourmolu https://hackage.haskell.org/package/fourmolu
fprettify https://github.com/fortran-lang/fprettify
gci https://github.com/daixiang0/gci
gdformat https://github.com/scony/godot-gdscript-toolkit
gersemi https://github.com/blankspruce/gersemi
gleam_format https://gleam.run/
gluon_fmt https://github.com/gluon-lang/gluon
gofmt https://pkg.go.dev/cmd/gofmt
gofumpt https://github.com/mvdan/gofumpt
goimports https://pkg.go.dev/golang.org/x/tools/cmd/goimports
goimports-reviser https://github.com/incu6us/goimports-reviser
golines https://github.com/segmentio/golines
google-java-format https://github.com/google/google-java-format
grain_format https://grain-lang.org
haml-lint https://github.com/sds/haml-lint
hindent https://hackage.haskell.org/package/hindent
htmlbeautifier https://github.com/threedaymonk/htmlbeautifier
imba_fmt https://github.com/imba/imba
isort https://pycqa.github.io/isort/
joker https://github.com/candid82/joker
jsona_format https://github.com/jsona/jsona
juliaformatter.jl https://github.com/domluna/JuliaFormatter.jl
just_fmt https://github.com/casey/just
kcl_fmt https://www.kcl-lang.io/docs/tools/cli/kcl/fmt
kdlfmt https://github.com/hougesen/kdlfmt
ktfmt https://github.com/facebook/ktfmt
ktlint https://github.com/pinterest/ktlint
leptosfmt https://github.com/bram209/leptosfmt
luaformatter https://github.com/Koihik/LuaFormatter
markdownlint https://github.com/davidanson/markdownlint
markuplint https://markuplint.dev
mdformat https://github.com/executablebooks/mdformat
misspell https://github.com/client9/misspell/
mix_format https://hexdocs.pm/mix/main/Mix.Tasks.Format.html
nickel_format https://nickel-lang.org
nimpretty https://github.com/nim-lang/nim
nixfmt https://github.com/serokell/nixfmt
nixpkgs-fmt https://github.com/nix-community/nixpkgs-fmt
npm-groovy-lint https://github.com/nvuillam/npm-groovy-lint
ocamlformat https://github.com/ocaml-ppx/ocamlformat
ocp-indent https://github.com/OCamlPro/ocp-indent
ormolu https://hackage.haskell.org/package/ormolu
oxlint https://oxc.rs
perltidy https://github.com/perltidy/perltidy
pg_format https://github.com/darold/pgFormatter
prettier https://github.com/prettier/prettier
puppet-lint https://github.com/puppetlabs/puppet-lint
purs-tidy https://github.com/natefaubion/purescript-tidy
pyink https://github.com/google/pyink
raco_fmt https://docs.racket-lang.org/fmt/
rescript_format https://rescript-lang.org/
roc_format https://github.com/roc-lang/roc
rstfmt https://github.com/dzhu/rstfmt
rubocop https://github.com/rubocop/rubocop
rubyfmt https://github.com/fables-tales/rubyfmt
ruff https://docs.astral.sh/ruff/formatter/
ruff_check https://docs.astral.sh/ruff/linter/
rufo https://github.com/ruby-formatter/rufo
rune_fmt https://github.com/rune-rs/rune
rustfmt https://github.com/rust-lang/rustfmt
rustywind https://github.com/avencera/rustywind
scalafmt https://github.com/scalameta/scalafmt
shfmt https://github.com/mvdan/sh
smlfmt https://github.com/shwestrick/smlfmt
snakefmt https://github.com/snakemake/snakefmt
sql-formatter https://github.com/sql-formatter-org/sql-formatter
sqlfluff https://github.com/sqlfluff/sqlfluff
sqlfmt https://sqlfmt.com
standardjs https://standardjs.com/
standardrb https://github.com/standardrb/standard
stylelint https://github.com/stylelint/stylelint
stylish-haskell https://github.com/haskell/stylish-haskell
stylua https://github.com/JohnnyMorganz/StyLua
swift-format https://github.com/apple/swift-format
swiftformat https://github.com/nicklockwood/SwiftFormat
taplo https://github.com/tamasfe/taplo
templ https://templ.guide
terraform_fmt https://www.terraform.io/docs/cli/commands/fmt.html
tofu_fmt https://opentofu.org/docs/cli/commands/fmt/
ts-standard https://github.com/standard/ts-standard
typos https://github.com/crate-ci/typos
uiua_fmt https://github.com/uiua-lang/uiua
usort https://github.com/facebook/usort
veryl_fmt https://github.com/veryl-lang/veryl
vlang_fmt https://vlang.io
xmlformat https://github.com/pamoller/xmlformatter
xmllint http://xmlsoft.org/xmllint.html
xo http://github.com/xojs/xo
yamlfix https://github.com/lyz-code/yamlfix
yamlfmt https://github.com/google/yamlfmt
yapf https://github.com/google/yapf
yew-fmt https://github.com/its-the-shrimp/yew-fmt
zigfmt https://ziglang.org/
zprint https://github.com/kkinnear/zprint

Acknowledgement

mdsf was inspired by the amazing neovim formatting plugin conform.nvim.

Alternatives to mdsf