Allow `--resource-path` to accumulate.
Previously, if `--resource-path` were used multiple times, the last
resource path would replace the others.
With this change, each time `--resource-path` is used, it prepends
the specified path components to the existing resource path.
Similarly, when `resource-path` is specified in a defaults file,
the paths provided will be prepended to the existing resource
path.
This change also allows one to avoid using the OS-specific path
separator; instead, one can simply use `--resource-path`
a number of times with single paths. This form of command
will not have an OS-dependent behavior.
This change facilitates the use of multiple, small defaults
files: each can specify a directory containing its own
resources without clobbering the resource paths set by
the others.
Closes #6152.
commit735a69de6b94e32ee9aceb44a893de4067f24354
authorJohn MacFarlane <jgm@berkeley.edu>
dateSat 6 Mar 2021, 10:32 (6 years ago)
parent2652424
MANUAL.txt+5
@@ -891,6 +891,11 @@ header when requesting a document from a URL:
891891 will not be searched. For example:
892892 `--resource-path=.:test` will search the working directory
893893 and the `test` subdirectory, in that order.
894+ This option can be used repeatedly. Search path components
895+ that come later on the command line will be searched before
896+ those that come earlier, so
897+ `--resource-path foo:bar --resource-path baz:bim` is
898+ equivalent to `--resource-path baz:bim:foo:bar`.
894899
895900`--request-header=`*NAME*`:`*VAL*
896901
src/Text/Pandoc/App/CommandLineOptions.hs+2−1
@@ -288,7 +288,8 @@ options =
288288 , Option "" ["resource-path"]
289289 (ReqArg
290290 (\arg opt -> return opt { optResourcePath =
291− splitSearchPath arg })
291+ splitSearchPath arg ++
292+ optResourcePath opt })
292293 "SEARCHPATH")
293294 "" -- "Paths to search for images and other resources"
294295
src/Text/Pandoc/App/Opt.hs+2−1
@@ -583,7 +583,8 @@ doOpt (k',v) = do
583583 optIncludeInHeader o <> [unpack x] }))
584584 "resource-path" ->
585585 parseYAML v >>= \x ->
586− return (\o -> o{ optResourcePath = map unpack x })
586+ return (\o -> o{ optResourcePath = map unpack x <>
587+ optResourcePath o })
587588 "request-headers" ->
588589 parseYAML v >>= \x ->
589590 return (\o -> o{ optRequestHeaders = x })