Create mdformat plugin for mdsf#1
Merged
KyleKing merged 10 commits intoNov 27, 2025
Merged
Conversation
- Add _formatter.py module with support for 28 languages - Implement code formatters for Python, JavaScript, TypeScript, Rust, Go, Java, C, C++, C#, Ruby, PHP, Swift, Kotlin, Scala, Shell, Bash, Zsh, JSON, YAML, TOML, HTML, CSS, SCSS, SQL, GraphQL, and Markdown - Configure entry points for mdformat.codeformatter - Update README with usage instructions and prerequisites - Add comprehensive tests for multiple language formatters - Remove template files (plugin.py, _helpers.py) - Update pyproject.toml with code formatter entry points The plugin integrates mdsf (https://github.com/hougesen/mdsf) with mdformat to automatically format code blocks in Markdown files using 332+ formatters.
BREAKING CHANGE: Reduced hardcoded functions, added flexible configuration - Add configuration system via CLI args, TOML, and Python API - Create `_config.py` module for managing plugin configuration - Add `plugin.py` with CLI argument group for mdsf options - Support `--mdsf-config`, `--mdsf-timeout`, `--mdsf-languages`, `--mdsf-fail-on-error` - Support TOML configuration via `[tool.mdformat.plugin.mdsf]` - Dynamically generate formatter functions instead of hardcoding 28 separate functions - Update README with comprehensive configuration documentation - Add parser extension entry point for CLI integration - Formatters now check configuration before processing Configuration options: - config: Path to mdsf.json configuration file - timeout: Timeout for mdsf operations (default: 30s) - languages: Specific languages to format (default: all) - fail_on_error: Fail on errors vs. fallback to unformatted (default: false) This makes the plugin more flexible and maintainable while keeping the DRY principle for formatter functions.
- Export empty RENDERERS dict for mdformat compatibility - Add comprehensive integration tests with mdsf installed - Remove obsolete template test directories (render, format) - Verify end-to-end formatting works with Python, JavaScript, Rust, JSON - All 14 tests pass (6 integration, 8 unit) Integration tests verify: - Python code formatting with mdsf - Multiple language support - Language filtering configuration - Timeout configuration - Empty code block handling - Trailing newline preservation
- Add detailed installation instructions for mise, pixi, cargo, and homebrew - Emphasize mise as recommended installation method (cargo:mdsf) - Include pixi configuration for cross-platform support - Add examples/ directory with complete configuration files: - .mise.toml.example: mise tool configuration - pixi.toml.example: pixi project setup - mdsf.json.example: mdsf formatter configuration - .mdformat.toml.example: mdformat plugin configuration - Clarify mdsf requirement for pre-commit hooks - Add verification steps for mdsf installation - Fix __all__ sorting in __init__.py (ruff) The examples make it easy for users to get started with the recommended tooling (mise/pixi) for managing mdsf.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The plugin integrates mdsf (https://github.com/hougesen/mdsf) with mdformat to automatically format code blocks in Markdown files using 332+ formatters.