{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE QuasiQuotes #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE NoImplicitPrelude #-}
module Text.Pandoc.Filter.Plot.Renderers.Mathematica
( mathematicaSupportedSaveFormats,
mathematicaCommand,
mathematicaCapture,
mathematicaAvailable,
)
where
import Text.Pandoc.Filter.Plot.Renderers.Prelude
mathematicaSupportedSaveFormats :: [SaveFormat]
mathematicaSupportedSaveFormats :: [SaveFormat]
mathematicaSupportedSaveFormats = [SaveFormat
PNG, SaveFormat
PDF, SaveFormat
SVG, SaveFormat
JPG, SaveFormat
EPS, SaveFormat
GIF, SaveFormat
TIF]
mathematicaCommand :: OutputSpec -> Text -> Text
mathematicaCommand :: OutputSpec -> Text -> Text
mathematicaCommand OutputSpec {FilePath
FigureSpec
oFigurePath :: OutputSpec -> FilePath
oScriptPath :: OutputSpec -> FilePath
oFigureSpec :: OutputSpec -> FigureSpec
oFigurePath :: FilePath
oScriptPath :: FilePath
oFigureSpec :: FigureSpec
..} Text
exe = [st|#{exe} -script "#{oScriptPath}"|]
mathematicaAvailable :: PlotM Bool
mathematicaAvailable :: PlotM Bool
mathematicaAvailable = do
Maybe Executable
mexe <- Toolkit -> PlotM (Maybe Executable)
executable Toolkit
Mathematica
case Maybe Executable
mexe of
Maybe Executable
Nothing -> Bool -> PlotM Bool
forall (m :: * -> *) a. Monad m => a -> m a
return Bool
False
Just (Executable FilePath
dir Text
exe) ->
FilePath -> Text -> PlotM Bool
commandSuccess FilePath
dir [st|#{exe} -h|]
mathematicaCapture :: FigureSpec -> FilePath -> Script
mathematicaCapture :: FigureSpec -> FilePath -> Text
mathematicaCapture = (FigureSpec -> FilePath -> Text) -> FigureSpec -> FilePath -> Text
appendCapture FigureSpec -> FilePath -> Text
mathematicaCaptureFragment
mathematicaCaptureFragment :: FigureSpec -> FilePath -> Script
mathematicaCaptureFragment :: FigureSpec -> FilePath -> Text
mathematicaCaptureFragment FigureSpec {Bool
Int
FilePath
[FilePath]
[(Text, Text)]
Attr
Text
SaveFormat
Toolkit
blockAttrs :: FigureSpec -> Attr
extraAttrs :: FigureSpec -> [(Text, Text)]
dependencies :: FigureSpec -> [FilePath]
dpi :: FigureSpec -> Int
directory :: FigureSpec -> FilePath
saveFormat :: FigureSpec -> SaveFormat
script :: FigureSpec -> Text
withSource :: FigureSpec -> Bool
caption :: FigureSpec -> Text
toolkit :: FigureSpec -> Toolkit
blockAttrs :: Attr
extraAttrs :: [(Text, Text)]
dependencies :: [FilePath]
dpi :: Int
directory :: FilePath
saveFormat :: SaveFormat
script :: Text
withSource :: Bool
caption :: Text
toolkit :: Toolkit
..} FilePath
fname =
[st|
Export["#{fname}", %, #{show saveFormat}, ImageResolution -> #{dpi}]
|]