git.iko.soy/typeable/pandoc
on master help sign in
Merge pull request #2646 from tarleb/org-figure-with-no-name

Prefix even empty figure names with "fig:"

commit29706ee02dcfd6f211bf3592babf627baae0a3e9 authorJohn MacFarlane <jgm@berkeley.edu> dateSat 20 Feb 2016, 21:44 (11 years ago) parent649cfb6fabbd1a
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>
@@ -629,7 +629,7 @@ figure = try $ do
629629 maybeNam <- lookupBlockAttribute "name"
630630 guard $ isJust maybeCap || isJust maybeNam
631631 return ( fromMaybe mempty maybeCap
632− , maybe mempty withFigPrefix maybeNam )
632+ , withFigPrefix $ fromMaybe mempty maybeNam )
633633 withFigPrefix cs =
634634 if "fig:" `isPrefixOf` cs
635635 then cs
tests/Tests/Readers/Org.hs+4−4
@@ -639,11 +639,11 @@ tests =
639639 ] =?>
640640 para (image "edward.jpg" "fig:goodguy" "A very courageous man.")
641641
642− , "Unnamed figure" =:
643− unlines [ "#+caption: A great whistleblower."
644− , "[[snowden.png]]"
642+ , "Figure with no name" =:
643+ unlines [ "#+caption: I've been through the desert on this"
644+ , "[[horse.png]]"
645645 ] =?>
646− para (image "snowden.png" "" "A great whistleblower.")
646+ para (image "horse.png" "fig:" "I've been through the desert on this")
647647
648648 , "Figure with `fig:` prefix in name" =:
649649 unlines [ "#+caption: Used as a metapher in evolutionary biology."