{-# LANGUAGE NoImplicitPrelude #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE QuasiQuotes #-}
{-# LANGUAGE RecordWildCards #-}
module Text.Pandoc.Filter.Plot.Renderers.Matlab (
matlabSupportedSaveFormats
, matlabCommand
, matlabCapture
, matlabAvailable
) where
import System.Directory (exeExtension)
import Text.Pandoc.Filter.Plot.Renderers.Prelude
matlabSupportedSaveFormats :: [SaveFormat]
matlabSupportedSaveFormats = [PNG, PDF, SVG, JPG, EPS, GIF, TIF]
matlabCommand :: OutputSpec -> IO Text
matlabCommand OutputSpec{..} = do
exe <- executable Matlab oConfiguration
return [st|#{exe} -batch "run('#{oScriptPath}')"|]
matlabAvailable :: Configuration -> IO Bool
matlabAvailable Configuration{..} = existsOnPath (matlabExe <> exeExtension)
matlabCapture :: FigureSpec -> FilePath -> Script
matlabCapture FigureSpec{..} fname = [st|
saveas(gcf, '#{fname}')
|]