From fa0dfdf0e146ff5ec97e46dedb3492ebd3a35808 Mon Sep 17 00:00:00 2001 From: Hendrik Erz Date: Sun, 30 Aug 2026 02:25:41 +0200 Subject: [PATCH] Markdown reader: case-insensitive alert keywords (#11836) The keywords (e.g. `TIP`) for GFM-style alerts need not be all caps. This commit fixes that. It also adds the class `alert` to the produced Divs to allow for namespacing. This commit changes the emitted classes from the alert extension of the basic Markdown reader to add the class `alert` to the produced DIVs to allow for namespacing. --- src/Text/Pandoc/Readers/Markdown.hs | 4 ++-- test/command/9716.md | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Text/Pandoc/Readers/Markdown.hs b/src/Text/Pandoc/Readers/Markdown.hs index 99a3fb434..c0a1c5a88 100644 --- a/src/Text/Pandoc/Readers/Markdown.hs +++ b/src/Text/Pandoc/Readers/Markdown.hs @@ -819,7 +819,7 @@ blockQuote = do (do guardEnabled Ext_alerts case raw of (t:ts) | "[!" `T.isPrefixOf` t -> - case T.strip t of + case T.toUpper (T.strip t) of "[!TIP]" -> pure (Just "tip", ts) "[!WARNING]" -> pure (Just "warning", ts) "[!IMPORTANT]" -> pure (Just "important", ts) @@ -834,7 +834,7 @@ blockQuote = do case mbAlert of Nothing -> B.blockQuote <$> contents Just alert -> - (B.divWith ("", [alert], []) + (B.divWith ("", ["alert", alert], []) . (B.divWith ("", ["title"], []) (B.para (B.str (T.toTitle alert))) <>)) <$> contents diff --git a/test/command/9716.md b/test/command/9716.md index 4f340aecc..c7b07f0b5 100644 --- a/test/command/9716.md +++ b/test/command/9716.md @@ -4,7 +4,7 @@ > A suggestion. ^D [ Div - ( "" , [ "tip" ] , [] ) + ( "" , [ "alert" , "tip" ] , [] ) [ Div ( "" , [ "title" ] , [] ) [ Para [ Str "Tip" ] ] , Para [ Str "A" , Space , Str "suggestion." ] ]