This guide covers different ways to set up and use markdown-table-fixer.
- Quick Start
- Installation Methods
- Pre-commit Integration
- CI/CD Integration
- Development Setup
- Troubleshooting
The fastest way to get started:
# Install with pip
pip install markdown-table-fixer
# Run on current directory
markdown-table-fixer lint --auto-fixpip install markdown-table-fixeruv pip install markdown-table-fixergit clone https://github.com/lfreleng-actions/markdown-table-fixer.git
cd markdown-table-fixer
pip install -e .# Create virtual environment
python -m venv .venv
source .venv/bin/activate # On Windows: .venv\Scripts\activate
# Install
pip install markdown-table-fixer- Add to your
.pre-commit-config.yaml:
repos:
- repo: https://github.com/lfreleng-actions/markdown-table-fixer
rev: v1.0.0 # Use latest version
hooks:
- id: markdown-table-fixer- Install the hooks:
pre-commit install- Run on all files (optional):
pre-commit run markdown-table-fixer --all-filesAutomatically fixes table formatting issues:
- id: markdown-table-fixer
# Optional: customize behavior
args: [lint, ., --auto-fix]Checks for issues without fixing (useful for CI):
- id: markdown-table-fixer-check
# Fails if issues found, doesn't change files- id: markdown-table-fixer
files: ^docs/.*\.md$ # Docs directory- id: markdown-table-fixer
files: '\.md$|\.markdown$' # Default behavior- id: markdown-table-fixer
exclude: ^vendor/|^third_party/Create .github/workflows/markdown-tables.yaml:
name: Markdown Tables
on:
pull_request:
paths:
- '**.md'
- '**.markdown'
jobs:
check-tables:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.11'
- name: Install markdown-table-fixer
run: pip install markdown-table-fixer
- name: Check markdown tables
run: markdown-table-fixer lint . --checkAdd to .gitlab-ci.yml:
markdown-tables:
image: python:3.11
script:
- pip install markdown-table-fixer
- markdown-table-fixer lint . --check
only:
changes:
- "**/*.md"Add to Jenkinsfile:
stage('Check Markdown Tables') {
steps {
sh '''
pip install markdown-table-fixer
markdown-table-fixer lint . --check
'''
}
}Add to .circleci/config.yml:
jobs:
markdown-tables:
docker:
- image: python:3.11
steps:
- checkout
- run:
name: Install markdown-table-fixer
command: pip install markdown-table-fixer
- run:
name: Check tables
command: markdown-table-fixer lint . --check- Python 3.10 or higher
- Git
- uv (recommended) or pip
# Clone the repository
git clone https://github.com/lfreleng-actions/markdown-table-fixer.git
cd markdown-table-fixer
# Create virtual environment
uv venv
source .venv/bin/activate # On Windows: .venv\Scripts\activate
# Install with development dependencies
uv pip install -e ".[dev]"
# Install pre-commit hooks
pre-commit install# Run all tests
pytest
# Run with coverage
pytest --cov=markdown_table_fixer
# Run specific test file
pytest tests/test_table_parser.py -v
# Run with verbose output
pytest -vv# Run all pre-commit hooks
pre-commit run --all-files
# Run specific checks
ruff check src tests
ruff format --check src tests
mypy src# Install build tools
pip install build
# Build source distribution and wheel
python -m build
# Check the distribution
pip install twine
twine check dist/*Problem: [ERROR] markdown-table-fixer is not installed
Solution: Update pre-commit hooks:
pre-commit autoupdate
pre-commit clean
pre-commit installProblem: ModuleNotFoundError: No module named 'markdown_table_fixer'
Solution: Install the package first:
pip install markdown-table-fixer
# Or for development:
pip install -e .Problem: Tool detects issues but doesn't fix them
Solution: Use the --auto-fix flag:
markdown-table-fixer lint --auto-fixOr use the auto-fix pre-commit hook:
- id: markdown-table-fixer # Not markdown-table-fixer-checkProblem: Tool is slow on large repositories
Solutions:
-
Limit to specific directories:
markdown-table-fixer lint docs/
-
Use file filtering in pre-commit:
files: ^docs/.*\.md$
-
Exclude generated or vendor files:
exclude: ^(vendor|node_modules)/
Problem: Dependency conflicts with other packages
Solution: Use a virtual environment:
python -m venv .venv
source .venv/bin/activate
pip install markdown-table-fixerProblem: Pre-commit shows "Passed" but tables aren't fixed
Check:
-
Verify you're using the fix hook (not check):
- id: markdown-table-fixer # Correct # Not: markdown-table-fixer-check
-
Check hook arguments:
- id: markdown-table-fixer args: [lint, ., --auto-fix] # Ensure --auto-fix is present
-
Run manually to see detailed output:
markdown-table-fixer lint . --auto-fix
Use backslashes or forward slashes in paths:
markdown-table-fixer lint docs\
# Or
markdown-table-fixer lint docs/Activate virtual environment:
.venv\Scripts\activateIf you encounter SSL errors, update certificates:
pip install --upgrade certifiEnsure Python 3.10+ is available:
python3 --version
# If needed, install:
sudo apt-get install python3.11 # Ubuntu/DebianIf you encounter issues not covered here:
- Check the GitHub Issues
- Review the README and CONTRIBUTING
- Open a new issue with:
- Your operating system and Python version
- The command you ran
- The error message or unexpected behavior
- A minimal example that reproduces the issue
- Review FEATURES.md for complete feature list
- Read CONTRIBUTING.md if you want to contribute
- Check CHANGELOG.md for version history