git.iko.soy/typeable/pandoc
on master help sign in
Prefix even empty figure names with "fig:"

The convention used by pandoc for figures is to mark them by prefixing the name with "fig:". The org reader failed to do this if a figure had no name. The test for this was broken as well. This fixes #2643.

commitfabbd1aa79360dcaadf309308c83e4dab74b60b4 authorAlbert Krewinkel <albert@zeitkraut.de> dateMon 11 Jan 2016, 22:18 (11 years ago) parentf34382e
2 files changed+7−7
src/Text/Pandoc/Readers/Org.hs+3−3 tests/Tests/Readers/Org.hs+4−4
src/Text/Pandoc/Readers/Org.hs+3−3
@@ -2,7 +2,7 @@
22{-# LANGUAGE GeneralizedNewtypeDeriving #-}
33{-# LANGUAGE MultiParamTypeClasses, FlexibleContexts, FlexibleInstances #-}
44{-
5−Copyright (C) 2014-2015 Albert Krewinkel <tarleb+pandoc@moltkeplatz.de>
5+Copyright (C) 2014-2016 Albert Krewinkel <tarleb+pandoc@moltkeplatz.de>
66
77This program is free software; you can redistribute it and/or modify
88it under the terms of the GNU General Public License as published by
@@ -21,7 +21,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
2121
2222{- |
2323 Module : Text.Pandoc.Readers.Org
24− Copyright : Copyright (C) 2014-2015 Albert Krewinkel
24+ Copyright : Copyright (C) 2014-2016 Albert Krewinkel
2525 License : GNU GPL, version 2 or above
2626
2727 Maintainer : Albert Krewinkel <tarleb+pandoc@moltkeplatz.de>
@@ -628,7 +628,7 @@ figure = try $ do
628628 maybeNam <- lookupBlockAttribute "name"
629629 guard $ isJust maybeCap || isJust maybeNam
630630 return ( fromMaybe mempty maybeCap
631− , maybe mempty withFigPrefix maybeNam )
631+ , withFigPrefix $ fromMaybe mempty maybeNam )
632632 withFigPrefix cs =
633633 if "fig:" `isPrefixOf` cs
634634 then cs
tests/Tests/Readers/Org.hs+4−4
@@ -635,11 +635,11 @@ tests =
635635 ] =?>
636636 para (image "edward.jpg" "fig:goodguy" "A very courageous man.")
637637
638− , "Unnamed figure" =:
639− unlines [ "#+caption: A great whistleblower."
640− , "[[snowden.png]]"
638+ , "Figure with no name" =:
639+ unlines [ "#+caption: I've been through the desert on this"
640+ , "[[horse.png]]"
641641 ] =?>
642− para (image "snowden.png" "" "A great whistleblower.")
642+ para (image "horse.png" "fig:" "I've been through the desert on this")
643643
644644 , "Figure with `fig:` prefix in name" =:
645645 unlines [ "#+caption: Used as a metapher in evolutionary biology."