git.iko.soy/typeable/pandoc
on master help sign in
Add template variable `curdir` with working directory

from which pandoc is run. Closes #5464.

commitfee3258280959a741fbdddb1eeb4b1ef2ab14e6d authorJohn MacFarlane <jgm@berkeley.edu> dateSat 4 May 2019, 09:04 (8 years ago) parent2fa8c0d
2 files changed+10
MANUAL.txt+5 src/Text/Pandoc/App/OutputSettings.hs+5
MANUAL.txt+5
@@ -1905,6 +1905,11 @@ on the output format, and include the following:
19051905
19061906 Similarly, `outputfile` can be `-` if output goes to the terminal.
19071907
1908+ If you need absolute paths, use e.g. `$curdir$/$sourcefile$`.
1909+
1910+`curdir`
1911+: working directory from which pandoc is run.
1912+
19081913`toc`
19091914: non-null value if `--toc/--table-of-contents` was specified
19101915
src/Text/Pandoc/App/OutputSettings.hs+5
@@ -28,6 +28,7 @@ import Data.List (find, isPrefixOf, isSuffixOf)
2828import Data.Maybe (fromMaybe)
2929import Skylighting (defaultSyntaxMap)
3030import Skylighting.Parser (addSyntaxDefinition, parseSyntaxDefinition)
31+import System.Directory (getCurrentDirectory)
3132import System.Exit (exitSuccess)
3233import System.FilePath
3334import System.IO (stdout)
@@ -113,6 +114,8 @@ optToOutputSettings opts = do
113114 s <- UTF8.toString . fst <$> fetchItem fp
114115 return $ (varname, s) : vars
115116
117+ curdir <- liftIO getCurrentDirectory
118+
116119 variables <-
117120 withList (addStringAsVariable "sourcefile")
118121 (reverse $ optInputFiles opts)
@@ -140,6 +143,8 @@ optToOutputSettings opts = do
140143 maybe return (addStringAsVariable "epub-cover-image")
141144 (optEpubCoverImage opts)
142145 >>=
146+ addStringAsVariable "curdir" curdir
147+ >>=
143148 (\vars -> if format == "dzslides"
144149 then do
145150 dztempl <- UTF8.toString <$> readDataFile