Introduction

GitHub release
Github All Releases
license
Go Reference
Coverage Status

A Markdown formatter that follow the CommonMark. Like gofmt, but for Markdown.

Language

English | 简体中文

Intallation

Homebrew

The elliotxx/tap has macOS and GNU/Linux pre-built binaries available:

brew install elliotxx/tap/mdfmt

Build from Source

Starting with Go 1.17, you can install mdfmt from source using go install:

go install github.com/elliotxx/mdfmt/cmd/[email protected]

NOTE: This will install mdfmt based on the latest available code base. Even though the goal is that the latest commit on the main branch should always be a stable and usable version, this is not the recommended way to install and use mdfmt. The version output will show mdfmt version (default-version) for go install based builds.

Usage

$ mdfmt -h
A Markdown formatter that follow the CommonMark. Like gofmt, but for Markdown.

Usage:
  mdfmt [flags] [path ...]

Examples:
  # Format specified Markdown file, and write to stdout
  mdfmt README.md
  
  # Format and rewrite specified Markdown file
  mdfmt -w README.md
  
  # Format and rewrite all Markdown file in current directory
  mdfmt -w *.md
  
  # Format and rewrite Markdown file and directory
  mdfmt -w README.md testdir/
  
  # Format stdin to stdout
  cat README.md | mdfmt
  
  # Show version info
  mdfmt -V

Flags:
  -h, --help      help for mdfmt
  -V, --version   show version info
  -w, --write     write result to (source) file instead of stdout

Thanks

GitHub

View Github