Plan 87: add GitHub Alerts detection and fix to MDS034 - #153
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #153 +/- ##
==========================================
+ Coverage 87.32% 87.40% +0.07%
==========================================
Files 107 107
Lines 13220 13300 +80
==========================================
+ Hits 11545 11625 +80
Misses 1218 1218
Partials 457 457 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Pull request overview
Implements a new opt-in rule (MDS034) to validate Markdown syntax against a configured target flavor (commonmark, gfm, goldmark), including detection/fixing for GitHub Alerts, and wires the rule into the CLI + integration fixture runner.
Changes:
- Added
internal/rules/markdownflavorpackage implementing MDS034 (feature registry, detectors, shared parser, rule + fixes) with unit tests. - Added MDS034 rule documentation and fixtures (good/bad/fixed) and registered the rule in the CLI + rule index.
- Updated integration fixture harness to avoid
MDS033’s process-level warning leaking across fixture runs.
Reviewed changes
Copilot reviewed 31 out of 31 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| plan/87_markdown-flavor-github-alerts.md | Marks GitHub Alerts flavor validation plan as completed with tasks checked off. |
| plan/86_markdown-flavor-validation.md | Updates plan 86 status and task breakdown to reflect partial completion. |
| internal/rules/markdownflavor/features.go | Defines flavors/features and flavor support table for MDS034. |
| internal/rules/markdownflavor/features_test.go | Tests for flavor parsing/stringification and support matrix expectations. |
| internal/rules/markdownflavor/parser.go | Adds cached goldmark parser with extensions enabled for AST-based detection. |
| internal/rules/markdownflavor/parser_test.go | Verifies cached parser instance and that key extension nodes appear in the AST. |
| internal/rules/markdownflavor/detect.go | Implements feature detection (dual parse + regex/pattern detectors) and finding ordering. |
| internal/rules/markdownflavor/detect_test.go | Unit tests for detectors, filtering behavior, and ordering. |
| internal/rules/markdownflavor/rule.go | Implements MDS034 rule Check/Fix and config handling; registers rule. |
| internal/rules/markdownflavor/rule_test.go | Unit tests for rule identity/config, diagnostics, flavor behavior, and Fix for alerts. |
| internal/rules/MDS034-markdown-flavor/README.md | Adds rule documentation, settings, feature matrix, and examples. |
| internal/rules/MDS034-markdown-flavor/good/commonmark.md | “Good” fixture for commonmark flavor. |
| internal/rules/MDS034-markdown-flavor/good/gfm.md | “Good” fixture for gfm flavor. |
| internal/rules/MDS034-markdown-flavor/good/goldmark.md | “Good” fixture for goldmark flavor. |
| internal/rules/MDS034-markdown-flavor/bad/commonmark-task-list.md | “Bad” fixture asserting task list diagnostics under commonmark. |
| internal/rules/MDS034-markdown-flavor/bad/commonmark-table.md | “Bad” fixture asserting table diagnostics under commonmark. |
| internal/rules/MDS034-markdown-flavor/bad/commonmark-strikethrough.md | “Bad” fixture asserting strikethrough diagnostics under commonmark. |
| internal/rules/MDS034-markdown-flavor/bad/commonmark-heading-id.md | “Bad” fixture asserting heading-ID diagnostics under commonmark. |
| internal/rules/MDS034-markdown-flavor/bad/commonmark-bare-url.md | “Bad” fixture asserting bare-URL diagnostics under commonmark. |
| internal/rules/MDS034-markdown-flavor/bad/commonmark-github-alerts.md | “Bad” fixture asserting GitHub Alerts diagnostics under commonmark. |
| internal/rules/MDS034-markdown-flavor/bad/gfm-heading-id.md | “Bad” fixture asserting heading-ID diagnostics under gfm. |
| internal/rules/MDS034-markdown-flavor/bad/gfm-footnote.md | “Bad” fixture asserting footnote diagnostics under gfm. |
| internal/rules/MDS034-markdown-flavor/bad/gfm-definition-list.md | “Bad” fixture asserting definition list diagnostics under gfm. |
| internal/rules/MDS034-markdown-flavor/bad/goldmark-github-alerts.md | “Bad” fixture asserting GitHub Alerts diagnostics under goldmark. |
| internal/rules/MDS034-markdown-flavor/fixed/commonmark-github-alerts.md | Expected fixed output after removing alert marker under commonmark. |
| internal/rules/MDS034-markdown-flavor/fixed/goldmark-github-alerts.md | Expected fixed output after removing alert marker under goldmark. |
| internal/rules/index.md | Adds MDS034 to the internal rule catalog. |
| internal/rules/directorystructure/rule.go | Adds test helper to silence the process-level config warning. |
| internal/integration/rules_test.go | Imports and uses the new silence helper; registers markdownflavor rule for fixtures. |
| cmd/mdsmith/main.go | Registers markdownflavor rule package in the CLI. |
| PLAN.md | Updates plan catalog statuses for plan 86/87. |
Extends MDS034 with FeatureGitHubAlerts (feature 13): detects > [!NOTE/TIP/IMPORTANT/WARNING/CAUTION] blockquotes as GFM-only syntax and auto-fixes by removing the marker line. Adds bad/fixed fixtures and updates the README. https://claude.ai/code/session_018PqzkvcKjWCSc7k9NAh3wm
…feature count in README
7b7cf50 to
4ed7236
Compare
… tests
- Remove unreachable defensive nil/empty-lines check from isGitHubAlert
(goldmark Paragraphs always have at least one line)
- Fix lazy-continuation prefix: preserve leading whitespace before "> "
so indented blockquotes (e.g. inside a list) stay correctly nested
- Add TestRuleCheckNestedAlert and TestRuleFixNestedAlert: nested alert
("> > [!NOTE]") is detected and its marker stripped by Fix
- Add TestRuleFixIndentedLazyContinuation: verifies the indentation fix
- Add TestRuleFixNoAlerts and TestRuleFixHeadingBlockquote for Fix edge
cases (no alerts in doc; non-paragraph first child in blockquote)
https://claude.ai/code/session_018PqzkvcKjWCSc7k9NAh3wm
- README: change "Fixable: yes" to "partially (GitHub Alerts only)" since Fix() only removes alert markers, not other unsupported syntax - TestRuleCheckGFMAcceptsAlerts: use require.Empty instead of a loop so the assertion truly validates GFM accepts the alert with zero diags https://claude.ai/code/session_018PqzkvcKjWCSc7k9NAh3wm
|
🟢 Merge Queue — picked up This PR is in the queue and will be batched with other Next: No action needed — you'll get another comment when CI starts on the batch. View merge queue run. |
|
🔵 Merge Queue — CI running Merged into batch branch Next: No action needed — you'll be notified when CI completes. |
|
✅ Merge Queue — merged This PR landed on Next: Done — nothing more to do here. |
Summary
Implements MDS034, a new linting rule that validates Markdown syntax against a declared target flavor (CommonMark, GFM, or Goldmark) and flags unsupported syntax features.
Key Changes
Feature detection system (
features.go): Defines 13 tracked Markdown features (tables, task lists, strikethrough, bare-URL autolinks, footnotes, definition lists, heading IDs, superscript, subscript, math blocks/inline, abbreviations, GitHub alerts) and maps their support across three flavors.Dual-parser AST detection (
detect.go): Implements comprehensive feature detection using goldmark's built-in extensions for tables, strikethrough, task lists, footnotes, definition lists, and heading IDs. Includes specialized detectors for bare-URL autolinks (regex-based text scanning) and GitHub Alerts (blockquote pattern matching).Rule implementation (
rule.go): Implements the MDS034 rule with:flavorsetting (commonmark, gfm, goldmark)Check()method that reports diagnostics for unsupported featuresFix()method that removes GitHub Alert marker lines when the flavor doesn't support themParser caching (
parser.go): Provides a singleton goldmark parser with extensions enabled for efficient AST-based detection across multiple files.Comprehensive test coverage:
Documentation (
README.md): Complete rule documentation with feature support matrix, configuration examples, and detected features breakdown.Notable Implementation Details
https://claude.ai/code/session_018PqzkvcKjWCSc7k9NAh3wm