From 0448b7d1fc8bb12d1288287ea01bb2ef091ea7d5 Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Fri, 24 Feb 2017 15:34:41 +0100 Subject: Implemented `\graphicspath` in LaTeX reader. Closes #736. --- src/Text/Pandoc/Readers/LaTeX.hs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'src/Text/Pandoc/Readers') diff --git a/src/Text/Pandoc/Readers/LaTeX.hs b/src/Text/Pandoc/Readers/LaTeX.hs index fbbdc1873..cc8176162 100644 --- a/src/Text/Pandoc/Readers/LaTeX.hs +++ b/src/Text/Pandoc/Readers/LaTeX.hs @@ -53,7 +53,7 @@ import Text.Pandoc.Highlighting (fromListingsLanguage, languagesByExtension) import Text.Pandoc.ImageSize (numUnit, showFl) import Control.Monad.Except (throwError) import Text.Pandoc.Class (PandocMonad, PandocPure, lookupEnv, report, - readFileFromDirs) + readFileFromDirs, setResourcePath) -- | Parse LaTeX from string and return 'Pandoc' document. readLaTeX :: PandocMonad m @@ -372,6 +372,7 @@ blockCommands = M.fromList $ addMeta "bibliography" . splitBibs)) -- includes , ("lstinputlisting", inputListing) + , ("graphicspath", graphicsPath) ] ++ map ignoreBlocks -- these commands will be ignored unless --parse-raw is specified, -- in which case they will appear as raw latex blocks @@ -390,6 +391,12 @@ blockCommands = M.fromList $ , "newpage" ] +graphicsPath :: PandocMonad m => LP m Blocks +graphicsPath = do + ps <- bgroup *> (manyTill braced egroup) + setResourcePath (".":ps) + return mempty + addMeta :: PandocMonad m => ToMetaValue a => String -> a -> LP m () addMeta field val = updateState $ \st -> st{ stateMeta = addMetaField field val $ stateMeta st } -- cgit v1.2.3