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.
This commit is contained in:
parent
93eaf33e6e
commit
fd6e65b00f
2 changed files with 18 additions and 1 deletions
|
@ -690,6 +690,12 @@ General writer options
|
|||
repeatedly to include multiple files. They will be included in the
|
||||
order specified. Implies `--standalone`.
|
||||
|
||||
`--resource-path=`*SEARCHPATH*
|
||||
|
||||
: List of paths to search for images and other resources.
|
||||
The paths should be separated by `:` on linux, unix, and
|
||||
MacOS systems, and by `;` on Windows.
|
||||
|
||||
Options affecting specific writers
|
||||
----------------------------------
|
||||
|
||||
|
|
|
@ -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,
|
||||
|
|
Loading…
Reference in a new issue