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:
Albert Krewinkel 2016-10-14 23:16:51 +02:00
parent 49b0b67b11
commit 462c140eb6
No known key found for this signature in database
GPG key ID: 388DC0B21F631124
2 changed files with 7 additions and 3 deletions

View file

@ -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

View file

@ -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" =: