mirror of
https://github.com/jgm/pandoc.git
synced 2026-09-21 15:05:47 +00:00
Fine-tuning on alerts.
Added a test to show that we can convert smoothly between gfm, rst, and asciidoc alerts.
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
```
|
||||
% pandoc -f rst -t gfm
|
||||
.. note::
|
||||
This is my note.
|
||||
^D
|
||||
> [!NOTE]
|
||||
> This is my note.
|
||||
```
|
||||
|
||||
```
|
||||
% pandoc -f gfm -t rst
|
||||
> [!WARNING]
|
||||
> Be careful!
|
||||
^D
|
||||
.. warning::
|
||||
|
||||
Be careful!
|
||||
```
|
||||
|
||||
```
|
||||
% pandoc -f gfm -t asciidoc
|
||||
> [!TIP]
|
||||
> A tip.
|
||||
^D
|
||||
[TIP]
|
||||
====
|
||||
A tip.
|
||||
====
|
||||
```
|
||||
Reference in New Issue
Block a user