Skip to content

Plan 87: add GitHub Alerts detection and fix to MDS034 - #153

Merged
jeduden merged 7 commits into
mainfrom
claude/plan-87-github-alerts
Apr 22, 2026
Merged

Plan 87: add GitHub Alerts detection and fix to MDS034#153
jeduden merged 7 commits into
mainfrom
claude/plan-87-github-alerts

Conversation

@jeduden

@jeduden jeduden commented Apr 20, 2026

Copy link
Copy Markdown
Owner

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:

    • Configuration support for flavor setting (commonmark, gfm, goldmark)
    • Check() method that reports diagnostics for unsupported features
    • Fix() method that removes GitHub Alert marker lines when the flavor doesn't support them
    • Opt-in by default (disabled unless explicitly configured)
  • Parser caching (parser.go): Provides a singleton goldmark parser with extensions enabled for efficient AST-based detection across multiple files.

  • Comprehensive test coverage:

    • Unit tests for feature detection, flavor parsing, and rule behavior
    • Integration tests for all three flavors with various feature combinations
    • Test fixtures demonstrating good/bad examples and fix behavior
  • Documentation (README.md): Complete rule documentation with feature support matrix, configuration examples, and detected features breakdown.

Notable Implementation Details

  • The detector uses a dual-parse strategy: CommonMark parse for bare URLs and GitHub Alerts, goldmark parse with extensions for other features, then merges results in document order.
  • Bare-URL detection intelligently skips URLs inside links, autolinks, code spans, and code blocks to avoid false positives.
  • GitHub Alerts detection is case-sensitive per GFM spec and matches the five standard tokens (NOTE, TIP, IMPORTANT, WARNING, CAUTION).
  • Finding positions are body-relative (excluding front-matter) with precise byte anchors for features requiring exact spans.
  • The goldmark profile is mdsmith-defined: accepts GFM features plus heading IDs, but rejects optional extensions (footnotes, definition lists, math, abbreviations).

https://claude.ai/code/session_018PqzkvcKjWCSc7k9NAh3wm

Copilot AI review requested due to automatic review settings April 20, 2026 21:04
@codecov

codecov Bot commented Apr 20, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 87.40%. Comparing base (22695b4) to head (62670fc).
⚠️ Report is 8 commits behind head on main.

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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@jeduden jeduden changed the title Add MDS034 markdown-flavor rule for validating against target flavors Plan 87: add GitHub Alerts detection and fix to MDS034 Apr 20, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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/markdownflavor package 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.

Comment thread internal/rules/markdownflavor/features.go
Comment thread internal/rules/MDS034-markdown-flavor/README.md Outdated

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 31 out of 31 changed files in this pull request and generated 1 comment.

Comment thread internal/rules/markdownflavor/rule.go

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 31 out of 31 changed files in this pull request and generated no new comments.

claude added 3 commits April 22, 2026 05:43
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
@jeduden
jeduden force-pushed the claude/plan-87-github-alerts branch from 7b7cf50 to 4ed7236 Compare April 22, 2026 05:48
@jeduden
jeduden requested a review from Copilot April 22, 2026 05:48

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 13 out of 13 changed files in this pull request and generated 2 comments.

Comment thread internal/rules/markdownflavor/rule.go
Comment thread internal/rules/markdownflavor/rule_test.go
… 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

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 13 out of 14 changed files in this pull request and generated 3 comments.

Comment thread internal/rules/MDS034-markdown-flavor/README.md Outdated
Comment thread internal/rules/markdownflavor/rule_test.go Outdated
Comment thread internal/rules/markdownflavor/rule.go
- 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

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 13 out of 14 changed files in this pull request and generated no new comments.

@jeduden jeduden added queue Add to a PR to enqueue it queue:active Applied automatically when a PR is in an active batch labels Apr 22, 2026
@jeduden jeduden removed the queue Add to a PR to enqueue it label Apr 22, 2026
@jeduden

jeduden commented Apr 22, 2026

Copy link
Copy Markdown
Owner Author

🟢 Merge Queue — picked up

This PR is in the queue and will be batched with other queue-labelled PRs.

Next: No action needed — you'll get another comment when CI starts on the batch. View merge queue run.

@jeduden

jeduden commented Apr 22, 2026

Copy link
Copy Markdown
Owner Author

🔵 Merge Queue — CI running

Merged into batch branch merge-queue/batch-153-1776847088. View CI run.

Next: No action needed — you'll be notified when CI completes.

@jeduden
jeduden merged commit afe06e6 into main Apr 22, 2026
16 checks passed
@jeduden jeduden removed the queue:active Applied automatically when a PR is in an active batch label Apr 22, 2026
@jeduden

jeduden commented Apr 22, 2026

Copy link
Copy Markdown
Owner Author

Merge Queue — merged

This PR landed on main via commit afe06e6. CI run that validated the merge.

Next: Done — nothing more to do here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants