{-# LANGUAGE NoImplicitPrelude #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE QuasiQuotes #-}
{-# LANGUAGE RecordWildCards #-}
module Text.Pandoc.Filter.Plot.Renderers.Matlab (
matlabSupportedSaveFormats
, matlabCommand
, matlabCapture
, matlabAvailable
) where
import Text.Pandoc.Filter.Plot.Renderers.Prelude
matlabSupportedSaveFormats :: [SaveFormat]
matlabSupportedSaveFormats = [PNG, PDF, SVG, JPG, EPS, GIF, TIF]
matlabCommand :: Configuration -> FigureSpec -> FilePath -> Text
matlabCommand Configuration{..} _ fp = [st|#{matlabExe} -batch "run('#{fp}')"|]
matlabAvailable :: Configuration -> IO Bool
matlabAvailable Configuration{..} = existsOnPath (matlabExe <> ext)
where
ext = if isWindows then ".exe" else mempty
matlabCapture :: FigureSpec -> FilePath -> Script
matlabCapture FigureSpec{..} fname = [st|
saveas(gcf, '#{fname}')
|]