Mdformat plugin to format Gherkin code blocks using reformat-gherkin
Project description
Features
- Formats Gherkin feature files within markdown code blocks
- Preserves all markdown formatting outside Gherkin code blocks
- Supports all standard Gherkin keywords and syntax
- Consistent formatting for better version control diffs
- Seamless integration with pre-commit hooks
Installation
pip install mdformat-gherkin
You may pin the reformat-gherkin dependency for formatting stability:
pip install mdformat-gherkin reformat-gherkin==v3.0.1
Usage
When using mdformat on the command line, Gherkin formatting will be automatically enabled after install.
When using mdformat Python API, code formatting for Gherkin will have to be enabled explicitly:
import mdformat
unformatted = """```gherkin
Feature: Test feature
Scenario: Test scenario
Given I have a test
When I run the test
Then it should pass
```"""
formatted = mdformat.text(unformatted, codeformatters={"gherkin"})
print(formatted)
Example
Before formatting:
```gherkin
Feature: Test feature
Scenario: Test scenario
Given I have a test
When I run the test
Then it should pass
```
After formatting with mdformat-gherkin:
```gherkin
Feature: Test feature
Scenario: Test scenario
Given I have a test
When I run the test
Then it should pass
```
Pre-commit Hook
You can use this plugin with pre-commit. Add the following to your .pre-commit-config.yaml:
- repo: https://github.com/executablebooks/mdformat
rev: 1.0.0 # Use the latest version
hooks:
- id: mdformat
additional_dependencies:
- mdformat-gherkin
# Optional: pin specific versions
# - reformat-gherkin==v3.0.1
License
This project is licensed under the BSD 3-Clause License - see the LICENSE file for details.
Acknowledgments
This project is based on the work of reformat-gherkin.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file mdformat_gherkin-0.1.0.tar.gz.
File metadata
- Download URL: mdformat_gherkin-0.1.0.tar.gz
- Upload date:
- Size: 3.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0b5231e412746cefd532178031b7f1fe344a9058398a0ae48ed43e2ce75de52a
|
|
| MD5 |
c41e9a449fbf0a1f7048ada933446914
|
|
| BLAKE2b-256 |
cd6b7151199679de2e8c58e19913e6ca4fabaf4293802accf812ad5de3192577
|
File details
Details for the file mdformat_gherkin-0.1.0-py3-none-any.whl.
File metadata
- Download URL: mdformat_gherkin-0.1.0-py3-none-any.whl
- Upload date:
- Size: 4.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fd1f4827ecc571107822081077c01a48677e2a832e655bf197efb48ae29ecc69
|
|
| MD5 |
c148cd82be28edef7485e84746eeccd3
|
|
| BLAKE2b-256 |
1a3f09e6cb25e13bc936ddbf1caa65f8147050fc8a9cf1c67f029d90e388296c
|