Org reader: allow figure with empty caption
A `#+CAPTION` attribute before an image is enough to turn an image into a figure. This wasn't the case because the `parseFromString` function, which processes the caption value, would fail on empty values. Adding a newline character to the caption value fixes this. Fixes: #3161
This commit is contained in:
parent
49b0b67b11
commit
462c140eb6
2 changed files with 7 additions and 3 deletions
|
@ -288,9 +288,7 @@ blockAttributes = try $ do
|
|||
let kvAttrs = foldl' (appendValues "ATTR_HTML") Nothing kv
|
||||
let name = lookup "NAME" kv
|
||||
let label = lookup "LABEL" kv
|
||||
caption' <- maybe (return Nothing)
|
||||
(fmap Just . parseFromString inlines)
|
||||
caption
|
||||
caption' <- sequence (parseFromString inlines . (++ "\n") <$> caption)
|
||||
kvAttrs' <- parseFromString keyValues . (++ "\n") $ fromMaybe mempty kvAttrs
|
||||
return $ BlockAttributes
|
||||
{ blockAttrName = name
|
||||
|
|
|
@ -916,6 +916,12 @@ tests =
|
|||
] =?>
|
||||
let attr = ("fig:myfig", mempty, mempty)
|
||||
in para (imageWith attr "blub.png" "fig:" "My figure")
|
||||
|
||||
, "Figure with empty caption" =:
|
||||
unlines [ "#+CAPTION:"
|
||||
, "[[file:guess.jpg]]"
|
||||
] =?>
|
||||
para (image "guess.jpg" "fig:" "")
|
||||
]
|
||||
|
||||
, "Footnote" =:
|
||||
|
|
Loading…
Reference in a new issue