Skip to main content

An mdformat plugin for EditorConfig-based indentation and tight list formatting.

Project description

mdformat-space-control

Build Status PyPI version

An mdformat plugin that provides unified control over Markdown list formatting:

  • EditorConfig support: Configure list indentation via .editorconfig files
  • Tight list formatting: Automatically removes unnecessary blank lines between list items

Installation

pip install mdformat-space-control

Or with pipx for command-line usage:

pipx install mdformat
pipx inject mdformat mdformat-space-control

Usage

After installation, mdformat will automatically use this plugin:

mdformat your-file.md

EditorConfig Support

Create an .editorconfig file in your project:

# .editorconfig
root = true

[*.md]
indent_style = space
indent_size = 4

Nested lists will use the configured indentation:

Before:

- Item 1
  - Nested item
- Item 2

After (with 4-space indent):

- Item 1
    - Nested item
- Item 2

Tight List Formatting

Lists with single-paragraph items are automatically formatted as tight lists:

Before:

- Item 1

- Item 2

- Item 3

After:

- Item 1
- Item 2
- Item 3

Multi-paragraph items preserve loose formatting:

- First item with multiple paragraphs

  Second paragraph of first item

- Second item

EditorConfig Properties

Property Status Notes
indent_style Supported space or tab for list indentation
indent_size Supported Number of spaces per indent level
tab_width Supported Used when indent_size = tab

Python API

When using the Python API, you can set the file context for EditorConfig lookup:

import mdformat
from mdformat_space_control import set_current_file

set_current_file("/path/to/your/file.md")
try:
    result = mdformat.text(markdown_text, extensions={"space_control"})
finally:
    set_current_file(None)

Development

# Install dependencies
uv sync

# Run tests
uv run pytest

# Run with coverage
uv run pytest --cov=mdformat_space_control

License

MIT - see LICENSE file for details.

Project details


Download files

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

Source Distribution

mdformat_space_control-0.1.1.tar.gz (7.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

mdformat_space_control-0.1.1-py3-none-any.whl (7.4 kB view details)

Uploaded Python 3

File details

Details for the file mdformat_space_control-0.1.1.tar.gz.

File metadata

  • Download URL: mdformat_space_control-0.1.1.tar.gz
  • Upload date:
  • Size: 7.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: python-requests/2.32.5

File hashes

Hashes for mdformat_space_control-0.1.1.tar.gz
Algorithm Hash digest
SHA256 c1dd9892d06d2ef0eec94b0dcab40894b5646753d2bb9d16c1f4b235ab0bc3ab
MD5 0e6ecd1c7c042b5fa26381b8dca395b6
BLAKE2b-256 613d36539e269a95ddad11c71f2b68343306e8e5647efb14bbf9281597ce53c2

See more details on using hashes here.

File details

Details for the file mdformat_space_control-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for mdformat_space_control-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 33e07997e907f037f6505ccacf98832c716b4cdd976c89548811070f8c53654e
MD5 c8241effb98636fc0d4a6e8a45faec20
BLAKE2b-256 ae0706d5db7a72e7964c51bd6578db83c974ab7febf7609bba4af5ecef9758ec

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page