@@ -39,7 +39,7 @@ import Control.Applicative (many, optional, (<|>))
3939import Control.Monad
4040import Control.Monad.Except (throwError)
4141import Data.Char (chr, isAlphaNum, isLetter, ord)
42−import Data.List (intercalate)
42+import Data.List (intercalate, isPrefixOf)
4343import qualified Data.Map as M
4444import Data.Maybe (fromMaybe, maybeToList)
4545import Safe (minimumDef)
@@ -1111,10 +1111,11 @@ rawLaTeXInline = do
11111111
11121112addImageCaption :: PandocMonad m => Blocks -> LP m Blocks
11131113addImageCaption = walkM go
1114− where go (Image attr alt (src,tit)) = do
1114+ where go (Image attr alt (src,tit))
1115+ | not ("fig:" `isPrefixOf` tit) = do
11151116 mbcapt <- stateCaption <$> getState
11161117 return $ case mbcapt of
1117− Just ils -> Image attr (toList ils) (src, "fig:")
1118+ Just ils -> Image attr (toList ils) (src, "fig:" ++ tit)
11181119 Nothing -> Image attr alt (src,tit)
11191120 go x = return x
11201121
@@ -1134,8 +1135,8 @@ environments = M.fromList
11341135 , ("letter", env "letter" letterContents)
11351136 , ("minipage", env "minipage" $
11361137 skipopts *> spaces' *> optional braced *> spaces' *> blocks)
1137− , ("figure", env "figure" $
1138− resetCaption *> skipopts *> blocks >>= addImageCaption)
1138+ , ("figure", env "figure" $ skipopts *> figure)
1139+ , ("subfigure", env "subfigure" $ skipopts *> tok *> figure)
11391140 , ("center", env "center" blocks)
11401141 , ("longtable", env "longtable" $
11411142 resetCaption *> simpTable False >>= addTableCaption)
@@ -1187,6 +1188,11 @@ environments = M.fromList
11871188 , ("alignat*", mathEnv para (Just "aligned") "alignat*")
11881189 ]
11891190
1191+figure :: PandocMonad m => LP m Blocks
1192+figure = try $ do
1193+ resetCaption
1194+ blocks >>= addImageCaption
1195+
11901196letterContents :: PandocMonad m => LP m Blocks
11911197letterContents = do
11921198 bs <- blocks