@@ -866,7 +866,7 @@ parseBlock (Elem e) =
866
866
" simpara" -> parseMixed para (elContent e)
867
867
" ackno" -> parseMixed para (elContent e)
868
868
" epigraph" -> parseBlockquote
869
- " blockquote" -> parseBlockquote
869
+ " blockquote" -> withOptionalTitle parseBlockquote
870
870
" attribution" -> skip
871
871
" titleabbrev" -> skip
872
872
" authorinitials" -> skip
@@ -917,9 +917,10 @@ parseBlock (Elem e) =
917
917
" question" -> addToStart (strong (str " Q:" ) <> str " " ) <$> getBlocks e
918
918
" answer" -> addToStart (strong (str " A:" ) <> str " " ) <$> getBlocks e
919
919
" abstract" -> blockQuote <$> getBlocks e
920
- " calloutlist" -> bulletList <$> callouts
921
- " itemizedlist" -> bulletList . handleCompact <$> listitems
922
- " orderedlist" -> do
920
+ " calloutlist" -> withOptionalTitle $ bulletList <$> callouts
921
+ " itemizedlist" -> withOptionalTitle $
922
+ bulletList . handleCompact <$> listitems
923
+ " orderedlist" -> withOptionalTitle $ do
923
924
let listStyle = case attrValue " numeration" e of
924
925
" arabic" -> Decimal
925
926
" loweralpha" -> LowerAlpha
@@ -1106,23 +1107,34 @@ parseBlock (Elem e) =
1106
1107
Just t -> Just (" titleabbrev" , strContentRecursive t)
1107
1108
Nothing -> Nothing
1108
1109
lineItems = mapM getInlines $ filterChildren (named " line" ) e
1110
+
1111
+ -- <title> elements can be directly nested inside an admonition block, use
1112
+ -- it if it's there. It is unclear whether we should include the label in
1113
+ -- the title: docbook references are ambiguous on that, and some implementations of admonitions
1114
+ -- (e.g. asciidoctor) just use an icon in all cases. To be conservative, we don't
1115
+ -- include the label and leave it to styling.
1116
+ --
1117
+ getTitle = case filterChild (named " title" ) e of
1118
+ Just t -> Just <$> getInlines t
1119
+ Nothing -> return Nothing
1120
+ withOptionalTitle p = do
1121
+ mbt <- getTitle
1122
+ b <- p
1123
+ case mbt of
1124
+ Nothing -> return b
1125
+ Just t -> return $ divWith (attrValue " id" e,[] ,[] )
1126
+ (divWith (" " , [" title" ], [] ) (plain t) <> b)
1127
+
1109
1128
-- Admonitions are parsed into a div. Following other Docbook tools that output HTML,
1110
1129
-- we parse the optional title as a div with the @title@ class, and give the
1111
1130
-- block itself a class corresponding to the admonition name.
1112
1131
parseAdmonition label = do
1113
- -- <title> elements can be directly nested inside an admonition block, use
1114
- -- it if it's there. It is unclear whether we should include the label in
1115
- -- the title: docbook references are ambiguous on that, and some implementations of admonitions
1116
- -- (e.g. asciidoctor) just use an icon in all cases. To be conservative, we don't
1117
- -- include the label and leave it to styling.
1118
- title <- divWith (" " , [" title" ], [] ) . plain <$>
1119
- case filterChild (named " title" ) e of
1120
- Just t -> getInlines t
1121
- Nothing -> return mempty
1122
- -- this will ignore the title element if it is present
1132
+ mbt <- getTitle
1133
+ -- this will ignore the title element if it is present:
1123
1134
b <- getBlocks e
1135
+ let t = divWith (" " , [" title" ], [] ) (plain $ fromMaybe mempty mbt)
1124
1136
-- we also attach the label as a class, so it can be styled properly
1125
- return $ divWith (attrValue " id" e,[label],[] ) (title <> b)
1137
+ return $ divWith (attrValue " id" e,[label],[] ) (t <> b)
1126
1138
1127
1139
toAlignment :: Element -> Alignment
1128
1140
toAlignment c = case findAttr (unqual " align" ) c of
0 commit comments