-
Notifications
You must be signed in to change notification settings - Fork 1
Add plans 87 and 88: GitHub Alerts and TOC directive rules #139
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
28cc348
plan: add 87 (GitHub Alerts) and 88 (TOC migration)
claude c878ad9
plan 88: clarify catalog use-case, fix error message
claude 08665c7
plan 88: conform error style, handle [TOC] link-ref ambiguity
claude eb3513a
plan 88: correct failure description and error message style
claude 0031023
plan 88: backtick <?catalog?> in example error message
claude 7c7a4d0
plan 88: make error message template explicit for all tokens
claude b7b5f00
plans 87, 88: tighten failure-mode and CommonMark wording
claude 417a0cb
ci: bump merge-queue-action to v0.5.0
claude File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,155 @@ | ||
| --- | ||
| id: 87 | ||
| title: Flavor validation for GitHub Alerts | ||
| status: "🔲" | ||
| summary: >- | ||
| Extend MDS034 to detect GitHub Alerts syntax | ||
| (`> [!NOTE]` blockquote prefix) as a GFM-only | ||
| feature with auto-fix that demotes the alert to | ||
| a plain blockquote when the target flavor does | ||
| not support it. | ||
| --- | ||
| # Flavor validation for GitHub Alerts | ||
|
|
||
| Extends [plan 86](86_markdown-flavor-validation.md) | ||
| (MDS034, flavor validation). Add one feature — | ||
| GitHub Alerts — to the MDS034 feature enum. | ||
|
|
||
| Depends on: plan 86 lands first (provides the | ||
| dual parser, feature enum, fix pipeline). | ||
|
|
||
| ## Goal | ||
|
|
||
| MDS034 flags `> [!NOTE]`-style alert blockquotes | ||
| when the target flavor is `commonmark` or | ||
| `goldmark`. `gfm` accepts them. Auto-fix demotes | ||
| the alert marker so the blockquote still renders | ||
| on non-GFM renderers. | ||
|
|
||
| ## Context | ||
|
|
||
| GitHub added Alerts to GFM in December 2023 | ||
| (see the `github.blog` changelog entry for | ||
| `new-syntax-for-alerts-on-github`). Five tokens | ||
| are recognized: `[!NOTE]`, `[!TIP]`, | ||
| `[!IMPORTANT]`, `[!WARNING]`, `[!CAUTION]`. | ||
| Obsidian callouts use the same prefix and accept | ||
| extra tokens, but only these five are standard | ||
| GFM. | ||
|
|
||
| On CommonMark / goldmark-default, the marker | ||
| renders as literal text inside a blockquote: | ||
|
|
||
| ```markdown | ||
| > [!NOTE] | ||
| > Something to remember. | ||
| ``` | ||
|
|
||
| becomes a blockquote whose first line is the | ||
| literal string `[!NOTE]`. The author intended a | ||
| styled callout; the reader sees unstyled text | ||
| with the marker token visible inside the | ||
| blockquote. The failure is visible, not silent, | ||
| but the author's intent is still lost. | ||
|
|
||
| ### Why not a generic container rule | ||
|
|
||
| The research spike evaluated four other | ||
| container syntaxes (Pandoc `:::` fenced divs, | ||
| MyST `:::{note}`, markdown-it-container, MkDocs | ||
| `!!! note`). None are mutually compatible and no | ||
| linter in the comparison covers them. GitHub | ||
| Alerts are the only variant with a standardized | ||
| spec, broad renderer support, and a clear | ||
| failure mode — so this plan covers them alone. | ||
|
|
||
| ## Design | ||
|
|
||
| ### Detection | ||
|
|
||
| GitHub Alerts need no new goldmark extension. | ||
| The syntax is a plain Blockquote. Its first | ||
| paragraph text must match | ||
| `^\[!(NOTE|TIP|IMPORTANT|WARNING|CAUTION)\]\s*$` | ||
| (case-sensitive per GFM). | ||
|
|
||
| Detection is an AST walk over `ast.Blockquote` | ||
| nodes on the dual parser's tree. The same walk | ||
| pattern the other 12 features use. | ||
|
|
||
| ### Configuration | ||
|
|
||
| No new settings. GitHub Alerts join the existing | ||
| feature enum in | ||
| `internal/rules/markdownflavor/features.go` as | ||
| feature 13 (`GitHubAlerts`). Flavor support: | ||
|
|
||
| | Flavor | GitHub Alerts | | ||
| |------------|---------------| | ||
| | commonmark | unsupported | | ||
| | gfm | supported | | ||
| | goldmark | unsupported | | ||
|
|
||
|
jeduden marked this conversation as resolved.
|
||
| ### Auto-fix | ||
|
|
||
| Remove the `[!TOKEN]` marker line, keeping the | ||
| rest of the blockquote intact: | ||
|
|
||
| ```markdown | ||
| > [!NOTE] > Something to | ||
| > Something to → > remember. | ||
| > remember. | ||
| ``` | ||
|
|
||
| If the alert marker is the only line in the | ||
| blockquote, remove the whole blockquote. The | ||
| marker line has no meaningful content once the | ||
| token is gone. | ||
|
|
||
| ### Error message | ||
|
|
||
| `github alerts are not supported by {flavor}` | ||
|
|
||
| Severity: `warning`, matching the other MDS034 | ||
| features. | ||
|
|
||
| ## Tasks | ||
|
|
||
| 1. Add `GitHubAlerts` to the feature enum in | ||
| `internal/rules/markdownflavor/features.go` | ||
| 2. Add flavor support table entry: supported in | ||
| `gfm`, unsupported in `commonmark` and | ||
| `goldmark` | ||
| 3. Implement an AST detector that walks | ||
| `ast.Blockquote` nodes and matches the five | ||
| GFM tokens on the first paragraph child | ||
| 4. Implement the fix: strip the marker line; | ||
| drop the blockquote if empty afterward | ||
| 5. Add unit tests: each of the five tokens, | ||
| lower-case tokens (should not match), mixed | ||
| content after the marker, marker as the only | ||
| line | ||
| 6. Add good/bad fixtures under | ||
| `internal/rules/MDS034-markdown-flavor/alerts/` | ||
| 7. Update the MDS034 README to list GitHub | ||
| Alerts as the 13th feature | ||
|
|
||
| ## Acceptance Criteria | ||
|
|
||
| - [ ] `flavor: commonmark` flags all five alert | ||
| tokens | ||
| - [ ] `flavor: goldmark` flags all five alert | ||
| tokens | ||
| - [ ] `flavor: gfm` accepts all five tokens | ||
| - [ ] `mdsmith fix` removes the marker line, | ||
| preserves remaining blockquote content | ||
| - [ ] `mdsmith fix` removes the whole blockquote | ||
| when the marker was its only line | ||
| - [ ] Lower-case or unknown tokens (e.g. | ||
| `[!note]`, `[!INFO]`) produce no | ||
| diagnostic — they are ordinary blockquote | ||
| text | ||
| - [ ] Nested blockquotes are checked recursively | ||
| - [ ] All tests pass: `go test ./...` | ||
| - [ ] `go tool golangci-lint run` reports no | ||
| issues | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.