Skip to main content

Mdformat plugin to format Gherkin code blocks using reformat-gherkin

Project description

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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mdformat_gherkin-0.1.0.tar.gz (3.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

mdformat_gherkin-0.1.0-py3-none-any.whl (4.0 kB view details)

Uploaded Python 3

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

Hashes for mdformat_gherkin-0.1.0.tar.gz
Algorithm Hash digest
SHA256 0b5231e412746cefd532178031b7f1fe344a9058398a0ae48ed43e2ce75de52a
MD5 c41e9a449fbf0a1f7048ada933446914
BLAKE2b-256 cd6b7151199679de2e8c58e19913e6ca4fabaf4293802accf812ad5de3192577

See more details on using hashes here.

File details

Details for the file mdformat_gherkin-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for mdformat_gherkin-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 fd1f4827ecc571107822081077c01a48677e2a832e655bf197efb48ae29ecc69
MD5 c148cd82be28edef7485e84746eeccd3
BLAKE2b-256 1a3f09e6cb25e13bc936ddbf1caa65f8147050fc8a9cf1c67f029d90e388296c

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page