Skip to content

Commit 986d178

Browse files
committed
Support pandoc-types 1.23, used by pandoc 3
1 parent 7eb80dc commit 986d178

File tree

2 files changed

+13
-8
lines changed

2 files changed

+13
-8
lines changed

dombuilder-pandoc.cabal

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ library
2020
build-depends: base >=4.12 && <4.15
2121
, containers >= 0.6 && <0.7
2222
, html-parse >= 0.2 && <0.3
23-
, pandoc-types >= 1.22 && <1.23
23+
, pandoc-types >= 1.23 && <1.24
2424
, reflex-dom-core >= 0.7 && < 0.9
2525
, text >= 1.2 && <1.3
2626
-- We don't actually need aeson, but pandoc-types has a too-lenient bound

src/Reflex/Dom/Builder/Pandoc.hs

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,13 @@ attr (ident, classes, other) = Map.fromListWith (\a b -> a <> " " <> b) $
2323
, ("class", T.intercalate " " classes)
2424
] <> other
2525

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+
2633
block :: DomBuilder t m => Block -> m ()
2734
block = \case
2835
Plain xs -> mapM_ inline xs
@@ -42,16 +49,15 @@ block = \case
4249
Header lvl a xs -> elAttr ("h" <> T.pack (show lvl)) (attr a) $
4350
mapM_ inline xs
4451
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) ->
4656
-- TODO: format columns
4757
-- TODO: format cells
4858
-- TODO: handle intermediate table heads in body
4959
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
5561
let mkRow cell (Row ra cs) = elAttr "tr" (attr ra) $
5662
mapM_ (\(Cell ca _align _rowSpan _colSpan ys) ->
5763
elAttr cell (attr ca) $ mapM_ block ys) cs
@@ -60,7 +66,6 @@ block = \case
6066
elAttr "tbody" (attr ba) $ mapM_ (mkRow "td") cs
6167
elAttr "tfoot" (attr fattrs) $ mapM_ (mkRow "td") frows
6268
Div a xs -> elAttr "div" (attr a) $ mapM_ block xs
63-
Null -> blank
6469
where
6570
listStyle = \case
6671
DefaultStyle -> mempty

0 commit comments

Comments
 (0)