0.8.1 • Published 3 months ago

mdsf-cli v0.8.1

Weekly downloads
-
License
MIT
Repository
github
Last release
3 months ago

mdsf

Format, and lint, markdown code snippets using your favorite tools.

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 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

npm.io npm.io

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! 😃

NameDescriptionCategoriesLanguages
actionlintStatic checker for GitHub Actions workflow fileslinteryaml
airR formatter and language serverformatterr
alejandraThe Uncompromising Nix Code Formatterformatternix
alexCatch insensitive, inconsiderate writingspell-checkmarkdown
amebaA static code analysis tool for Crystallintercrystal
ansible-lintansible-lint checks playbooks for practices and behavior that could potentially be improved and can fix some of the most common ones for youlinteransible
asmfmtGo Assembler Formatterformattergo
astyleA Free, Fast, and Small Automatic Formatter for C, C++, C++/CLI, Objective-C, C#, and Java Source Codeformatterc#, c++, c, java, objective-c
auto-optionalAdds the Optional type-hint to arguments where the default value is Noneformatterpython
autocorrectA linter and formatter to help you to improve copywriting, correct spaces, words, and punctuations between CJK (Chinese, Japanese, Korean)spell-check
autoflakeRemoves unused imports and unused variables as reported by pyflakeslinterpython
autopep8A tool that automatically formats Python code to conform to the PEP 8 style guidformatterpython
bashateCode style enforcement for bash programsformatterbash
beancount-blackOpinionated code formatter, just like Python's black code formatter but for Beancountformatterbeancount
beautyshA Bash beautifier for the massesformatterbash, shell
bibtex-tidyCleaner and Formatter for BibTeX filesformatterbibtex
bicepBicep is a declarative language for describing and deploying Azure resourcesformatterbicep
biomeOne toolchain for your web projectformatter, linterjavascript, json, typescript, vue
blackThe uncompromising Python code formatterformatterpython
blade-formatterAn opinionated blade template formatter for Laravel that respects readabilityformatterblade, laravel, php
blueThe slightly less uncompromising Python code formatterformatterpython
bpfmtA formatter for Blueprint filesformatterblueprint
brittanyA Haskell source code formatterformatterhaskell
brunetteA best practice Python code formatterformatterpython
bsfmtA code formatter for BrightScript and BrighterScriptformatterbrighterscript, brightscript
bslintA linter for BrightScript and BrighterScriptlinterbrightscript, brightscripter
bufThe best way of working with Protocol Buffersformatterprotobuf
buildifierA bazel BUILD file formatter andformatterbazel
cabal-fmtAn experiment of formatting .cabal filesformattercabal
cabal-prettifyPrettify your Cabal package configuration filesformattercabal
cabalCabal is a system for building and packaging Haskell libraries and programsformattercabal
caddyFormats or prettifies a Caddyfileformattercaddy
caramelFormatter for the Caramel programming languageformattercaramel
cfn-lintCloudFormation Linterlintercloudformation, json, yaml
checkmakeExperimental linter/analyzer for Makefileslintermakefile
clang-formatA tool to format C/C++/Java/JavaScript/JSON/Objective-C/Protobuf/C# codeformatterc#, c++, c, java, javascript, json, objective-c, protobuf
clang-tidyclang-tidy is a clang-based C++ “linter” toollinterc++
clj-kondoStatic analyzer and linter for Clojure code that sparks joylinterclojure, clojurescript
cljfmtA tool for formatting Clojure codeformatterclojure
cljstyleA tool for formatting Clojure codeformatterclojure
cmake-formatcmake-format can format your listfiles nicely so that they don't look like crapformattercmake
cmake-lintLint CMake fileslintercmake
codeqlFormat queries and libraries with CodeQLformattercodeql
codespellCheck code for common misspellingsspell-check
coffeelintLint your CoffeeScriptlintercoffeescript
cppcheckCppcheck is a static analysis tool for C/C++ codelinterc++, c
cpplintStatic code checker for C++linterc++
crlfmtFormatter for CockroachDB's additions to the Go style guideformattergo
crystalTools for the Crystal programming languageformattercrystal
csharpierAn Opinionated Code Formatter for C#formatterc#
css-beautifyA css formatterformattercss
csscombCSS coding style formatterformattercss
csslintAutomated linting of Cascading Stylesheetslintercss
curlylintExperimental HTML templates linting for Jinja, Nunjucks, Django templates, Twig, Liquidlinterdjango, html, jinja, liquid, nunjucks, twig
d2A modern language that turns text to diagramsformatterd2
dartFormatter and linter for Dartformatter, linterdart, flutter
dcmCode Quality Tool for Flutter Developersformatter, linterdart, flutter
deadnixScan Nix files for dead codelinternix
denoFormatter and linter for JavaScript and TypeScriptformatter, linterjavascript, json, typescript
dfmtDfmt is a formatter for D source codeformatterd
dhallFormat Dhall filesformatterdhall
djadeA Django template formatterformatterdjango, python
djlintLint & Format HTML Templatesformatter, linterhandlebars, html, jinja, mustache, nunjucks, twig
docformatterFormats docstrings to follow PEP 257formatterpython
dockfmtDockerfile format and parser. Like gofmt but for Dockerfilesformatterdocker
docstrfmtA formatter for Sphinx flavored reStructuredTextformatterpython, restructuredtext, sphinx
doctocGenerates table of contents for markdown filesformattermarkdown
dotenv-linterLightning-fast linter for .env fileslinterenv
dprintA pluggable and configurable code formatting platform written in Rustformatter
dscannerSwiss-army knife for D source codelinterd
easy-coding-standardThe Easiest way to add coding standard to your PHP projectformatter, linterphp
efmtErlang code formatterformattererlang
elm-formatelm-format formats Elm source code according to a standard set of rules based on the official Elm Style Guideformatterelm
erb-formatterFormat ERB files with speed and precisionformattererb, ruby
erlfmtAn automated code formatter for Erlangformattererlang
eslintFind and fix problems in your JavaScript codelinterjavascript, typescript
fantomasFSharp source code formatterformatterfsharp
fish_indentFish indenter and prettifierformatterfish
fixjsonJSON Fixer for Humans using (relaxed) JSON5formatter, linterjson5, json
floskellFloskell is a flexible Haskell source code pretty printerformatterhaskell
fnlfmtA formatter for Fennel codeformatterfennel
forgeA Solidity formatterformattersolidity
fortitudeA Fortran linter, written in Rustlinter
fortran-linterA simple fortran syntax checker, including automatic fixing of the codeformatter, linterfortran
fourmoluA formatter for Haskell source codeformatterhaskell
fprettifyAuto-formatter for modern Fortran source codeformatterfortran
futharkCode formatter for the furhark programming languageformatterfuthark
gciGCI, a tool that control golang package import order and make it always deterministicformattergo
gdformatGDScript formatterformattergdscript
gdlintGDScript linterlintergdscript
gersemiA formatter to make your CMake code the real treasureformattercmake
gleamFormat Gleam source codeformattergleam
gluonCode formatting for the gluon programming languageformattergluon
gofmtGofmt formats Go programsformattergo
gofumptA stricter gofmtformattergo
goimports-reviserRight imports sorting & code formatting tool (goimports alternative)formattergo
goimportsgoimports updates your Go import lines, adding missing ones and removing unreferenced onesformattergo
golinesA golang formatter that fixes long linesformattergo
google-java-formatReformats Java source code to comply with Google Java Styleformatterjava
gospelMisspelled word linter for Go comments, string literals and embedded filesspell-checkgo
grainCode formatter for the Grain programming languageformattergrain
hadolintDockerfile linter, validate inline bash, written in Haskelllinterdockerfile
haml-lintTool for writing clean and consistent HAMLlinterhaml
hclfmtFormatter for hcl filesformatterhcl
hfmtFormat Haskell programs. Inspired by the gofmt utilityformatterhaskell
hindentExtensible Haskell pretty printerformatterhaskell
hlintHaskell source code suggestionslinterhaskell
html-beautifyA html formatterformatterhtml
htmlbeautifierA normaliser/beautifier for HTML that also understands embedded Ruby. Ideal for tidying up Rails templatesformattererb, html, ruby
htmlhintThe static code analysis tool you need for your HTMLlinterhtml
hurlfmtFormatter for hurl filesformatterhurl
imbaA formatter for Imbaformatterimba
inkoCode formatter for the inko programming languageformatterinko
isortA Python utility to sort importsformatterpython
jokerSmall Clojure interpreter, linter and formatterformatter, linterclojure
jqJSON processorformatterjson
jqfmtlike gofmt, but for jqformatterjq
js-beautifyA JavaScript formatterformatterjavascript
json5formatJSON5 (a.k.a., JSON for Humans) formatter that preserves contextual commentsformatterjson5, json
jsonaJSONA linter and formatterformatter, linterjsona
jsonlintA JSON parser and validator with a CLIformatter, linterjson
jsonnet-lintLinter for jsonnet fileslinterjsonnet
jsonnetfmtFormatter for automatically fixing jsonnet stylistic problemsformatterjsonnet
jsonppA fast command line JSON pretty printerformatterjson
juliaformatter.jlAn opinionated code formatter for Julia. Plot twist - the opinion is your ownformatterjulia
justA formatter for justfilesformatterjust
kclKCL Format tool supports reformatting KCL files to the standard code styleformatterkcl
kdlfmtA formatter for kdl documentsformatterkdl
kdoc-formatterReformats Kotlin KDoc comments, reflowing text and other cleanupformatterkotlin
ktfmtprogram that reformats Kotlin source code to comply with the common community standard for Kotlin code conventionsformatterkotlin
ktlintAn anti-bikeshedding Kotlin linter with built-in formatterlinterkotlin
kulala-fmtAn opinionated .http and .rest file linter and formatterformatterhttp
leptosfmtA formatter for the leptos view! macroformatterrust
liquidsoap-prettierPrettier plugin for liquidsoap scriptformatterliquidsoap
luacheckA tool for linting and static analysis of Lua codeformatterlua
luaformatterCode formatter for Luaformatterlua
madoA fast Markdown linter written in Rustlintermarkdown
magoA fast linter and formatter for PHPformatter, linterphp
markdownfmtLike gofmt, but for Markdownformattermarkdown
markdownlint-cli2A fast, flexible, configuration-based command-line interface for linting Markdown/CommonMark files with the markdownlint librarylintermarkdown
markdownlintA Node.js style checker and lint tool for Markdown/CommonMark fileslintermarkdown
markuplintAn HTML linter for all markup developerslinterhtml

| md-padding(https://github.com/harttle/md

0.8.1

3 months ago

0.8.0

3 months ago

0.5.3

4 months ago

0.5.0

4 months ago

0.4.1

5 months ago

0.3.2

6 months ago

0.4.0

5 months ago

0.3.1

7 months ago

0.7.0

3 months ago

0.6.1

3 months ago

0.5.2

4 months ago

0.6.0

4 months ago

0.5.1

4 months ago

0.3.0

8 months ago

0.2.7

8 months ago

0.2.6

9 months ago

0.2.5

9 months ago

0.2.3

9 months ago