summaryrefslogtreecommitdiff
path: root/src/Text/Pandoc
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2017-05-20 21:43:53 +0200
committerJohn MacFarlane <jgm@berkeley.edu>2017-05-20 21:47:10 +0200
commitfd6e65b00ffc628488c27171f7dd9ab833c436c6 (patch)
tree79d710b884fb86811d96cd061de8d8fd1f1078a1 /src/Text/Pandoc
parent93eaf33e6e7fbb364c83e6bde66f253a8b14297b (diff)
Added `--resource-path=SEARCHPATH` command line option.
SEARCHPATH is separated by the usual character, depending on OS (: on unix, ; on windows). Note: This does not yet work for PDF output, because the routine that creates PDFs runs outside PandocMonad. (This has to do with its use of inTemporaryDirectory and its interaction with our exceptions.) The best solution would be to figure out how to move the PDF creation routines into PandocMonad. Second-best, just pass an extra parameter in? See #852.
Diffstat (limited to 'src/Text/Pandoc')
-rw-r--r--src/Text/Pandoc/App.hs13
1 files changed, 12 insertions, 1 deletions
diff --git a/src/Text/Pandoc/App.hs b/src/Text/Pandoc/App.hs
index 9c8e1bde4..a4967e5d1 100644
--- a/src/Text/Pandoc/App.hs
+++ b/src/Text/Pandoc/App.hs
@@ -70,7 +70,7 @@ import System.IO.Error (isDoesNotExistError)
import Text.Pandoc
import Text.Pandoc.Builder (setMeta)
import Text.Pandoc.Class (PandocIO, getLog, withMediaBag,
- extractMedia, fillMediaBag)
+ extractMedia, fillMediaBag, setResourcePath)
import Text.Pandoc.Highlighting (highlightingStyles)
import Text.Pandoc.Lua ( runLuaFilter )
import Text.Pandoc.PDF (makePDF)
@@ -414,6 +414,7 @@ convertWithOpts opts = do
let eol = fromMaybe nativeNewline $ optEol opts
runIO' $ do
+ setResourcePath $ "." : (optResourcePath opts)
(doc, media) <- withMediaBag $ sourceToDoc sources >>=
( (if isJust (optExtractMedia opts)
then fillMediaBag (writerSourceURL writerOptions)
@@ -569,6 +570,7 @@ data Opt = Opt
, optIncludeBeforeBody :: [FilePath] -- ^ Files to include before
, optIncludeAfterBody :: [FilePath] -- ^ Files to include after body
, optIncludeInHeader :: [FilePath] -- ^ Files to include in header
+ , optResourcePath :: [FilePath] -- ^ Path to search for images etc
, optEol :: Maybe Newline -- ^ Enforce line-endings
}
@@ -638,6 +640,7 @@ defaultOpts = Opt
, optIncludeBeforeBody = []
, optIncludeAfterBody = []
, optIncludeInHeader = []
+ , optResourcePath = []
, optEol = Nothing
}
@@ -1052,6 +1055,14 @@ options =
"FILE")
"" -- "File to include after document body"
+ , Option "" ["resource-path"]
+ (ReqArg
+ (\arg opt -> return opt { optResourcePath =
+ splitSearchPath arg })
+ "SEARCHPATH")
+ "" -- "Paths to search for images and other resources"
+
+
, Option "" ["self-contained"]
(NoArg
(\opt -> return opt { optSelfContained = True,