mirror of
https://github.com/jgm/pandoc.git
synced 2026-08-31 02:04:53 +08:00
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.
This commit is contained in:
@@ -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
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
> A suggestion.
|
||||
^D
|
||||
[ Div
|
||||
( "" , [ "tip" ] , [] )
|
||||
( "" , [ "alert" , "tip" ] , [] )
|
||||
[ Div ( "" , [ "title" ] , [] ) [ Para [ Str "Tip" ] ]
|
||||
, Para [ Str "A" , Space , Str "suggestion." ]
|
||||
]
|
||||
|
||||
Reference in New Issue
Block a user