aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJohn MacFarlane <[email protected]>2023-12-05 09:38:47 -0800
committerJohn MacFarlane <[email protected]>2023-12-05 09:38:47 -0800
commitfe351f1fd5f12cb043bd6996f3fa650af7846832 (patch)
tree44daaf335854701085c8e90401ef1bfeb2292021 /src
parent64bc8ab9c261e7844f3e991a5e6f538bb3564832 (diff)
Fine-tuning on alerts.
Added a test to show that we can convert smoothly between gfm, rst, and asciidoc alerts.
Diffstat (limited to 'src')
-rw-r--r--src/Text/Pandoc/Writers/AsciiDoc.hs4
-rw-r--r--src/Text/Pandoc/Writers/Markdown.hs19
2 files changed, 13 insertions, 10 deletions
diff --git a/src/Text/Pandoc/Writers/AsciiDoc.hs b/src/Text/Pandoc/Writers/AsciiDoc.hs
index a4f4809e4..6eb095626 100644
--- a/src/Text/Pandoc/Writers/AsciiDoc.hs
+++ b/src/Text/Pandoc/Writers/AsciiDoc.hs
@@ -354,7 +354,9 @@ blockToAsciiDoc opts (Div (ident,classes,_) bs) = do
case bs of
(Div (_,["title"],_) ts : rest) -> (ts, rest)
_ -> ([], bs)
- admonitionTitle <- if null titleBs
+ admonitionTitle <- if null titleBs ||
+ -- If title matches class, omit
+ (T.toLower (T.strip (stringify titleBs))) == l
then return mempty
else ("." <>) <$>
blockListToAsciiDoc opts titleBs
diff --git a/src/Text/Pandoc/Writers/Markdown.hs b/src/Text/Pandoc/Writers/Markdown.hs
index cf1b36807..877e54b72 100644
--- a/src/Text/Pandoc/Writers/Markdown.hs
+++ b/src/Text/Pandoc/Writers/Markdown.hs
@@ -370,16 +370,17 @@ blockToMarkdown' :: PandocMonad m
-> MD m (Doc Text)
blockToMarkdown' opts (Div attrs@(_,classes,_) bs)
| isEnabled Ext_alerts opts
- , "alert" `elem` classes
- , (Div ("", ["alert-title"], []) _ : Para ils : bs') <- bs
+ , (cls:_) <- classes
+ , cls `elem` ["note", "tip", "warning", "caution", "important"]
+ , (Div ("", ["title"], []) _ : Para ils : bs') <- bs
= blockToMarkdown' opts $ BlockQuote $
- (Para (RawInline (Format "markdown") (case () of
- _ | "alert-note" `elem` classes -> "[!NOTE]\n"
- _ | "alert-tip" `elem` classes -> "[!TIP]\n"
- _ | "alert-warning" `elem` classes -> "[!WARNING]\n"
- _ | "alert-caution" `elem` classes -> "[!CAUTION]\n"
- _ | "alert-important" `elem` classes -> "[!IMPORTANT]\n"
- | otherwise -> "[!NOTE]\n") : ils)) : bs'
+ (Para (RawInline (Format "markdown") (case cls of
+ "note" -> "[!NOTE]\n"
+ "tip" -> "[!TIP]\n"
+ "warning" -> "[!WARNING]\n"
+ "caution" -> "[!CAUTION]\n"
+ "important" -> "[!IMPORTANT]\n"
+ _ -> "[!NOTE]\n") : ils)) : bs'
| otherwise = do
contents <- blockListToMarkdown opts bs
variant <- asks envVariant