git.iko.soy/typeable/pandoc
on master help sign in
LaTeX reader: parse label after caption into a span...

instead of inserting an additional paragraph of bracketed text. Closes #1747.

commit58ea1ce5f1754323e129610f96a41e919323de11 authorJohn MacFarlane <jgm@berkeley.edu> dateMon 15 Dec 2014, 21:49 (12 years ago) parent0eb3f8c
1 file changed+11−4
src/Text/Pandoc/Readers/LaTeX.hs+11−4
src/Text/Pandoc/Readers/LaTeX.hs+11−4
@@ -304,7 +304,7 @@ blockCommands = M.fromList $
304304 , ("item", skipopts *> loose_item)
305305 , ("documentclass", skipopts *> braced *> preamble)
306306 , ("centerline", (para . trimInlines) <$> (skipopts *> tok))
307− , ("caption", skipopts *> tok >>= setCaption)
307+ , ("caption", skipopts *> setCaption)
308308 , ("PandocStartInclude", startInclude)
309309 , ("PandocEndInclude", endInclude)
310310 , ("bibliography", mempty <$ (skipopts *> braced >>=
@@ -336,9 +336,16 @@ addMeta field val = updateState $ \st ->
336336splitBibs :: String -> [Inlines]
337337splitBibs = map (str . flip replaceExtension "bib" . trim) . splitBy (==',')
338338
339−setCaption :: Inlines -> LP Blocks
340−setCaption ils = do
341− updateState $ \st -> st{ stateCaption = Just ils }
339+setCaption :: LP Blocks
340+setCaption = do
341+ ils <- tok
342+ mblabel <- option Nothing $
343+ try $ spaces >> controlSeq "label" >> (Just <$> tok)
344+ let ils' = case mblabel of
345+ Just lab -> ils <> spanWith
346+ ("",[],[("data-label", stringify lab)]) mempty
347+ Nothing -> ils
348+ updateState $ \st -> st{ stateCaption = Just ils' }
342349 return mempty
343350
344351resetCaption :: LP ()