Mdformat is an opinionated Markdown formatter that can be used to enforce a consistent style in Markdown files

Overview

Documentation Status Build Status codecov.io PyPI version

mdformat

CommonMark compliant Markdown formatter

Mdformat is an opinionated Markdown formatter that can be used to enforce a consistent style in Markdown files. Mdformat is a Unix-style command-line tool as well as a Python library.

Find out more in the docs.

Installing

Install with CommonMark support:

pip install mdformat

Alternatively install with GitHub Flavored Markdown (GFM) support:

pip install mdformat-gfm

Or with Markedly Structured Text (MyST) support:

pip install mdformat-myst

Command line usage

Format files

Format files README.md and CHANGELOG.md in place

mdformat README.md CHANGELOG.md

Format .md files in current working directory recursively

mdformat .

Read Markdown from standard input until EOF. Write formatted Markdown to standard output.

mdformat -

Check formatting

mdformat --check README.md CHANGELOG.md

This will not apply any changes to the files. If a file is not properly formatted, the exit code will be non-zero.

Options

[email protected]:~$ mdformat --help
usage: mdformat [-h] [--check] [--version] [--number] [--wrap {keep,no,INTEGER}] [--end-of-line {lf,crlf}] [paths [paths ...]]

CommonMark compliant Markdown formatter

positional arguments:
  paths                 files to format

optional arguments:
  -h, --help            show this help message and exit
  --check               do not apply changes to files
  --version             show program's version number and exit
  --number              apply consecutive numbering to ordered lists
  --wrap {keep,no,INTEGER}
                        paragraph word wrap mode (default: keep)
  --end-of-line {lf,crlf}
                        output file line ending mode (default: lf)

Documentation

This README merely provides a quickstart guide for the command line interface. For more information refer to the documentation. Here's a few pointers to get you started:

Frequently Asked Questions

Why not use Prettier instead?

Mdformat is pure Python code! Python is pre-installed on macOS and virtually any Linux distribution, meaning that typically little to no additional installations are required to run mdformat. This argument also holds true when using together with pre-commit (also Python). Prettier on the other hand requires Node.js/npm.

Prettier suffers from numerous bugs, many of which cause changes in Markdown AST and rendered HTML. Many of these bugs are a consequence of using remark-parse v8.x as Markdown parser which, according to the author themselves, is inferior to markdown-it used by mdformat. remark-parse v9.x is advertised as CommonMark compliant and presumably would fix many of the issues, but is not used by Prettier (v2.3.1) yet.

Prettier (v2.3.1), being able to format many languages other than Markdown, is a large package with 65 direct dependencies (mdformat only has 2 in Python 3.8+). This can be a disadvantage in many environments, one example being size optimized Docker images.

Mdformat's parser extension plugin API allows not only customization of the Markdown specification in use, but also advanced features like automatic table of contents generation. Also provided is a code formatter plugin API enabling integration of embedded code formatting for any programming language.

What's wrong with the mdformat logo? It renders incorrectly and is just terrible in general.

Nope, the logo is actually pretty great – you're terrible. The logo is more a piece of art than a logo anyways, depicting the horrors of poorly formatted text documents. I made it myself!

That said, if you have any graphic design skills and want to contribute a revised version, a PR is more than welcome 😄 .

Owner
Executable Books
An open collaboration to create executable books with Jupyter
Executable Books
Mdformat is an opinionated Markdown formatter that can be used to enforce a consistent style in Markdown files

Mdformat is an opinionated Markdown formatter that can be used to enforce a consistent style in Markdown files. Mdformat is a Unix-style command-line tool as well as a Python library.

Executable Books 180 Jan 06, 2023
A markdown extension for converting Leiden+ epigraphic text to TEI XML/HTML

LeidenMark $ pip install leidenmark A Python Markdown extension for converting Leiden+ epigraphic text to TEI XML/HTML. Inspired by the Brill plain te

André van Delft 2 Aug 04, 2021
An interactive, terminal-based markdown presenter

lookatme lookatme is an interactive, extensible, terminal-based markdown presentation tool. TOC TOC Features Tour Navigating the Presentation CLI Opti

James Johnson 1.4k Jan 01, 2023
a small simple library for generating documentation from docstrings

inkpot a small simple library for generating documentation from docstrings inkpot is available on pip. Please give it a star if you like it! To know m

Axel Gard 5 Oct 20, 2022
Convert HTML to Markdown-formatted text.

html2text html2text is a Python script that converts a page of HTML into clean, easy-to-read plain ASCII text. Better yet, that ASCII also happens to

Alireza Savand 1.3k Dec 31, 2022
Converts a grading Excel sheet into Markdown documents.

GradeDocs Turns Excel worksheets into grade/score documents. Example Given such an Excel Worksheet (see examples/example.xlsx): The following commands

Patrick Bucher 1 Dec 19, 2021
Extensions for Python Markdown

PyMdown Extensions Extensions for Python Markdown. Documentation Extension documentation is found here: https://facelessuser.github.io/pymdown-extensi

Isaac Muse 685 Jan 01, 2023
A Python implementation of John Gruber’s Markdown with Extension support.

Python-Markdown This is a Python implementation of John Gruber's Markdown. It is almost completely compliant with the reference implementation, though

Python-Markdown 3.1k Dec 30, 2022
Notedown - Markdown <=> IPython Notebook

Python 2/3 and IPython 4 / Jupyter compatible! Convert IPython Notebooks to markdown (and back) notedown is a simple tool to create IPython notebooks

Aaron O'Leary 840 Jan 04, 2023
Lightweight Markdown dialect for Python desktop apps

Litemark is a lightweight Markdown dialect originally created to be the markup language for the Codegame Platform project. When you run litemark from the command line interface without any arguments,

10 Apr 23, 2022
A markdown lexer and parser which gives the programmer atomic control over markdown parsing to html.

A markdown lexer and parser which gives the programmer atomic control over markdown parsing to html.

stonepresto 4 Aug 13, 2022
A fast, extensible and spec-compliant Markdown parser in pure Python.

mistletoe mistletoe is a Markdown parser in pure Python, designed to be fast, spec-compliant and fully customizable. Apart from being the fastest Comm

Mi Yu 546 Jan 01, 2023
Remarkable Markdown Debian Package Fix

Remarkable debian package fix For some reason the Debian package for remarkable markdown editor has not been made to install properly on Ubuntu 20.04

Eric Seifert 37 Jan 02, 2023
Markdown Presentations for Tech Conferences, Training, Developer Advocates, and Educators.

March 1, 2021: Service on gitpitch.com has been shutdown permanently. GitPitch 4.0 Docs Twitter About Watch the Introducing GitPitch 4.0 Video Visit t

David Russell 5.4k Jan 05, 2023
A lightweight and fast-to-use Markdown document generator based on Python

A lightweight and fast-to-use Markdown document generator based on Python

快乐的老鼠宝宝 1 Jan 10, 2022
A automated python script that creates mark-down files to read for the aes keys and other useful information.

Archive A automated python script that creates mark-down files to read for the aes keys and other useful information. Table of Contents Benbot Automat

Tector 13 Dec 14, 2022
Rich-cli is a command line toolbox for fancy output in the terminal

Rich CLI Rich-cli is a command line toolbox for fancy output in the terminal, built with Rich. Rich-cli can syntax highlight a large number of file ty

Textualize 2.5k Jan 02, 2023
Toci is a markdown tool to generate an outline from a given Jupyter notebook.

Toci is a markdown tool to generate an outline from a given Jupyter notebook. It traverses the markdown cells of a given ipynb file to form a toc for you.

Hakan Özler 7 Jan 22, 2022
Application that converts markdown to html.

Markdown-Engine An application that converts markdown to html. Installation Using the package manager [pip] pip install -r requirements.txt Usage Run

adriano atambo 1 Jan 13, 2022
Awesome Django Markdown Editor, supported for Bootstrap & Semantic-UI

martor Martor is a Markdown Editor plugin for Django, supported for Bootstrap & Semantic-UI. Features Live Preview Integrated with Ace Editor Supporte

659 Jan 04, 2023