From 58ea1ce5f1754323e129610f96a41e919323de11 Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Mon, 15 Dec 2014 21:49:35 -0800 Subject: LaTeX reader: parse label after caption into a span... instead of inserting an additional paragraph of bracketed text. Closes #1747. --- src/Text/Pandoc/Readers/LaTeX.hs | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'src/Text/Pandoc/Readers') diff --git a/src/Text/Pandoc/Readers/LaTeX.hs b/src/Text/Pandoc/Readers/LaTeX.hs index 5a3ba4808..1e02b4fc3 100644 --- a/src/Text/Pandoc/Readers/LaTeX.hs +++ b/src/Text/Pandoc/Readers/LaTeX.hs @@ -304,7 +304,7 @@ blockCommands = M.fromList $ , ("item", skipopts *> loose_item) , ("documentclass", skipopts *> braced *> preamble) , ("centerline", (para . trimInlines) <$> (skipopts *> tok)) - , ("caption", skipopts *> tok >>= setCaption) + , ("caption", skipopts *> setCaption) , ("PandocStartInclude", startInclude) , ("PandocEndInclude", endInclude) , ("bibliography", mempty <$ (skipopts *> braced >>= @@ -336,9 +336,16 @@ addMeta field val = updateState $ \st -> splitBibs :: String -> [Inlines] splitBibs = map (str . flip replaceExtension "bib" . trim) . splitBy (==',') -setCaption :: Inlines -> LP Blocks -setCaption ils = do - updateState $ \st -> st{ stateCaption = Just ils } +setCaption :: LP Blocks +setCaption = do + ils <- tok + mblabel <- option Nothing $ + try $ spaces >> controlSeq "label" >> (Just <$> tok) + let ils' = case mblabel of + Just lab -> ils <> spanWith + ("",[],[("data-label", stringify lab)]) mempty + Nothing -> ils + updateState $ \st -> st{ stateCaption = Just ils' } return mempty resetCaption :: LP () -- cgit v1.2.3