git.iko.soy/typeable/pandoc
on master help sign in
LaTeX reader: Handle \caption for images in figures.

Closes #766.

commit52ee09608a3ada9ce465f2a0b0feef62bd7a9bde authorJohn MacFarlane <fiddlosopher@gmail.com> dateTue 26 Feb 2013, 22:16 (14 years ago) parent3fca434
1 file changed+6−3
src/Text/Pandoc/Readers/LaTeX.hs+6−3
src/Text/Pandoc/Readers/LaTeX.hs+6−3
@@ -498,12 +498,15 @@ inlineCommands = M.fromList $
498498 [ "noindent", "index", "nocite" ]
499499
500500mkImage :: String -> LP Inlines
501−mkImage src =
501+mkImage src = do
502+ -- try for a caption
503+ alt <- option (str "image") $ try $ spaces >>
504+ controlSeq "caption" >> optional (char '*') >> grouped inline
502505 case takeExtension src of
503506 "" -> do
504507 defaultExt <- getOption readerDefaultImageExtension
505− return $ image (addExtension src defaultExt) "" (str "image")
506− _ -> return $ image src "" (str "image")
508+ return $ image (addExtension src defaultExt) "" alt
509+ _ -> return $ image src "" alt
507510
508511inNote :: Inlines -> Inlines
509512inNote ils =