LaTeX reader: parse label after caption into a span...

instead of inserting an additional paragraph of bracketed text.
Closes #1747.
This commit is contained in:
John MacFarlane
2014-12-15 21:50:10 -08:00
parent 0eb3f8cff2
commit 58ea1ce5f1
+11 -4
View File
@@ -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 ()