{-# LANGUAGE NoImplicitPrelude #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE QuasiQuotes #-}
{-# LANGUAGE RecordWildCards #-}
module Text.Pandoc.Filter.Plot.Renderers.Octave (
octaveSupportedSaveFormats
, octaveCommand
, octaveCapture
, octaveAvailable
) where
import Text.Pandoc.Filter.Plot.Renderers.Prelude
octaveSupportedSaveFormats :: [SaveFormat]
octaveSupportedSaveFormats = [PNG, PDF, SVG, JPG, EPS, GIF, TIF]
octaveCommand :: OutputSpec -> Text -> Text
octaveCommand OutputSpec{..} exe = [st|#{exe} --no-gui --no-window-system "#{oScriptPath}"|]
octaveAvailable :: PlotM Bool
octaveAvailable = do
mexe <- executable Octave
case mexe of
Nothing -> return False
Just (Executable dir exe) ->
commandSuccess dir [st|#{exe} -h|]
octaveCapture :: FigureSpec -> FilePath -> Script
octaveCapture = appendCapture octaveCaptureFragment
octaveCaptureFragment :: FigureSpec -> FilePath -> Script
octaveCaptureFragment _ fname = [st|
saveas(gcf, '#{fname}')
|]