git.iko.soy/typeable/pandoc
on master help sign in
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.

commitfd6e65b00ffc628488c27171f7dd9ab833c436c6 authorJohn MacFarlane <jgm@berkeley.edu> dateSat 20 May 2017, 21:43 (9 years ago) parent93eaf33
2 files changed+18−1
MANUAL.txt+6 src/Text/Pandoc/App.hs+12−1
MANUAL.txt+6
@@ -690,6 +690,12 @@ General writer options
690690 repeatedly to include multiple files. They will be included in the
691691 order specified. Implies `--standalone`.
692692
693+`--resource-path=`*SEARCHPATH*
694+
695+: List of paths to search for images and other resources.
696+ The paths should be separated by `:` on linux, unix, and
697+ MacOS systems, and by `;` on Windows.
698+
693699Options affecting specific writers
694700----------------------------------
695701
src/Text/Pandoc/App.hs+12−1
@@ -70,7 +70,7 @@ import System.IO.Error (isDoesNotExistError)
7070import Text.Pandoc
7171import Text.Pandoc.Builder (setMeta)
7272import Text.Pandoc.Class (PandocIO, getLog, withMediaBag,
73− extractMedia, fillMediaBag)
73+ extractMedia, fillMediaBag, setResourcePath)
7474import Text.Pandoc.Highlighting (highlightingStyles)
7575import Text.Pandoc.Lua ( runLuaFilter )
7676import Text.Pandoc.PDF (makePDF)
@@ -414,6 +414,7 @@ convertWithOpts opts = do
414414 let eol = fromMaybe nativeNewline $ optEol opts
415415
416416 runIO' $ do
417+ setResourcePath $ "." : (optResourcePath opts)
417418 (doc, media) <- withMediaBag $ sourceToDoc sources >>=
418419 ( (if isJust (optExtractMedia opts)
419420 then fillMediaBag (writerSourceURL writerOptions)
@@ -569,6 +570,7 @@ data Opt = Opt
569570 , optIncludeBeforeBody :: [FilePath] -- ^ Files to include before
570571 , optIncludeAfterBody :: [FilePath] -- ^ Files to include after body
571572 , optIncludeInHeader :: [FilePath] -- ^ Files to include in header
573+ , optResourcePath :: [FilePath] -- ^ Path to search for images etc
572574 , optEol :: Maybe Newline -- ^ Enforce line-endings
573575 }
574576
@@ -638,6 +640,7 @@ defaultOpts = Opt
638640 , optIncludeBeforeBody = []
639641 , optIncludeAfterBody = []
640642 , optIncludeInHeader = []
643+ , optResourcePath = []
641644 , optEol = Nothing
642645 }
643646
@@ -1052,6 +1055,14 @@ options =
10521055 "FILE")
10531056 "" -- "File to include after document body"
10541057
1058+ , Option "" ["resource-path"]
1059+ (ReqArg
1060+ (\arg opt -> return opt { optResourcePath =
1061+ splitSearchPath arg })
1062+ "SEARCHPATH")
1063+ "" -- "Paths to search for images and other resources"
1064+
1065+
10551066 , Option "" ["self-contained"]
10561067 (NoArg
10571068 (\opt -> return opt { optSelfContained = True,