Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions .pre-commit-hook.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
- id: mdformat-hallmark
name: mdformat-hallmark
description: "CommonMark compliant Markdown formatter"
entry: mdformat
language: python
types: [markdown]
minimum_pre_commit_version: '1.0.0'
additional_dependencies:
- [email protected]
- mdformat-hallmark
3 changes: 2 additions & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
MIT License

Copyright (c) 2025 Executable Books
Copyright (c) 2020 Executable Books
Copyright (c) 2025 Callan Gray

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
28 changes: 26 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,34 @@
# mdformat-hallmark

[![Build Status](https://github.com/calgray/mdformat-hallmark/actions/workflows/tests.yml/badge.svg?branch=master)](<https://github.com/calgray/mdformat-hallmark/actions?query=workflow%3ATests+branch%3Amaster+event%3Apush>)
[![codecov.io](https://codecov.io/gh/calgray/mdformat-hallmark/branch/main/graph/badge.svg)](https://codecov.io/gh/xarray-contrib/astropy-xarray)
[![codecov.io](https://codecov.io/gh/calgray/mdformat-hallmark/branch/master/graph/badge.svg)](https://codecov.io/gh/calgray/mdformat-hallmark)
[![PyPI version](https://badge.fury.io/py/mdformat-hallmark.svg)](<https://badge.fury.io/py/mdformat-hallmark>)

An [mdformat](https://github.com/executablebooks/mdformat) plugin for compatibility with [hallmark](https://github.com/vweevers/hallmark) formatted Markdown and [Common Changelog](https://common-changelog.org/).
An [mdformat](https://github.com/executablebooks/mdformat) plugin for compatibility with [hallmark](https://github.com/vweevers/hallmark) formatted Markdown and [Common Changelog](https://common-changelog.org/) that allows both formatters and linters to simultaneously pass for quality assurance.

## Features

- `hallmark` style reference formatting for changelogs with blank lines and sort by semantic version.

## Install

Install with:

```sh
pip install mdformat-hallmark
```

## CLI Usage

After installing the plugin, run `mdformat` for Markdown files including Common Changelog files.

```sh
# with extension detected automatically
mdformat README.md CHANGELOG.md

# with extension explicitly required
mdformat --extensions hallmark README.md CHANGELOG.md
```

## Development

Expand Down
6 changes: 0 additions & 6 deletions mdformat_hallmark/hallmark_links_extension.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,6 @@ class SemverReference:
href: str
title: str | None

def __str__(self):
line = f"[{self.label}]: {self.href}"
if self.title:
line += f' "{self.title}"'
return line


def _extract_semver_references(src: str) -> tuple[list[SemverReference], str]:
refs: list[SemverReference] = []
Expand Down
45 changes: 45 additions & 0 deletions tests/fixtures.md
Original file line number Diff line number Diff line change
Expand Up @@ -159,3 +159,48 @@ unsorted changelog test

[0.0.1]: https://example.com
.


extra links changelog test
.
# Changelog

## [1.0.0] - 2025-01-01

### Added

- Commit [JIRA-2]

## [1.1.0] - 2025-01-01

### Added

- Commit [JIRA-1]

[JIRA-2]: https://example.com
[JIRA-1]: https://example.com

[2.10.0]: https://example.com
[10.1.0]: https://example.com
.
# Changelog

## [1.0.0] - 2025-01-01

### Added

- Commit [JIRA-2]

## [1.1.0] - 2025-01-01

### Added

- Commit [JIRA-1]

[10.1.0]: https://example.com

[2.10.0]: https://example.com

[jira-1]: https://example.com
[jira-2]: https://example.com
.
1 change: 0 additions & 1 deletion tests/test_fixtures.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,4 @@
)
def test_fixtures(line, title, text, expected):
output = mdformat.text(text, extensions={"hallmark"})
# output = mdformat.text(text, codeformatters={"python"})
assert output.rstrip() == expected.rstrip(), output
Loading