Skip to main content

License


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.

Metadata

Release files for mdformat-gherkin 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for mdformat-gherkin 0.1.0
File Size Uploaded
mdformat_gherkin-0.1.0.tar.gz 3.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for mdformat-gherkin 0.1.0
File Interpreter ABI Platform
mdformat_gherkin-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 7.4 kB

Release files / mdformat_gherkin-0.1.0.tar.gz

Download URL mdformat_gherkin-0.1.0.tar.gz
Size 3.4 kB
Tags Source
SHA-256 checksum
How to use checksums
0b5231e412746cefd532178031b7f1fe344a9058398a0ae48ed43e2ce75de52a
BLAKE2b-256 checksum
How to use checksums
cd6b7151199679de2e8c58e19913e6ca4fabaf4293802accf812ad5de3192577
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.4

Release files / mdformat_gherkin-0.1.0-py3-none-any.whl

Download URL mdformat_gherkin-0.1.0-py3-none-any.whl
Size 4.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
fd1f4827ecc571107822081077c01a48677e2a832e655bf197efb48ae29ecc69
BLAKE2b-256 checksum
How to use checksums
1a3f09e6cb25e13bc936ddbf1caa65f8147050fc8a9cf1c67f029d90e388296c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.4

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page