Skip to content

Create mdformat plugin for mdsf#1

Merged
KyleKing merged 10 commits into
mainfrom
claude/mdformat-mdsf-plugin-01BWCeWsaHPkRMCbeQSXLF44
Nov 27, 2025
Merged

Create mdformat plugin for mdsf#1
KyleKing merged 10 commits into
mainfrom
claude/mdformat-mdsf-plugin-01BWCeWsaHPkRMCbeQSXLF44

Conversation

@KyleKing
Copy link
Copy Markdown
Owner

  • 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.

claude and others added 10 commits November 23, 2025 06:16
- 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.
@KyleKing KyleKing merged commit dfb5a05 into main Nov 27, 2025
2 of 7 checks passed
@KyleKing KyleKing deleted the claude/mdformat-mdsf-plugin-01BWCeWsaHPkRMCbeQSXLF44 branch November 27, 2025 03:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants