summaryrefslogtreecommitdiff
path: root/pandoc.hs
diff options
context:
space:
mode:
authorJohn MacFarlane <fiddlosopher@gmail.com>2013-08-11 15:58:09 -0700
committerJohn MacFarlane <fiddlosopher@gmail.com>2013-08-11 15:58:09 -0700
commite279175ea517e2df65fe5d716bc02e383b04fc36 (patch)
treecafdb6b78c8a399e8fb0ac9c8e1c3ba5a8fef153 /pandoc.hs
parent6f736dfa7578faab7b90546ee5b2c275185968c8 (diff)
Options: Changed `writerSourceDir` to `writerSourceURL` (now a Maybe).
Previously we used to store the directory of the first input file, even if it was local, and used this as a base directory for finding images in ODT, EPUB, Docx, and PDF. This has been confusing to many users. It seems better to look for images relative to the current working directory, even if the first file argument is in another directory. writerSourceURL is set to 'Just url' when the first command-line argument is an absolute URL. (So, relative links will be resolved in relation to the first page.) Otherwise, 'Nothing'. The ODT, EPUB, Docx, and PDF writers have been modified accordingly. Note that this change may break some existing workflows. If you have been assuming that relative links will be interpreted relative to the directory of the first file argument, you'll need to make that the current directory before running pandoc. Closes #942.
Diffstat (limited to 'pandoc.hs')
-rw-r--r--pandoc.hs12
1 files changed, 7 insertions, 5 deletions
diff --git a/pandoc.hs b/pandoc.hs
index fdf0b35b7..81672e16c 100644
--- a/pandoc.hs
+++ b/pandoc.hs
@@ -1034,13 +1034,15 @@ main = do
return $ Just csl { CSL.styleAbbrevs = abbrevs }
else return Nothing
- let sourceDir = case sources of
- [] -> "."
+ let sourceURL = case sources of
+ [] -> Nothing
(x:_) -> case parseURI x of
Just u
| uriScheme u `elem` ["http:","https:"] ->
- show u{ uriPath = "", uriQuery = "", uriFragment = "" }
- _ -> takeDirectory x
+ Just $ show u{ uriPath = "",
+ uriQuery = "",
+ uriFragment = "" }
+ _ -> Nothing
let readerOpts = def{ readerSmart = smart || (texLigatures &&
(laTeXOutput || "context" `isPrefixOf` writerName'))
@@ -1074,7 +1076,7 @@ main = do
writerColumns = columns,
writerEmailObfuscation = obfuscationMethod,
writerIdentifierPrefix = idPrefix,
- writerSourceDirectory = sourceDir,
+ writerSourceURL = sourceURL,
writerUserDataDir = datadir,
writerHtml5 = html5,
writerHtmlQTags = htmlQTags,