{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE QuasiQuotes #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE NoImplicitPrelude #-}
module Text.Pandoc.Filter.Plot.Renderers.Plotsjl
( plotsjlSupportedSaveFormats,
plotsjlCommand,
plotsjlCapture,
plotsjlAvailable,
)
where
import Text.Pandoc.Filter.Plot.Renderers.Prelude
plotsjlSupportedSaveFormats :: [SaveFormat]
plotsjlSupportedSaveFormats :: [SaveFormat]
plotsjlSupportedSaveFormats = [SaveFormat
PNG, SaveFormat
SVG, SaveFormat
PDF]
plotsjlCommand :: OutputSpec -> Text -> Text
plotsjlCommand :: OutputSpec -> Text -> Text
plotsjlCommand OutputSpec {FilePath
FigureSpec
oFigurePath :: OutputSpec -> FilePath
oScriptPath :: OutputSpec -> FilePath
oFigureSpec :: OutputSpec -> FigureSpec
oFigurePath :: FilePath
oScriptPath :: FilePath
oFigureSpec :: FigureSpec
..} Text
exe = [st|#{exe} "#{oScriptPath}"|]
plotsjlAvailable :: PlotM Bool
plotsjlAvailable :: PlotM Bool
plotsjlAvailable = do
Maybe Executable
mexe <- Toolkit -> PlotM (Maybe Executable)
executable Toolkit
Plotsjl
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} -e "using Plots"|]
plotsjlCapture :: FigureSpec -> FilePath -> Script
plotsjlCapture :: FigureSpec -> FilePath -> Text
plotsjlCapture = (FigureSpec -> FilePath -> Text) -> FigureSpec -> FilePath -> Text
appendCapture FigureSpec -> FilePath -> Text
plotsjlCaptureFragment
plotsjlCaptureFragment :: FigureSpec -> FilePath -> Script
plotsjlCaptureFragment :: FigureSpec -> FilePath -> Text
plotsjlCaptureFragment FigureSpec
_ FilePath
fname =
[st|
savefig(raw"#{fname}")
|]