https://github.com/emiliogrv/mdformat-gherkin
Mdformat plugin to beautify Gherkin code blocks
https://github.com/emiliogrv/mdformat-gherkin
commonmark gherkin markdown mdformat python
Last synced: 3 months ago
JSON representation
Mdformat plugin to beautify Gherkin code blocks
- Host: GitHub
- URL: https://github.com/emiliogrv/mdformat-gherkin
- Owner: emiliogrv
- License: bsd-3-clause
- Created: 2025-11-09T19:26:51.000Z (8 months ago)
- Default Branch: main
- Last Pushed: 2025-11-10T12:10:41.000Z (8 months ago)
- Last Synced: 2025-12-15T07:39:31.834Z (6 months ago)
- Topics: commonmark, gherkin, markdown, mdformat, python
- Language: Python
- Homepage:
- Size: 7.81 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[](LICENSE)
- [Features](#features)
- [Installation](#installation)
- [Usage](#usage)
- [Example](#example)
- [Pre-commit Hook](#pre-commit-hook)
- [License](#license)
- [Acknowledgments](#acknowledgments)
______________________________________________________________________
- 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
```bash
pip install mdformat-gherkin
```
You may pin the reformat-gherkin dependency for formatting stability:
```bash
pip install mdformat-gherkin reformat-gherkin==v3.0.1
```
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:
````python
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)
````
Before formatting:
````markdown
```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`:
````markdown
```gherkin
Feature: Test feature
Scenario: Test scenario
Given I have a test
When I run the test
Then it should pass
```
````
You can use this plugin with [pre-commit](https://pre-commit.com/). Add the following to your `.pre-commit-config.yaml`:
```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
```
This project is licensed under the BSD 3-Clause License - see the [LICENSE](LICENSE) file for details.
This project is based on the work of [reformat-gherkin](https://github.com/ducminh-phan/reformat-gherkin).