Skip to main content

🛠️ Markdown Table Fixer

A modern Python tool for automatically fixing markdown table formatting issues. Works as a standalone CLI tool, pre-commit hook, and can bulk-fix tables across GitHub organizations.

Features

  • Lint Mode: Scan directories for markdown files with table formatting issues
  • GitHub Mode: Automatically fix tables in blocked PRs across an entire GitHub organization
  • Pre-commit Integration: Run as a pre-commit hook to enforce table formatting standards
  • Markdownlint Compatible: Fixes issues detected by markdownlint's MD060 rule
  • Parallel Processing: Efficiently processes repositories and PRs in parallel

Installation

pip install markdown-table-fixer

Or with uv:

uv pip install markdown-table-fixer

Usage

Lint Mode

Scan the current directory for markdown table formatting issues:

markdown-table-fixer lint

Scan a specific path:

markdown-table-fixer lint /path/to/docs

Auto-fix issues found:

markdown-table-fixer lint --auto-fix

Respecting Markdownlint Disable Comments

The tool automatically respects markdownlint disable/enable comments in your markdown files. Violations within disabled sections are not reported:

<!-- markdownlint-disable MD013 -->
| Long table that exceeds line length... |
<!-- markdownlint-enable MD013 -->

<!-- markdownlint-disable MD013 MD060 -->
| Table with both line length and formatting issues disabled |
<!-- markdownlint-enable MD013 MD060 -->

This behavior is consistent across both lint and github commands, ensuring that locally suppressed violations are not reported or fixed when processing pull requests.

Violation Reporting

The lint command provides detailed violation reporting by markdownlint rule code:

$ markdown-table-fixer lint .
🔍 Scanning: .

Summary:
  Files scanned: 10
  Files with issues: 1
  Total violations: 66

Files with issues:
  README.md [66 Errors: MD013 (61), MD060 (5)]

The tool reports violations categorized by markdownlint rule:

  • MD013: Line length exceeds limit (auto-detected from .markdownlintrc)
  • MD060: Table formatting issues (misaligned pipes, spacing, etc.)

Note: Violations in sections with markdownlint disable comments are automatically filtered out and not reported.

The line length limit is automatically detected from your markdownlint configuration file (.markdownlint.json, .markdownlint.yaml, etc.). If no configuration file exists, the default is 80 characters.

GitHub Mode

The github command intelligently handles both individual pull requests and entire organizations.

Fix a Specific Pull Request

Fix markdown tables in a specific pull request by providing the PR URL:

markdown-table-fixer github https://github.com/owner/repo/pull/123 --token YOUR_GITHUB_TOKEN

With environment variable for token:

export GITHUB_TOKEN=your_token_here
markdown-table-fixer github https://github.com/owner/repo/pull/123

Dry run to preview changes without applying them:

markdown-table-fixer github https://github.com/owner/repo/pull/123 --dry-run

Update Methods

The tool supports two methods for applying fixes:

API Method (default) - Uses GitHub API to create new commits:

markdown-table-fixer github https://github.com/owner/repo/pull/123
  • Creates new commits via GitHub API
  • Shows as "Verified" by GitHub
  • No Git operations required
  • Faster and simpler
  • Does not support sync strategies (rebase/merge)

Git Method - Clones repo, amends commit, force-pushes:

markdown-table-fixer github https://github.com/owner/repo/pull/123 \
  --update-method git
  • Respects your local Git signing configuration
  • Amends the existing commit (preserves commit history)
  • Requires Git operations (clone, amend, push)
  • Use when you need to amend commits or use sync strategies

Scope Control

By default, both methods scan and fix all markdown files in the repository. To limit processing to files changed in the PR, use the --pr-changes-only flag:

markdown-table-fixer github https://github.com/owner/repo/pull/123 \
  --pr-changes-only

Benefits of limiting scope to PR changes:

  • Faster processing (fewer files to check)
  • Useful when you want to fix tables in modified files without touching others
  • Avoids touching unrelated markdown files

Fix PRs Across an Organization

Scan and fix tables in PRs across an entire GitHub organization:

markdown-table-fixer github ORG_NAME --token YOUR_GITHUB_TOKEN

Or using an organization URL:

markdown-table-fixer github https://github.com/ORG_NAME/

You can also provide the GitHub token via the GITHUB_TOKEN environment variable:

export GITHUB_TOKEN=your_token_here
markdown-table-fixer github ORG_NAME

Pre-commit Integration

Add to your .pre-commit-config.yaml:

repos:
  - repo: https://github.com/lfreleng-actions/markdown-table-fixer
    rev: v1.0.0
    hooks:
      - id: markdown-table-fixer
        # Automatically fixes issues

Or use the check variant for validation without auto-fixing:

repos:
  - repo: https://github.com/lfreleng-actions/markdown-table-fixer
    rev: v1.0.0
    hooks:
      - id: markdown-table-fixer-check
        # Validates, doesn't fix

Available hooks:

  • markdown-table-fixer: Automatically fixes table formatting issues
  • markdown-table-fixer-check: Checks for issues without fixing (CI mode)

Table Formatting Rules

The tool enforces the following formatting standards:

  1. Alignment: All pipe symbols (|) must be vertically aligned
  2. Spacing: Cell content must have at least one space on each side
  3. Consistency: All rows in a table must follow the same formatting style

Correct Format

Name Required Description
input False Action input
verbose True Enable logs

Incorrect Format (Fixed Automatically)

| Name    | Required | Description  |
| ------- | -------- | ------------ |
| input   | False    | Action input |
| verbose | True     | Enable logs  |

Options

Lint Command

Flag Short Default Description
--auto-fix false Automatically fix issues found
--format text Output format: text, json
--quiet -q false Suppress output except errors
--check false Exit with error if issues found

GitHub Command

Flag Short Default Description
--token -t None GitHub token (or use $GITHUB_TOKEN)
--threads auto Number of parallel threads
--dry-run false Preview changes without applying
--format table Output format: table, json
--include-drafts false Include draft PRs

Development

Setup

git clone https://github.com/lfreleng-actions/markdown-table-fixer.git
cd markdown-table-fixer
uv venv
source .venv/bin/activate
uv pip install -e ".[dev]"

Running Tests

pytest

Running Pre-commit Hooks

pre-commit install
pre-commit run --all-files

License

Apache-2.0

Contributing

Contributions are welcome! Please see our contributing guidelines for more information.

Metadata

Release files for markdown-table-fixer 0.1.12

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for markdown-table-fixer 0.1.12
File Size Uploaded
markdown_table_fixer-0.1.12.tar.gz 68.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for markdown-table-fixer 0.1.12
File Interpreter ABI Platform
markdown_table_fixer-0.1.12-py3-none-any.whl Python 3 none any Details

Total release size: 136.4 kB

Release files / markdown_table_fixer-0.1.12.tar.gz

Download URL markdown_table_fixer-0.1.12.tar.gz
Size 68.7 kB
Tags Source
SHA-256 checksum
How to use checksums
ecdf3c970a0934ebfb28603e4ed4125ce020d5432046112f192eda235fb6f5ec
BLAKE2b-256 checksum
How to use checksums
34a92f87c7e79069b26d4aa6bdf1d60aba792851894fa653fcf2718f2b332c5c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.12.15

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 6, 2026.

Transparency log

Release files / markdown_table_fixer-0.1.12-py3-none-any.whl

Download URL markdown_table_fixer-0.1.12-py3-none-any.whl
Size 67.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ee1b02578e751937de002870f3091fbc95f7c4da7f20d372064da3f956f29763
BLAKE2b-256 checksum
How to use checksums
561851927d26eb83b66f95435d9725dd71932b493364bddeb5e1b531d45dc522
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.12.15

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 6, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.1.12 This release

2 release files

0.1.11

2 release files

0.1.10

2 release files

0.1.9

2 release files

0.1.8

2 release files

0.1.7

2 release files

0.1.6

2 release files

0.1.5

2 release files

0.1.4

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page