aboutsummaryrefslogtreecommitdiff
path: root/src/Text
diff options
context:
space:
mode:
authorJohn MacFarlane <[email protected]>2024-08-01 08:06:16 -0700
committerJohn MacFarlane <[email protected]>2024-08-01 08:06:45 -0700
commit3d0faf692708f9977a485ade57d67f2d528da817 (patch)
tree5799e8d9a858976bcac49ada7ed668a5ecb111df /src/Text
parent0494f71e4c1b0dfbaf13d02bb47a17b756b756ac (diff)
AsciiDoc writer: don't emit empty figure caption.
Closes #10047.
Diffstat (limited to 'src/Text')
-rw-r--r--src/Text/Pandoc/Writers/AsciiDoc.hs8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/Text/Pandoc/Writers/AsciiDoc.hs b/src/Text/Pandoc/Writers/AsciiDoc.hs
index f019cb51a..b315f0e92 100644
--- a/src/Text/Pandoc/Writers/AsciiDoc.hs
+++ b/src/Text/Pandoc/Writers/AsciiDoc.hs
@@ -204,7 +204,10 @@ blockToAsciiDoc opts (Header level (ident,_,_) inlines) = do
blockToAsciiDoc opts (Figure attr (Caption _ longcapt) body) = do
-- Images in figures all get rendered as individual block-level images
-- with the given caption. Non-image elements are rendered unchanged.
- capt <- inlineListToAsciiDoc opts (blocksToInlines longcapt)
+ capt <- if null longcapt
+ then pure mempty
+ else ("." <>) . nowrap <$>
+ inlineListToAsciiDoc opts (blocksToInlines longcapt)
let renderFigElement = \case
Plain [Image imgAttr alternate (src, tit)] -> do
args <- imageArguments opts imgAttr alternate src tit
@@ -213,7 +216,8 @@ blockToAsciiDoc opts (Figure attr (Caption _ longcapt) body) = do
(ident, _, _) -> literal $ "[#" <> ident <> "]"
-- .Figure caption
-- image::images/logo.png[Company logo, title="blah"]
- return $ "." <> nowrap capt $$
+ return $
+ capt $$
figAttributes $$
"image::" <> args <> blankline
blk -> blockToAsciiDoc opts blk