From b707097fd94a23e70c0a35db6b5b76f27a796e28 Mon Sep 17 00:00:00 2001 From: Callan Gray Date: Fri, 22 Aug 2025 23:57:18 +0800 Subject: [PATCH] Update README.md Add hook Badge corrections Improve coverage Signed-off-by: Callan Gray --- .pre-commit-hook.yaml | 10 +++++ LICENSE | 3 +- README.md | 28 +++++++++++- mdformat_hallmark/hallmark_links_extension.py | 6 --- tests/fixtures.md | 45 +++++++++++++++++++ tests/test_fixtures.py | 1 - 6 files changed, 83 insertions(+), 10 deletions(-) create mode 100644 .pre-commit-hook.yaml diff --git a/.pre-commit-hook.yaml b/.pre-commit-hook.yaml new file mode 100644 index 0000000..e5a8efa --- /dev/null +++ b/.pre-commit-hook.yaml @@ -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: + - mdformat@0.7.22 + - mdformat-hallmark diff --git a/LICENSE b/LICENSE index 292a6fc..ec7d018 100644 --- a/LICENSE +++ b/LICENSE @@ -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 diff --git a/README.md b/README.md index f3ae713..4af68a0 100644 --- a/README.md +++ b/README.md @@ -1,10 +1,34 @@ # mdformat-hallmark [![Build Status](https://github.com/calgray/mdformat-hallmark/actions/workflows/tests.yml/badge.svg?branch=master)]() -[![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)]() -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 diff --git a/mdformat_hallmark/hallmark_links_extension.py b/mdformat_hallmark/hallmark_links_extension.py index b7cdeaf..e224cdf 100644 --- a/mdformat_hallmark/hallmark_links_extension.py +++ b/mdformat_hallmark/hallmark_links_extension.py @@ -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] = [] diff --git a/tests/fixtures.md b/tests/fixtures.md index a1cd460..ff46a81 100644 --- a/tests/fixtures.md +++ b/tests/fixtures.md @@ -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 +. diff --git a/tests/test_fixtures.py b/tests/test_fixtures.py index c805a5a..b2273d1 100644 --- a/tests/test_fixtures.py +++ b/tests/test_fixtures.py @@ -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