mdsf-cli
v0.3.2
Published
Format markdown code snippets using your favorite code formatters
Downloads
97
Maintainers
Readme
mdsf
Format markdown code snippets using your favorite code formatters.
Table of contents
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 [email protected]: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
Usage
mdsf 0.3.2
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
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:
--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
Verifying code
mdsf verify docs/
Verify files are formatted
Usage: mdsf verify [OPTIONS] [INPUT]...
Arguments:
[INPUT]... Path to files and/or directories
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
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.
{
"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 210 tools. Feel free to open an issue/pull-request if your favorite tool/command is missing! 😃
| Name | Description | Categories | Languages |
| --------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------- | --------------------- | ------------------------------------------------------------------------- |
| alejandra | The Uncompromising Nix Code Formatter | formatter
| nix
|
| ameba | A static code analysis tool for Crystal | linter
| crystal
|
| 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) | autocorrection
| |
| 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
|
| 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
|
| 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++
|
| cljfmt | A tool for formatting Clojure code | formatter
| clojure
|
| cljstyle | A tool for formatting Clojure code | formatter
| clojure
|
| codespell | Check code for common misspellings | autocorrection
| |
| 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
|
| d2 | Formatter for the d2 language | formatter
| d2
|
| dart | Formatter and linter for Dart | formatter
, linter
| dart
, flutter
|
| dcm | Code Quality Tool for Flutter Developers | formatter
, linter
| dart
, flutter
|
| 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
| Sphinx
, python
, reStructuredText
|
| 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
| |
| 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
|
| fourmolu | A formatter for Haskell source code | formatter
| haskell
|
| fprettify | Auto-formatter for modern Fortran source code | formatter
| fortran
|
| gci | GCI, a tool that control golang package import order and make it always deterministic | formatter
| go
|
| gdformat | GDScript linter | formatter
| 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
|
| grain | Code formatter for the Grain programming language | formatter
| grain
|
| haml-lint | Tool for writing clean and consistent HAML | linter
| haml
|
| 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
|
| imba | A formatter for Imba | formatter
| imba
|
| isort | A Python utility to sort imports | formatter
| python
|
| joker | Small Clojure interpreter, linter and formatter | formatter
, linter
| clojure
|
| 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
|
| jsonnetfmt | Formatter for automatically fixing jsonnet stylistic problems | formatter
| jsonnet
|
| 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 🐼 files linter 💄 and formatter ⚡. | formatter
| http
|
| leptosfmt | A formatter for the leptos view! macro | formatter
| rust
|
| liquidsoap-prettier | Prettier plugin for liquidsoap script | formatter
| liquidsoap
|
| luaformatter | Code formatter for Lua | formatter
| lua
|
| 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
|
| mdformat | CommonMark compliant Markdown formatter | formatter
| markdwon
|
| mdslw | Prepare your markdown for easy diff'ing! | formatter
| markdown
|
| misspell | Correct commonly misspelled English words in source files | autocorrection
| |
| mix | Code formatter for Elixir | formatter
| elixir
|
| mojo | Formats Mojo source files | formatter
| mojo
|
| nginxbeautifier | Format and beautify nginx config files | formatter
| nginx
|
| nginxfmt | nginx config file formatter/beautifier written in Python with no additional dependencies | formatter
| nginx
|
| nickel | Better configuration for less | formatter
| nickel
|
| nimpretty | Code formatter for the Nim programming language | formatter
| nim
|
| nixfmt | The official (but not yet stable) formatter for Nix code | formatter
| nix
|
| nixpkgs-fmt | Nix code formatter for nixpkgs | formatter
| nix
|
| nph | An opinionated code formatter for Nim | formatter
| nim
|
| npm-groovy-lint | Lint, format and auto-fix your Groovy / Jenkinsfile / Gradle files | formatter
, linter
| groovy
|
| ocamlformat | Auto-formatter for OCaml code | formatter
| ocaml
|
| ocp-indent | Indentation tool for OCaml | formatter
| ocaml
|
| opa | Format Rego source files | formatter
| rego
|
| ormolu | A formatter for Haskell source code | formatter
| haskell
|
| oxlint | Oxlint is designed to catch erroneous or useless code without requiring any configurations by default | linter
| javascript
, typescript
|
| packer | Packer is used to format HCL2 configuration files | formatter
| hcl
|
| perltidy | Perl::Tidy, a source code formatter for Perl | formatter
| perl
|
| pg_format | A PostgreSQL SQL syntax beautifier | formatter
| sql
|
| php-cs-fixer | A tool to automatically fix PHP Coding Standards issues | formatter
, linter
| php
|
| phpcbf | PHP Code Beautifier and Fixer fixes violations of a defined coding standard | formatter
| php
|
| phpinsights | Instant PHP quality checks from your console | linter
| php
|
| pint | Laravel Pint is an opinionated PHP code style fixer for minimalists | formatter
, linter
| php
|
| prettier | Prettier is an opinionated code formatter | formatter
| css
, html
, javascript
, json
, typescript
|
| pretty-php | The opinionated PHP code formatter | formatter
| php
|
| prettypst | Formatter for Typst | formatter
| typst
|
| prisma | Commands for interacting with the prisma ORM | formatter
| prisma
|
| protolint | A pluggable linter and fixer to enforce Protocol Buffer style and conventions | linter
| protobuf
|
| ptop | Free Pascal source formatter | formatter
| pascal
|
| puppet-lint | Check that your Puppet manifests conform to the style guide | linter
| puppet
|
| purs-tidy | PureScript code formatter | formatter
| purescript
|
| purty | PureScript pretty-printer | formatter
| purescript
|
| pycln | A formatter for finding and removing unused import statements | formatter
| python
|
| pyink | Pyink is a Python formatter, forked from Black with a few different formatting behaviors | formatter
| python
|
| pyment | Format and convert Python docstrings and generates patches | formatter
| python
|
| qmlfmt | qmlfmt - command line application that formats QML files | formatter
| qml
|
| raco | An extensible code formatter for Racket | formatter
| racket
|
| refmt | refmt stands by Reason Formatter and it formats Reason programs, is a parser and pretty-printer for Reason | formatter
| reason
|
| reformat-gherkin | Reformat-gherkin automatically formats Gherkin files | formatter
| gherkin
|
| reorder-python-imports | Rewrites source to reorder python imports | formatter
| python
|
| rescript | Formatter for ReScript | formatter
| rescript
|
| roc | Tools for the roc programming language | formatter
| roc
|
| rstfmt | A formatter for reStructuredText | formatter
| restructuredtext
|
| rubocop | A Ruby static code analyzer and formatter, based on the community Ruby style guide | formatter
, linter
| ruby
|
| rubyfmt | Ruby Autoformatter | formatter
| ruby
|
| ruff | An extremely fast Python linter and code formatter, written in Rust | formatter
, linter
| python
|
| rufo | The Ruby Formatter | formatter
| ruby
|
| rune | Tools for the Rune programming language | formatter
| rune
|
| rustfmt | The official code formatter for Rust | formatter
| rust
|
| rustywind | CLI for organizing Tailwind CSS classes | formatter
| html
|
| scalafmt | Code formatter for Scala | formatter
| scala
|
| scalariform | Scala source code formatter | formatter
| scala
|
| shellharden | The corrective bash syntax highlighter | linter
| bash
, shell
|
| shfmt | Shell script formatter | formatter
| shell
|
| sleek | Sleek is a CLI tool for formatting SQL. It helps you maintain a consistent style across your SQL code, enhancing readability and productivity | formatter
| sql
|
| smlfmt | A custom parser/auto-formatter for Standard ML | formatter
| standard-ml
|
| snakefmt | The uncompromising Snakemake code formatter | formatter
| snakemake
|
| sql-formatter | A whitespace formatter for different query languages | formatter
| sql
|
| sqlfluff | A modular SQL linter and auto-formatter with support for multiple dialects and templated code | formatter
, linter
| sql
|
| sqlfmt | sqlfmt formats your dbt SQL files so you don't have to | formatter
| sql
|
| sqruff | Fast SQL formatter/linter | formatter
, linter
| sql
|
| standardjs | JavaScript style guide, linter, and formatter | formatter
, linter
| javascript
|
| standardrb | Ruby's bikeshed-proof linter and formatter | formatter
, linter
| ruby
|
| stylefmt | stylefmt is a tool that automatically formats stylesheets | formatter
| css
, scss
|
| stylelint | A mighty CSS linter that helps you avoid errors and enforce conventions | linter
| css
, scss
|
| stylish-haskell | Haskell code prettifier | formatter
| haskell
|
| stylua | An opinionated Lua code formatter | formatter
| lua
|
| superhtml | HTML Language Server & Templating Language Library | formatter