module Text.Pandoc.Filter.Plot.Renderers.Prelude (
module Prelude
, module Text.Pandoc.Filter.Plot.Monad
, Text
, st
, unpack
, commandSuccess
, existsOnPath
, executable
, OutputSpec(..)
) where
import Data.Maybe (isJust)
import Data.Text (Text, unpack)
import System.Directory (findExecutable)
import System.Exit (ExitCode(..))
import Text.Shakespeare.Text (st)
import Text.Pandoc.Filter.Plot.Monad
commandSuccess :: Text -> PlotM Bool
commandSuccess s = do
(ec, _) <- runCommand s
return $ ec == ExitSuccess
existsOnPath :: FilePath -> IO Bool
existsOnPath fp = findExecutable fp >>= fmap isJust . return
tryToFindExe :: String -> IO FilePath
tryToFindExe fp = findExecutable fp >>= maybe (return fp) return
executable :: Toolkit -> PlotM FilePath
executable Matplotlib = asksConfig matplotlibExe >>= liftIO . tryToFindExe
executable PlotlyPython = asksConfig plotlyPythonExe >>= liftIO . tryToFindExe
executable PlotlyR = asksConfig plotlyRExe >>= liftIO . tryToFindExe
executable Matlab = asksConfig matlabExe >>= liftIO . tryToFindExe
executable Mathematica = asksConfig mathematicaExe >>= liftIO . tryToFindExe
executable Octave = asksConfig octaveExe >>= liftIO . tryToFindExe
executable GGPlot2 = asksConfig ggplot2Exe >>= liftIO . tryToFindExe
executable GNUPlot = asksConfig gnuplotExe >>= liftIO . tryToFindExe
executable Graphviz = asksConfig graphvizExe >>= liftIO . tryToFindExe
data OutputSpec = OutputSpec
{ oFigureSpec :: FigureSpec
, oScriptPath :: FilePath
, oFigurePath :: FilePath
}