@@ -619,19 +619,23 @@ instance HasMeta DBState where
619619 deleteMeta field s = s {dbMeta = deleteMeta field (dbMeta s)}
620620
621621isBlockElement :: Content -> Bool
622−isBlockElement (Elem e) = qName (elName e) `elem` blocktags
623− where blocktags = ["toc","index","para","formalpara","simpara",
622+isBlockElement (Elem e) = qName (elName e) `elem` blockTags
623+isBlockElement _ = False
624+
625+blockTags :: [String]
626+blockTags = ["toc","index","para","formalpara","simpara",
624627 "ackno","epigraph","blockquote","bibliography","bibliodiv",
625628 "biblioentry","glossee","glosseealso","glossary",
626629 "glossdiv","glosslist","chapter","appendix","preface",
627630 "bridgehead","sect1","sect2","sect3","sect4","sect5","section",
628− "refsect1","refsect2","refsect3","refsection",
629− "important","caution","note","tip","warning","qandadiv",
631+ "refsect1","refsect2","refsect3","refsection", "qandadiv",
630632 "question","answer","abstract","itemizedlist","orderedlist",
631633 "variablelist","article","book","table","informaltable",
632634 "informalexample", "linegroup",
633− "screen","programlisting","example","calloutlist"]
634−isBlockElement _ = False
635+ "screen","programlisting","example","calloutlist"] ++ admonitionTags
636+
637+admonitionTags :: [String]
638+admonitionTags = ["important","caution","note","tip","warning"]
635639
636640-- Trim leading and trailing newline characters
637641trimNl :: String -> String
@@ -736,16 +740,7 @@ parseBlock (Elem e) =
736740 "refsect2" -> sect 2
737741 "refsect3" -> sect 3
738742 "refsection" -> gets dbSectionLevel >>= sect . (+1)
739− "important" -> blockQuote . (para (strong $ str "Important") <>)
740− <$> getBlocks e
741− "caution" -> blockQuote . (para (strong $ str "Caution") <>)
742− <$> getBlocks e
743− "note" -> blockQuote . (para (strong $ str "Note") <>)
744− <$> getBlocks e
745− "tip" -> blockQuote . (para (strong $ str "Tip") <>)
746− <$> getBlocks e
747− "warning" -> blockQuote . (para (strong $ str "Warning") <>)
748− <$> getBlocks e
743+ l@_ | l `elem` admonitionTags -> parseAdmonition l
749744 "area" -> skip
750745 "areaset" -> skip
751746 "areaspec" -> skip
@@ -913,6 +908,22 @@ parseBlock (Elem e) =
913908 modify $ \st -> st{ dbSectionLevel = n - 1 }
914909 return $ headerWith (ident,[],[]) n' headerText <> b
915910 lineItems = mapM getInlines $ filterChildren (named "line") e
911+ -- | Admonitions are parsed into a div. Following other Docbook tools that output HTML,
912+ -- we parse the optional title as a div with the @title@ class, and give the
913+ -- block itself a class corresponding to the admonition name.
914+ parseAdmonition label = do
915+ -- <title> elements can be directly nested inside an admonition block, use
916+ -- it if it's there. It is unclear whether we should include the label in
917+ -- the title: docbook references are ambiguous on that, and some implementations of admonitions
918+ -- (e.g. asciidoctor) just use an icon in all cases. To be conservative, we don't
919+ -- include the label and leave it to styling.
920+ title <- case filterChild (named "title") e of
921+ Just t -> divWith ("", ["title"], []) . plain <$> getInlines t
922+ Nothing -> return $ mempty
923+ -- this will ignore the title element if it is present
924+ b <- getBlocks e
925+ -- we also attach the label as a class, so it can be styled properly
926+ return $ divWith (attrValue "id" e,[label],[]) (title <> b)
916927
917928getInlines :: PandocMonad m => Element -> DB m Inlines
918929getInlines e' = (trimInlines . mconcat) <$>