mdsf-cli v0.8.1
mdsf
Format, and lint, markdown code snippets using your favorite tools.
Table of contents
- mdsf
Installation
The latest version of mdsf
can be downloaded directly from github.com/hougesen/mdsf/releases.
Linux & MacOS
curl --proto '=https' --tlsv1.2 -LsSf https://github.com/hougesen/mdsf/releases/latest/download/mdsf-installer.sh | sh
Windows
powershell -ExecutionPolicy ByPass -c "irm https://github.com/hougesen/mdsf/releases/latest/download/mdsf-installer.ps1 | iex"
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
If you do not have Cargo installed, you need to install it first.
npm/npx
You can install mdsf
using npm:
npm install -g mdsf-cli
mdsf format .
or run it directly using npx:
npx mdsf-cli format .
Homebrew
brew install hougesen/tap/mdsf
Conda
An unofficial (and unsupported) Conda package can be found at https://anaconda.org/conda-forge/mdsf.
conda install conda-forge::mdsf
Editor Support
Visual Studio Code
mdsf can be run using the VSCode extension.
[!NOTE] The mdsf VS Code extension does currently not support installing mdsf. Which means mdsf must be installed using other means.
Vim / NeoVim
conform.nvim
conform.nvim has native support for running mdsf.
local conform = require("conform")
conform.setup({
formatters_by_ft = {
markdown = { "mdsf" },
-- ...
},
-- ...
})
Usage
mdsf 0.8.1
Format, and lint, markdown code snippets using your favorite tools
Mads Hougesen <mads@mhouge.dk>
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 caches
help Print this message or the help of the given subcommand(s)
Options:
-h, --help Print help
-V, --version Print version
Formatting code
mdsf format file.md
Run formatters on input files
Usage: mdsf format [OPTIONS] [INPUT]...
Arguments:
[INPUT]...
Path to files and/or directories
Options:
--stdin
Read input from stdin and write output to stdout
--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
Cache results
--timeout <TIMEOUT>
Tool timeout in seconds
Defaults to no timeout
-h, --help
Print help (see a summary with '-h')
-V, --version
Print version
Verifying code
mdsf verify docs/
Verify files are formatted
Usage: mdsf verify [OPTIONS] [INPUT]...
Arguments:
[INPUT]...
Path to files and/or directories
Options:
--stdin
Read input from stdin and write output to stdout
--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).
--timeout <TIMEOUT>
Tool timeout in seconds
Defaults to no timeout
-h, --help
Print help (see a summary with '-h')
-V, --version
Print version
GitHub workflow examples
There are a lot of different ways to run mdsf
using GitHub actions.
The easiest way, in my opinion, is to use an action like taiki-e/install-action to install mdsf
.
After that you can run the binary like you would in your terminal.
[!NOTE] mdsf is not a package manager.
You must also install the tools you wish to use in your GitHub action.
Format and commit
This workflow formats your repository using mdsf
and then commits the changes.
name: mdsf
on: push
jobs:
format:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Install mdsf
uses: taiki-e/install-action@v2
with:
tool: mdsf
- name: Run mdsf
run: mdsf format --log-level warn .
- name: Commit changes
uses: EndBug/add-and-commit@v9
with:
message: "style: formatted markdown code blocks"
Verify
This workflow verifies your repository is formatted.
name: mdsf
on: push
jobs:
verify:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Install mdsf
uses: taiki-e/install-action@v2
with:
tool: mdsf
- name: Run mdsf
run: mdsf verify --log-level warn .
treefmt
Add the following to your treefmt.toml
to run mdsf using treefmt.
# treefmt.toml
[formatter.mdsf]
command = "mdsf"
options = ["format"]
includes = ["*.md"]
Configuration
The default configuration of mdsf
aims to as simple 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.
{
"languages": {
// Only run `ruff` on Python snippets,
"python": "ruff:format",
// Run `usort` on file and then `black`
"python": ["usort", "black"],
// Run `usort`, if that fails run `isort`, finally run `black`
"python": [["usort", "isort"], "black"],
// Formatters listed under "*" will be run on any snippet.
"*": ["typos"],
// Formatters listed under "_" will only be run when there is not formatter configured for the file type OR globally ("*").
"_": "prettier"
}
}
Tools
[!NOTE] mdsf is not a package manager.
Only tools that are already installed will be used.
mdsf
currently supports 282 tools. Feel free to open an issue/pull-request if your favorite tool/command is missing! 😃
Name | Description | Categories | Languages |
---|---|---|---|
actionlint | Static checker for GitHub Actions workflow files | linter | yaml |
air | R formatter and language server | formatter | r |
alejandra | The Uncompromising Nix Code Formatter | formatter | nix |
alex | Catch insensitive, inconsiderate writing | spell-check | markdown |
ameba | A static code analysis tool for Crystal | linter | crystal |
ansible-lint | ansible-lint checks playbooks for practices and behavior that could potentially be improved and can fix some of the most common ones for you | linter | ansible |
asmfmt | Go Assembler Formatter | formatter | go |
astyle | A Free, Fast, and Small Automatic Formatter for C, C++, C++/CLI, Objective-C, C#, and Java Source Code | formatter | c# , c++ , c , java , objective-c |
auto-optional | Adds the Optional type-hint to arguments where the default value is None | formatter | python |
autocorrect | A linter and formatter to help you to improve copywriting, correct spaces, words, and punctuations between CJK (Chinese, Japanese, Korean) | spell-check | |
autoflake | Removes unused imports and unused variables as reported by pyflakes | linter | python |
autopep8 | A tool that automatically formats Python code to conform to the PEP 8 style guid | formatter | python |
bashate | Code style enforcement for bash programs | formatter | bash |
beancount-black | Opinionated code formatter, just like Python's black code formatter but for Beancount | formatter | beancount |
beautysh | A Bash beautifier for the masses | formatter | bash , shell |
bibtex-tidy | Cleaner and Formatter for BibTeX files | formatter | bibtex |
bicep | Bicep is a declarative language for describing and deploying Azure resources | formatter | bicep |
biome | One toolchain for your web project | formatter , linter | javascript , json , typescript , vue |
black | The uncompromising Python code formatter | formatter | python |
blade-formatter | An opinionated blade template formatter for Laravel that respects readability | formatter | blade , laravel , php |
blue | The slightly less uncompromising Python code formatter | formatter | python |
bpfmt | A formatter for Blueprint files | formatter | blueprint |
brittany | A Haskell source code formatter | formatter | haskell |
brunette | A best practice Python code formatter | formatter | python |
bsfmt | A code formatter for BrightScript and BrighterScript | formatter | brighterscript , brightscript |
bslint | A linter for BrightScript and BrighterScript | linter | brightscript , brightscripter |
buf | The best way of working with Protocol Buffers | formatter | protobuf |
buildifier | A bazel BUILD file formatter and | formatter | bazel |
cabal-fmt | An experiment of formatting .cabal files | formatter | cabal |
cabal-prettify | Prettify your Cabal package configuration files | formatter | cabal |
cabal | Cabal is a system for building and packaging Haskell libraries and programs | formatter | cabal |
caddy | Formats or prettifies a Caddyfile | formatter | caddy |
caramel | Formatter for the Caramel programming language | formatter | caramel |
cfn-lint | CloudFormation Linter | linter | cloudformation , json , yaml |
checkmake | Experimental linter/analyzer for Makefiles | linter | makefile |
clang-format | A tool to format C/C++/Java/JavaScript/JSON/Objective-C/Protobuf/C# code | formatter | c# , c++ , c , java , javascript , json , objective-c , protobuf |
clang-tidy | clang-tidy is a clang-based C++ “linter” tool | linter | c++ |
clj-kondo | Static analyzer and linter for Clojure code that sparks joy | linter | clojure , clojurescript |
cljfmt | A tool for formatting Clojure code | formatter | clojure |
cljstyle | A tool for formatting Clojure code | formatter | clojure |
cmake-format | cmake-format can format your listfiles nicely so that they don't look like crap | formatter | cmake |
cmake-lint | Lint CMake files | linter | cmake |
codeql | Format queries and libraries with CodeQL | formatter | codeql |
codespell | Check code for common misspellings | spell-check | |
coffeelint | Lint your CoffeeScript | linter | coffeescript |
cppcheck | Cppcheck is a static analysis tool for C/C++ code | linter | c++ , c |
cpplint | Static code checker for C++ | linter | c++ |
crlfmt | Formatter for CockroachDB's additions to the Go style guide | formatter | go |
crystal | Tools for the Crystal programming language | formatter | crystal |
csharpier | An Opinionated Code Formatter for C# | formatter | c# |
css-beautify | A css formatter | formatter | css |
csscomb | CSS coding style formatter | formatter | css |
csslint | Automated linting of Cascading Stylesheets | linter | css |
curlylint | Experimental HTML templates linting for Jinja, Nunjucks, Django templates, Twig, Liquid | linter | django , html , jinja , liquid , nunjucks , twig |
d2 | A modern language that turns text to diagrams | formatter | d2 |
dart | Formatter and linter for Dart | formatter , linter | dart , flutter |
dcm | Code Quality Tool for Flutter Developers | formatter , linter | dart , flutter |
deadnix | Scan Nix files for dead code | linter | nix |
deno | Formatter and linter for JavaScript and TypeScript | formatter , linter | javascript , json , typescript |
dfmt | Dfmt is a formatter for D source code | formatter | d |
dhall | Format Dhall files | formatter | dhall |
djade | A Django template formatter | formatter | django , python |
djlint | Lint & Format HTML Templates | formatter , linter | handlebars , html , jinja , mustache , nunjucks , twig |
docformatter | Formats docstrings to follow PEP 257 | formatter | python |
dockfmt | Dockerfile format and parser. Like gofmt but for Dockerfiles | formatter | docker |
docstrfmt | A formatter for Sphinx flavored reStructuredText | formatter | python , restructuredtext , sphinx |
doctoc | Generates table of contents for markdown files | formatter | markdown |
dotenv-linter | Lightning-fast linter for .env files | linter | env |
dprint | A pluggable and configurable code formatting platform written in Rust | formatter | |
dscanner | Swiss-army knife for D source code | linter | d |
easy-coding-standard | The Easiest way to add coding standard to your PHP project | formatter , linter | php |
efmt | Erlang code formatter | formatter | erlang |
elm-format | elm-format formats Elm source code according to a standard set of rules based on the official Elm Style Guide | formatter | elm |
erb-formatter | Format ERB files with speed and precision | formatter | erb , ruby |
erlfmt | An automated code formatter for Erlang | formatter | erlang |
eslint | Find and fix problems in your JavaScript code | linter | javascript , typescript |
fantomas | FSharp source code formatter | formatter | fsharp |
fish_indent | Fish indenter and prettifier | formatter | fish |
fixjson | JSON Fixer for Humans using (relaxed) JSON5 | formatter , linter | json5 , json |
floskell | Floskell is a flexible Haskell source code pretty printer | formatter | haskell |
fnlfmt | A formatter for Fennel code | formatter | fennel |
forge | A Solidity formatter | formatter | solidity |
fortitude | A Fortran linter, written in Rust | linter | |
fortran-linter | A simple fortran syntax checker, including automatic fixing of the code | formatter , linter | fortran |
fourmolu | A formatter for Haskell source code | formatter | haskell |
fprettify | Auto-formatter for modern Fortran source code | formatter | fortran |
futhark | Code formatter for the furhark programming language | formatter | futhark |
gci | GCI, a tool that control golang package import order and make it always deterministic | formatter | go |
gdformat | GDScript formatter | formatter | gdscript |
gdlint | GDScript linter | linter | gdscript |
gersemi | A formatter to make your CMake code the real treasure | formatter | cmake |
gleam | Format Gleam source code | formatter | gleam |
gluon | Code formatting for the gluon programming language | formatter | gluon |
gofmt | Gofmt formats Go programs | formatter | go |
gofumpt | A stricter gofmt | formatter | go |
goimports-reviser | Right imports sorting & code formatting tool (goimports alternative) | formatter | go |
goimports | goimports updates your Go import lines, adding missing ones and removing unreferenced ones | formatter | go |
golines | A golang formatter that fixes long lines | formatter | go |
google-java-format | Reformats Java source code to comply with Google Java Style | formatter | java |
gospel | Misspelled word linter for Go comments, string literals and embedded files | spell-check | go |
grain | Code formatter for the Grain programming language | formatter | grain |
hadolint | Dockerfile linter, validate inline bash, written in Haskell | linter | dockerfile |
haml-lint | Tool for writing clean and consistent HAML | linter | haml |
hclfmt | Formatter for hcl files | formatter | hcl |
hfmt | Format Haskell programs. Inspired by the gofmt utility | formatter | haskell |
hindent | Extensible Haskell pretty printer | formatter | haskell |
hlint | Haskell source code suggestions | linter | haskell |
html-beautify | A html formatter | formatter | html |
htmlbeautifier | A normaliser/beautifier for HTML that also understands embedded Ruby. Ideal for tidying up Rails templates | formatter | erb , html , ruby |
htmlhint | The static code analysis tool you need for your HTML | linter | html |
hurlfmt | Formatter for hurl files | formatter | hurl |
imba | A formatter for Imba | formatter | imba |
inko | Code formatter for the inko programming language | formatter | inko |
isort | A Python utility to sort imports | formatter | python |
joker | Small Clojure interpreter, linter and formatter | formatter , linter | clojure |
jq | JSON processor | formatter | json |
jqfmt | like gofmt, but for jq | formatter | jq |
js-beautify | A JavaScript formatter | formatter | javascript |
json5format | JSON5 (a.k.a., JSON for Humans) formatter that preserves contextual comments | formatter | json5 , json |
jsona | JSONA linter and formatter | formatter , linter | jsona |
jsonlint | A JSON parser and validator with a CLI | formatter , linter | json |
jsonnet-lint | Linter for jsonnet files | linter | jsonnet |
jsonnetfmt | Formatter for automatically fixing jsonnet stylistic problems | formatter | jsonnet |
jsonpp | A fast command line JSON pretty printer | formatter | json |
juliaformatter.jl | An opinionated code formatter for Julia. Plot twist - the opinion is your own | formatter | julia |
just | A formatter for justfiles | formatter | just |
kcl | KCL Format tool supports reformatting KCL files to the standard code style | formatter | kcl |
kdlfmt | A formatter for kdl documents | formatter | kdl |
kdoc-formatter | Reformats Kotlin KDoc comments, reflowing text and other cleanup | formatter | kotlin |
ktfmt | program that reformats Kotlin source code to comply with the common community standard for Kotlin code conventions | formatter | kotlin |
ktlint | An anti-bikeshedding Kotlin linter with built-in formatter | linter | kotlin |
kulala-fmt | An opinionated .http and .rest file linter and formatter | formatter | http |
leptosfmt | A formatter for the leptos view! macro | formatter | rust |
liquidsoap-prettier | Prettier plugin for liquidsoap script | formatter | liquidsoap |
luacheck | A tool for linting and static analysis of Lua code | formatter | lua |
luaformatter | Code formatter for Lua | formatter | lua |
mado | A fast Markdown linter written in Rust | linter | markdown |
mago | A fast linter and formatter for PHP | formatter , linter | php |
markdownfmt | Like gofmt, but for Markdown | formatter | markdown |
markdownlint-cli2 | A fast, flexible, configuration-based command-line interface for linting Markdown/CommonMark files with the markdownlint library | linter | markdown |
markdownlint | A Node.js style checker and lint tool for Markdown/CommonMark files | linter | markdown |
markuplint | An HTML linter for all markup developers | linter | html |
3 months ago
3 months ago
4 months ago
4 months ago
5 months ago
6 months ago
5 months ago
7 months ago
3 months ago
3 months ago
4 months ago
4 months ago
4 months ago
8 months ago
8 months ago
9 months ago
9 months ago
9 months ago