]> git.maquefel.me Git - brevno-suite/hugo/commitdiff
markup/goldmark/blockquotes: Fix handling of lower/mixed case GitHub alerts
authorBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>
Wed, 14 Aug 2024 14:57:18 +0000 (16:57 +0200)
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>
Wed, 14 Aug 2024 16:09:04 +0000 (18:09 +0200)
Fixes #12767

markup/goldmark/blockquotes/blockquotes.go
markup/goldmark/blockquotes/blockquotes_integration_test.go

index 2f5629d87dbd6c90d1bbb8bcc8af22c6e962d62d..d26c92669fdbc24baf52df7c698b055f2ead920f 100644 (file)
@@ -237,7 +237,8 @@ var _ hooks.PositionerSourceTargetProvider = (*blockquoteContext)(nil)
 // https://docs.github.com/en/get-started/writing-on-github/getting-started-with-writing-and-formatting-on-github/basic-writing-and-formatting-syntax#alerts
 // Five types:
 // [!NOTE], [!TIP], [!WARNING], [!IMPORTANT], [!CAUTION]
-var gitHubAlertRe = regexp.MustCompile(`^<p>\[!(NOTE|TIP|WARNING|IMPORTANT|CAUTION)\]`)
+// Note that GitHub's implementation is case-insensitive.
+var gitHubAlertRe = regexp.MustCompile(`(?i)^<p>\[!(NOTE|TIP|WARNING|IMPORTANT|CAUTION)\]`)
 
 // resolveGitHubAlert returns one of note, tip, warning, important or caution.
 // An empty string if no match.
index 45c031098fcb449bc6bdc6fa85b2e33e0617ec4a..e4447e5e9b492324bb7cae15f2e4b83b2d11dc56 100644 (file)
@@ -68,6 +68,11 @@ title: "p1"
 > Note triggering showing the position.
 {showpos="true"}
 
+
+> [!nOtE]  
+> Mixed case alert type.
+
+
 `
 
        b := hugolib.Test(t, files)
@@ -79,6 +84,9 @@ title: "p1"
                "Blockquote Alert Attributes: |<p>This is a tip with attributes.</p>\n|map[class:foo bar id:baz]|",
                filepath.FromSlash("/content/p1.md:20:3"),
                "Blockquote Alert Page: |<p>This is a tip with attributes.</p>\n|p1|p1|",
+
+               // Issue 12767.
+               "Blockquote Alert: |<p>Mixed case alert type.</p>\n|alert",
        )
 }