git.iko.soy/typeable/pandoc
on master help sign in
LaTeX reader: parse label after caption into a span...
58ea1ceJohn MacFarlane
src/Text/Pandoc/Readers/LaTeX.hs+11−4
@@ -304,7 +304,7 @@ blockCommands = M.fromList $
304 , ("item", skipopts *> loose_item)
304 , ("item", skipopts *> loose_item)
305 , ("documentclass", skipopts *> braced *> preamble)
305 , ("documentclass", skipopts *> braced *> preamble)
306 , ("centerline", (para . trimInlines) <$> (skipopts *> tok))
306 , ("centerline", (para . trimInlines) <$> (skipopts *> tok))
307− , ("caption", skipopts *> tok >>= setCaption)
307+ , ("caption", skipopts *> setCaption)
308 , ("PandocStartInclude", startInclude)
308 , ("PandocStartInclude", startInclude)
309 , ("PandocEndInclude", endInclude)
309 , ("PandocEndInclude", endInclude)
310 , ("bibliography", mempty <$ (skipopts *> braced >>=
310 , ("bibliography", mempty <$ (skipopts *> braced >>=
@@ -336,9 +336,16 @@ addMeta field val = updateState $ \st ->
336splitBibs :: String -> [Inlines]
336splitBibs :: String -> [Inlines]
337splitBibs = map (str . flip replaceExtension "bib" . trim) . splitBy (==',')
337splitBibs = map (str . flip replaceExtension "bib" . trim) . splitBy (==',')
338
338
339−setCaption :: Inlines -> LP Blocks
339+setCaption :: LP Blocks
340−setCaption ils = do
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
341− updateState $ \st -> st{ stateCaption = Just ils }
348+ updateState $ \st -> st{ stateCaption = Just ils' }
342 return mempty
349 return mempty
343
350
344resetCaption :: LP ()
351resetCaption :: LP ()