{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE QuasiQuotes #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE NoImplicitPrelude #-}
module Text.Pandoc.Filter.Plot.Renderers.Plotsjl
( plotsjl,
plotsjlSupportedSaveFormats,
)
where
import Text.Pandoc.Filter.Plot.Renderers.Prelude
plotsjl :: PlotM Renderer
plotsjl :: PlotM Renderer
plotsjl = do
Text
cmdargs <- (Configuration -> Text) -> PlotM Text
forall a. (Configuration -> a) -> PlotM a
asksConfig Configuration -> Text
plotsjlCmdArgs
Renderer -> PlotM Renderer
forall a. a -> StateT PlotState (ReaderT RuntimeEnv IO) a
forall (m :: * -> *) a. Monad m => a -> m a
return
(Renderer -> PlotM Renderer) -> Renderer -> PlotM Renderer
forall a b. (a -> b) -> a -> b
$ Renderer
{ rendererToolkit :: Toolkit
rendererToolkit = Toolkit
Plotsjl,
rendererCapture :: FigureSpec -> String -> Text
rendererCapture = FigureSpec -> String -> Text
plotsjlCapture,
rendererCommand :: OutputSpec -> Text
rendererCommand = Text -> OutputSpec -> Text
plotsjlCommand Text
cmdargs,
rendererAvailability :: AvailabilityCheck
rendererAvailability = (Executable -> Text) -> AvailabilityCheck
CommandSuccess ((Executable -> Text) -> AvailabilityCheck)
-> (Executable -> Text) -> AvailabilityCheck
forall a b. (a -> b) -> a -> b
$ \Executable
exe -> [st|#{pathToExe exe} -e "using Plots"|],
rendererSupportedSaveFormats :: [SaveFormat]
rendererSupportedSaveFormats = [SaveFormat]
plotsjlSupportedSaveFormats,
rendererChecks :: [Text -> CheckResult]
rendererChecks = [Text -> CheckResult]
forall a. Monoid a => a
mempty,
rendererLanguage :: Text
rendererLanguage = Text
"julia",
rendererComment :: Text -> Text
rendererComment = Text -> Text -> Text
forall a. Monoid a => a -> a -> a
mappend Text
"# ",
rendererScriptExtension :: String
rendererScriptExtension = String
".jl"
}
plotsjlSupportedSaveFormats :: [SaveFormat]
plotsjlSupportedSaveFormats :: [SaveFormat]
plotsjlSupportedSaveFormats = [SaveFormat
PNG, SaveFormat
SVG, SaveFormat
PDF]
plotsjlCommand :: Text -> OutputSpec -> Text
plotsjlCommand :: Text -> OutputSpec -> Text
plotsjlCommand Text
cmdargs OutputSpec {String
FigureSpec
Executable
oFigureSpec :: FigureSpec
oScriptPath :: String
oFigurePath :: String
oExecutable :: Executable
oCWD :: String
oFigureSpec :: OutputSpec -> FigureSpec
oScriptPath :: OutputSpec -> String
oFigurePath :: OutputSpec -> String
oExecutable :: OutputSpec -> Executable
oCWD :: OutputSpec -> String
..} = [st|#{pathToExe oExecutable} #{cmdargs} -- "#{oScriptPath}"|]
plotsjlCapture :: FigureSpec -> FilePath -> Script
plotsjlCapture :: FigureSpec -> String -> Text
plotsjlCapture = (FigureSpec -> String -> Text) -> FigureSpec -> String -> Text
appendCapture FigureSpec -> String -> Text
plotsjlCaptureFragment
plotsjlCaptureFragment :: FigureSpec -> FilePath -> Script
plotsjlCaptureFragment :: FigureSpec -> String -> Text
plotsjlCaptureFragment FigureSpec
_ String
fname =
[st|
savefig(raw"#{fname}")
|]