Skip to main content
Donate to the Python Software Foundation or Purchase a PyCharm License to Benefit the PSF! Donate Now

Lints Python code blocks in Markdown files using flake8

Project description

Flake8 Markdown


Flake8 Markdown lints GitHub-style Python code blocks in Markdown files using flake8.

This package helps improve a Python project's documentation by ensuring that code samples are error-free.


  • Lints code blocks containing regular Python and Python interpreter code (pycon)
  • pre-commit hook to lint on commit


Flake8 Markdown can be installed from PyPI using pip or your package manager of choice:

pip install flake8-markdown



You can use Flake8 Markdown as a CLI tool using the flake8-markdown command.

flake8-markdown accepts one or more globs as its arguments.


$ flake8-markdown flake8-markdown "tests/samples/*.md"
tests/samples/ F821 undefined name 'emphasized_imaginary_function'
tests/samples/ E999 SyntaxError: EOL while scanning string literal
tests/samples/ F821 undefined name 'undefined_variable'

pre-commit hook

You can also add flake8-markdown to your project using pre-commit. When configured, any staged Markdown files will be linted using flake8-markdown once you run git commit.

To enable this hook in your local repository, add the following repo to your .pre-commit-config.yaml file:

# .pre-commit-config.yaml
  - repo:
    rev: v0.2.0
      - id: flake8-markdown

Code of Conduct

Everyone interacting in the project's codebases, issue trackers, chat rooms, and mailing lists is expected to follow the PyPA Code of Conduct.


[0.2.0] - 2019-06-14


  • pycon code block support

[0.1.1] - 2019-05-19


  • Fixed pre-commit example in README

[0.1.0] - 2019-05-19


  • Added code for initial release

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Filename, size & hash SHA256 hash help File type Python version Upload date
flake8_markdown-0.2.0-py3-none-any.whl (6.3 kB) Copy SHA256 hash SHA256 Wheel py3
flake8-markdown-0.2.0.tar.gz (5.1 kB) Copy SHA256 hash SHA256 Source None

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page