{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE QuasiQuotes #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE NoImplicitPrelude #-}
module Text.Pandoc.Filter.Plot.Renderers.Octave
( octave,
octaveSupportedSaveFormats,
)
where
import Text.Pandoc.Filter.Plot.Renderers.Prelude
octave :: PlotM Renderer
octave :: PlotM Renderer
octave = do
Text
cmdargs <- forall a. (Configuration -> a) -> PlotM a
asksConfig Configuration -> Text
octaveCmdArgs
forall (m :: * -> *) a. Monad m => a -> m a
return forall a b. (a -> b) -> a -> b
$
Renderer
{ rendererToolkit :: Toolkit
rendererToolkit = Toolkit
Octave,
rendererCapture :: FigureSpec -> String -> Text
rendererCapture = FigureSpec -> String -> Text
octaveCapture,
rendererCommand :: OutputSpec -> Text
rendererCommand = Text -> OutputSpec -> Text
octaveCommand Text
cmdargs,
rendererAvailability :: AvailabilityCheck
rendererAvailability = (Executable -> Text) -> AvailabilityCheck
CommandSuccess forall a b. (a -> b) -> a -> b
$ \Executable
exe -> [st|#{pathToExe exe} -h|],
rendererSupportedSaveFormats :: [SaveFormat]
rendererSupportedSaveFormats = [SaveFormat]
octaveSupportedSaveFormats,
rendererChecks :: [Text -> CheckResult]
rendererChecks = forall a. Monoid a => a
mempty,
rendererLanguage :: Text
rendererLanguage = Text
"matlab",
rendererComment :: Text -> Text
rendererComment = forall a. Monoid a => a -> a -> a
mappend Text
"% ",
rendererScriptExtension :: String
rendererScriptExtension = String
".m"
}
octaveSupportedSaveFormats :: [SaveFormat]
octaveSupportedSaveFormats :: [SaveFormat]
octaveSupportedSaveFormats = [SaveFormat
PNG, SaveFormat
PDF, SaveFormat
SVG, SaveFormat
JPG, SaveFormat
EPS, SaveFormat
GIF, SaveFormat
TIF]
octaveCommand :: Text -> OutputSpec -> Text
octaveCommand :: Text -> OutputSpec -> Text
octaveCommand Text
cmdargs OutputSpec {String
FigureSpec
Executable
oCWD :: OutputSpec -> String
oExecutable :: OutputSpec -> Executable
oFigurePath :: OutputSpec -> String
oScriptPath :: OutputSpec -> String
oFigureSpec :: OutputSpec -> FigureSpec
oCWD :: String
oExecutable :: Executable
oFigurePath :: String
oScriptPath :: String
oFigureSpec :: FigureSpec
..} = [st|#{pathToExe oExecutable} #{cmdargs} --no-gui --no-window-system "#{oScriptPath}"|]
octaveCapture :: FigureSpec -> FilePath -> Script
octaveCapture :: FigureSpec -> String -> Text
octaveCapture = (FigureSpec -> String -> Text) -> FigureSpec -> String -> Text
appendCapture FigureSpec -> String -> Text
octaveCaptureFragment
octaveCaptureFragment :: FigureSpec -> FilePath -> Script
octaveCaptureFragment :: FigureSpec -> String -> Text
octaveCaptureFragment FigureSpec
_ String
fname =
[st|
saveas(gcf, '#{fname}')
|]