@@ -23,6 +23,13 @@ attr (ident, classes, other) = Map.fromListWith (\a b -> a <> " " <> b) $
23
23
, (" class" , T. intercalate " " classes)
24
24
] <> other
25
25
26
+ caption :: DomBuilder t m => Caption -> m ()
27
+ caption = \ case
28
+ Caption (Just short) xs -> do
29
+ mapM_ inline short
30
+ mapM_ block xs
31
+ Caption Nothing xs -> mapM_ block xs
32
+
26
33
block :: DomBuilder t m => Block -> m ()
27
34
block = \ case
28
35
Plain xs -> mapM_ inline xs
@@ -42,16 +49,15 @@ block = \case
42
49
Header lvl a xs -> elAttr (" h" <> T. pack (show lvl)) (attr a) $
43
50
mapM_ inline xs
44
51
HorizontalRule -> el " hr" $ pure ()
45
- Table a caption _colSpecs (TableHead hattrs hrows) tbody (TableFoot fattrs frows) ->
52
+ Figure a cap xs -> elAttr " figure" (attr a) $ do
53
+ el " figcaption" $ caption cap
54
+ mapM_ block xs
55
+ Table a cap _colSpecs (TableHead hattrs hrows) tbody (TableFoot fattrs frows) ->
46
56
-- TODO: format columns
47
57
-- TODO: format cells
48
58
-- TODO: handle intermediate table heads in body
49
59
elAttr " table" (attr a) $ do
50
- el " caption" $ case caption of
51
- (Caption (Just short) xs) -> do
52
- mapM_ inline short
53
- mapM_ block xs
54
- (Caption Nothing xs) -> mapM_ block xs
60
+ el " caption" $ caption cap
55
61
let mkRow cell (Row ra cs) = elAttr " tr" (attr ra) $
56
62
mapM_ (\ (Cell ca _align _rowSpan _colSpan ys) ->
57
63
elAttr cell (attr ca) $ mapM_ block ys) cs
@@ -60,7 +66,6 @@ block = \case
60
66
elAttr " tbody" (attr ba) $ mapM_ (mkRow " td" ) cs
61
67
elAttr " tfoot" (attr fattrs) $ mapM_ (mkRow " td" ) frows
62
68
Div a xs -> elAttr " div" (attr a) $ mapM_ block xs
63
- Null -> blank
64
69
where
65
70
listStyle = \ case
66
71
DefaultStyle -> mempty
0 commit comments