Finished implemtation of --resource-path
.
* Default is just working directory. * Working directory must be explicitly specifide if `--resource-path` option is used.
This commit is contained in:
parent
6a7f980247
commit
8c1b81bbef
3 changed files with 11 additions and 5 deletions
|
@ -694,7 +694,13 @@ General writer options
|
||||||
|
|
||||||
: List of paths to search for images and other resources.
|
: List of paths to search for images and other resources.
|
||||||
The paths should be separated by `:` on linux, unix, and
|
The paths should be separated by `:` on linux, unix, and
|
||||||
MacOS systems, and by `;` on Windows.
|
MacOS systems, and by `;` on Windows. If `--resource-path`
|
||||||
|
is not specified, the default resource path is the working
|
||||||
|
directory. Note that, if `--resource-path` is specified,
|
||||||
|
the working directory must be explicitly listed or it
|
||||||
|
will not be searched. For example:
|
||||||
|
`--resource-path=.:test` will search the working directory
|
||||||
|
and the `test` subdirectory, in that order.
|
||||||
|
|
||||||
Options affecting specific writers
|
Options affecting specific writers
|
||||||
----------------------------------
|
----------------------------------
|
||||||
|
|
|
@ -414,7 +414,7 @@ convertWithOpts opts = do
|
||||||
let eol = fromMaybe nativeNewline $ optEol opts
|
let eol = fromMaybe nativeNewline $ optEol opts
|
||||||
|
|
||||||
runIO' $ do
|
runIO' $ do
|
||||||
setResourcePath $ "." : (optResourcePath opts)
|
setResourcePath (optResourcePath opts)
|
||||||
(doc, media) <- withMediaBag $ sourceToDoc sources >>=
|
(doc, media) <- withMediaBag $ sourceToDoc sources >>=
|
||||||
( (if isJust (optExtractMedia opts)
|
( (if isJust (optExtractMedia opts)
|
||||||
then fillMediaBag (writerSourceURL writerOptions)
|
then fillMediaBag (writerSourceURL writerOptions)
|
||||||
|
@ -640,7 +640,7 @@ defaultOpts = Opt
|
||||||
, optIncludeBeforeBody = []
|
, optIncludeBeforeBody = []
|
||||||
, optIncludeAfterBody = []
|
, optIncludeAfterBody = []
|
||||||
, optIncludeInHeader = []
|
, optIncludeInHeader = []
|
||||||
, optResourcePath = []
|
, optResourcePath = ["."]
|
||||||
, optEol = Nothing
|
, optEol = Nothing
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -46,7 +46,7 @@ import Safe (minimumDef)
|
||||||
import System.FilePath (addExtension, replaceExtension, takeExtension)
|
import System.FilePath (addExtension, replaceExtension, takeExtension)
|
||||||
import Text.Pandoc.Builder
|
import Text.Pandoc.Builder
|
||||||
import Text.Pandoc.Class (PandocMonad, PandocPure, lookupEnv, readFileFromDirs,
|
import Text.Pandoc.Class (PandocMonad, PandocPure, lookupEnv, readFileFromDirs,
|
||||||
report, setResourcePath)
|
report, setResourcePath, getResourcePath)
|
||||||
import Text.Pandoc.Highlighting (fromListingsLanguage, languagesByExtension)
|
import Text.Pandoc.Highlighting (fromListingsLanguage, languagesByExtension)
|
||||||
import Text.Pandoc.ImageSize (numUnit, showFl)
|
import Text.Pandoc.ImageSize (numUnit, showFl)
|
||||||
import Text.Pandoc.Logging
|
import Text.Pandoc.Logging
|
||||||
|
@ -417,7 +417,7 @@ blockCommands = M.fromList $
|
||||||
graphicsPath :: PandocMonad m => LP m Blocks
|
graphicsPath :: PandocMonad m => LP m Blocks
|
||||||
graphicsPath = do
|
graphicsPath = do
|
||||||
ps <- bgroup *> (manyTill braced egroup)
|
ps <- bgroup *> (manyTill braced egroup)
|
||||||
setResourcePath (".":ps)
|
getResourcePath >>= setResourcePath . (++ ps)
|
||||||
return mempty
|
return mempty
|
||||||
|
|
||||||
addMeta :: PandocMonad m => ToMetaValue a => String -> a -> LP m ()
|
addMeta :: PandocMonad m => ToMetaValue a => String -> a -> LP m ()
|
||||||
|
|
Loading…
Reference in a new issue