git.iko.soy/typeable/pandoc
on master help sign in
Add template variable `curdir` with working directory
fee3258John MacFarlane
MANUAL.txt+5
@@ -1905,6 +1905,11 @@ on the output format, and include the following:
1905
1905
1906 Similarly, `outputfile` can be `-` if output goes to the terminal.
1906 Similarly, `outputfile` can be `-` if output goes to the terminal.
1907
1907
1908+ If you need absolute paths, use e.g. `$curdir$/$sourcefile$`.
1909+
1910+`curdir`
1911+: working directory from which pandoc is run.
1912+
1908`toc`
1913`toc`
1909: non-null value if `--toc/--table-of-contents` was specified
1914: non-null value if `--toc/--table-of-contents` was specified
1910
1915
src/Text/Pandoc/App/OutputSettings.hs+5
@@ -28,6 +28,7 @@ import Data.List (find, isPrefixOf, isSuffixOf)
28import Data.Maybe (fromMaybe)
28import Data.Maybe (fromMaybe)
29import Skylighting (defaultSyntaxMap)
29import Skylighting (defaultSyntaxMap)
30import Skylighting.Parser (addSyntaxDefinition, parseSyntaxDefinition)
30import Skylighting.Parser (addSyntaxDefinition, parseSyntaxDefinition)
31+import System.Directory (getCurrentDirectory)
31import System.Exit (exitSuccess)
32import System.Exit (exitSuccess)
32import System.FilePath
33import System.FilePath
33import System.IO (stdout)
34import System.IO (stdout)
@@ -113,6 +114,8 @@ optToOutputSettings opts = do
113 s <- UTF8.toString . fst <$> fetchItem fp
114 s <- UTF8.toString . fst <$> fetchItem fp
114 return $ (varname, s) : vars
115 return $ (varname, s) : vars
115
116
117+ curdir <- liftIO getCurrentDirectory
118+
116 variables <-
119 variables <-
117 withList (addStringAsVariable "sourcefile")
120 withList (addStringAsVariable "sourcefile")
118 (reverse $ optInputFiles opts)
121 (reverse $ optInputFiles opts)
@@ -140,6 +143,8 @@ optToOutputSettings opts = do
140 maybe return (addStringAsVariable "epub-cover-image")
143 maybe return (addStringAsVariable "epub-cover-image")
141 (optEpubCoverImage opts)
144 (optEpubCoverImage opts)
142 >>=
145 >>=
146+ addStringAsVariable "curdir" curdir
147+ >>=
143 (\vars -> if format == "dzslides"
148 (\vars -> if format == "dzslides"
144 then do
149 then do
145 dztempl <- UTF8.toString <$> readDataFile
150 dztempl <- UTF8.toString <$> readDataFile