{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE QuasiQuotes #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE NoImplicitPrelude #-}
module Text.Pandoc.Filter.Plot.Renderers.Asymptote
( asymptote,
asymptoteSupportedSaveFormats,
)
where
import Text.Pandoc.Filter.Plot.Renderers.Prelude
import Data.Char(toLower)
asymptote :: PlotM Renderer
asymptote :: PlotM Renderer
asymptote = do
Text
cmdargs <- forall a. (Configuration -> a) -> PlotM a
asksConfig Configuration -> Text
asyCmdArgs
forall (m :: * -> *) a. Monad m => a -> m a
return
forall a b. (a -> b) -> a -> b
$ Renderer
{ rendererToolkit :: Toolkit
rendererToolkit = Toolkit
Asymptote,
rendererCapture :: FigureSpec -> FilePath -> Text
rendererCapture = FigureSpec -> FilePath -> Text
asymptoteCapture,
rendererCommand :: OutputSpec -> Text
rendererCommand = Text -> OutputSpec -> Text
asymptoteCommand Text
cmdargs,
rendererAvailability :: AvailabilityCheck
rendererAvailability = (Executable -> Text) -> AvailabilityCheck
CommandSuccess forall a b. (a -> b) -> a -> b
$ \Executable
exe -> [st|#{pathToExe exe} -environment|],
rendererSupportedSaveFormats :: [SaveFormat]
rendererSupportedSaveFormats = [SaveFormat]
asymptoteSupportedSaveFormats,
rendererChecks :: [Text -> CheckResult]
rendererChecks = forall a. Monoid a => a
mempty,
rendererLanguage :: Text
rendererLanguage = Text
"asy",
rendererComment :: Text -> Text
rendererComment = forall a. Monoid a => a -> a -> a
mappend Text
"// ",
rendererScriptExtension :: FilePath
rendererScriptExtension = FilePath
".asy"
}
asymptoteSupportedSaveFormats :: [SaveFormat]
asymptoteSupportedSaveFormats :: [SaveFormat]
asymptoteSupportedSaveFormats = [SaveFormat
PDF, SaveFormat
EPS, SaveFormat
PNG]
asymptoteCommand :: Text -> OutputSpec -> Text
asymptoteCommand :: Text -> OutputSpec -> Text
asymptoteCommand Text
cmdArgs OutputSpec {FilePath
FigureSpec
Executable
oCWD :: OutputSpec -> FilePath
oExecutable :: OutputSpec -> Executable
oFigurePath :: OutputSpec -> FilePath
oScriptPath :: OutputSpec -> FilePath
oFigureSpec :: OutputSpec -> FigureSpec
oCWD :: FilePath
oExecutable :: Executable
oFigurePath :: FilePath
oScriptPath :: FilePath
oFigureSpec :: FigureSpec
..} =
[st|#{pathToExe oExecutable} #{cmdArgs} -f #{toLower <$> show (saveFormat oFigureSpec)} -o "#{oFigurePath}" "#{oScriptPath}"|]
asymptoteCapture :: FigureSpec -> FilePath -> Script
asymptoteCapture :: FigureSpec -> FilePath -> Text
asymptoteCapture FigureSpec {Bool
Int
FilePath
[FilePath]
[(Text, Text)]
Attr
Text
Renderer
SaveFormat
Executable
blockAttrs :: FigureSpec -> Attr
extraAttrs :: FigureSpec -> [(Text, Text)]
dependencies :: FigureSpec -> [FilePath]
dpi :: FigureSpec -> Int
directory :: FigureSpec -> FilePath
script :: FigureSpec -> Text
withSource :: FigureSpec -> Bool
caption :: FigureSpec -> Text
fsExecutable :: FigureSpec -> Executable
renderer_ :: FigureSpec -> Renderer
blockAttrs :: Attr
extraAttrs :: [(Text, Text)]
dependencies :: [FilePath]
dpi :: Int
directory :: FilePath
saveFormat :: SaveFormat
script :: Text
withSource :: Bool
caption :: Text
fsExecutable :: Executable
renderer_ :: Renderer
saveFormat :: FigureSpec -> SaveFormat
..} FilePath
_ = Text
script