Skip to content

Commit a5b9cd8

Browse files
authored
Merge pull request #2 from calgray/hook
Add hook, badge and license info
2 parents e6198fa + b707097 commit a5b9cd8

File tree

6 files changed

+83
-10
lines changed

6 files changed

+83
-10
lines changed

.pre-commit-hook.yaml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
- id: mdformat-hallmark
2+
name: mdformat-hallmark
3+
description: "CommonMark compliant Markdown formatter"
4+
entry: mdformat
5+
language: python
6+
types: [markdown]
7+
minimum_pre_commit_version: '1.0.0'
8+
additional_dependencies:
9+
10+
- mdformat-hallmark

LICENSE

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
MIT License
22

3-
Copyright (c) 2025 Executable Books
3+
Copyright (c) 2020 Executable Books
4+
Copyright (c) 2025 Callan Gray
45

56
Permission is hereby granted, free of charge, to any person obtaining a copy
67
of this software and associated documentation files (the "Software"), to deal

README.md

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,34 @@
11
# mdformat-hallmark
22

33
[![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>)
4-
[![codecov.io](https://codecov.io/gh/calgray/mdformat-hallmark/branch/main/graph/badge.svg)](https://codecov.io/gh/xarray-contrib/astropy-xarray)
4+
[![codecov.io](https://codecov.io/gh/calgray/mdformat-hallmark/branch/master/graph/badge.svg)](https://codecov.io/gh/calgray/mdformat-hallmark)
55
[![PyPI version](https://badge.fury.io/py/mdformat-hallmark.svg)](<https://badge.fury.io/py/mdformat-hallmark>)
66

7-
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/).
7+
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.
8+
9+
## Features
10+
11+
- `hallmark` style reference formatting for changelogs with blank lines and sort by semantic version.
12+
13+
## Install
14+
15+
Install with:
16+
17+
```sh
18+
pip install mdformat-hallmark
19+
```
20+
21+
## CLI Usage
22+
23+
After installing the plugin, run `mdformat` for Markdown files including Common Changelog files.
24+
25+
```sh
26+
# with extension detected automatically
27+
mdformat README.md CHANGELOG.md
28+
29+
# with extension explicitly required
30+
mdformat --extensions hallmark README.md CHANGELOG.md
31+
```
832

933
## Development
1034

mdformat_hallmark/hallmark_links_extension.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,6 @@ class SemverReference:
2020
href: str
2121
title: str | None
2222

23-
def __str__(self):
24-
line = f"[{self.label}]: {self.href}"
25-
if self.title:
26-
line += f' "{self.title}"'
27-
return line
28-
2923

3024
def _extract_semver_references(src: str) -> tuple[list[SemverReference], str]:
3125
refs: list[SemverReference] = []

tests/fixtures.md

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,3 +159,48 @@ unsorted changelog test
159159

160160
[0.0.1]: https://example.com
161161
.
162+
163+
164+
extra links changelog test
165+
.
166+
# Changelog
167+
168+
## [1.0.0] - 2025-01-01
169+
170+
### Added
171+
172+
- Commit [JIRA-2]
173+
174+
## [1.1.0] - 2025-01-01
175+
176+
### Added
177+
178+
- Commit [JIRA-1]
179+
180+
[JIRA-2]: https://example.com
181+
[JIRA-1]: https://example.com
182+
183+
[2.10.0]: https://example.com
184+
[10.1.0]: https://example.com
185+
.
186+
# Changelog
187+
188+
## [1.0.0] - 2025-01-01
189+
190+
### Added
191+
192+
- Commit [JIRA-2]
193+
194+
## [1.1.0] - 2025-01-01
195+
196+
### Added
197+
198+
- Commit [JIRA-1]
199+
200+
[10.1.0]: https://example.com
201+
202+
[2.10.0]: https://example.com
203+
204+
[jira-1]: https://example.com
205+
[jira-2]: https://example.com
206+
.

tests/test_fixtures.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,4 @@
1313
)
1414
def test_fixtures(line, title, text, expected):
1515
output = mdformat.text(text, extensions={"hallmark"})
16-
# output = mdformat.text(text, codeformatters={"python"})
1716
assert output.rstrip() == expected.rstrip(), output

0 commit comments

Comments
 (0)