diff options
author | John MacFarlane <jgm@berkeley.edu> | 2014-05-11 22:52:29 -0700 |
---|---|---|
committer | John MacFarlane <jgm@berkeley.edu> | 2014-05-11 22:52:29 -0700 |
commit | a8319d133908f3c39834984e5e11991b166c37b7 (patch) | |
tree | 775211f1cb32ac30eedb78413d15d27ead0a00c1 /src/Text/Pandoc/Readers | |
parent | 009260647612238b5af964afcbeb452001f2ab0c (diff) | |
download | pandoc-a8319d133908f3c39834984e5e11991b166c37b7.tar.gz |
LaTeX reader: set `bibliography` in metadata from `\bibliography` cmd.
Diffstat (limited to 'src/Text/Pandoc/Readers')
-rw-r--r-- | src/Text/Pandoc/Readers/LaTeX.hs | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/src/Text/Pandoc/Readers/LaTeX.hs b/src/Text/Pandoc/Readers/LaTeX.hs index 8476c8636..4b9e424d9 100644 --- a/src/Text/Pandoc/Readers/LaTeX.hs +++ b/src/Text/Pandoc/Readers/LaTeX.hs @@ -307,6 +307,8 @@ blockCommands = M.fromList $ , ("caption", tok >>= setCaption) , ("PandocStartInclude", startInclude) , ("PandocEndInclude", endInclude) + , ("bibliography", mempty <$ (skipopts *> braced >>= + addMeta "bibliography" . splitBibs)) ] ++ map ignoreBlocks -- these commands will be ignored unless --parse-raw is specified, -- in which case they will appear as raw latex blocks @@ -314,7 +316,7 @@ blockCommands = M.fromList $ -- newcommand, etc. should be parsed by macro, but we need this -- here so these aren't parsed as inline commands to ignore , "special", "pdfannot", "pdfstringdef" - , "bibliography", "bibliographystyle" + , "bibliographystyle" , "maketitle", "makeindex", "makeglossary" , "addcontentsline", "addtocontents", "addtocounter" -- \ignore{} is used conventionally in literate haskell for definitions @@ -329,6 +331,9 @@ addMeta :: ToMetaValue a => String -> a -> LP () addMeta field val = updateState $ \st -> st{ stateMeta = addMetaField field val $ stateMeta 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 } |