@@ -63,6 +63,7 @@ defaultConfiguration =
6363 bokehPreamble = mempty ,
6464 plotsjlPreamble = mempty ,
6565 plantumlPreamble = mempty ,
66+ sagemathPreamble = mempty ,
6667 -- Executables
6768 matplotlibExe = python,
6869 matlabExe = " matlab" ,
@@ -76,6 +77,7 @@ defaultConfiguration =
7677 bokehExe = python,
7778 plotsjlExe = " julia" ,
7879 plantumlExe = " java" ,
80+ sagemathExe = " sage" ,
7981 -- Command line arguments
8082 matplotlibCmdArgs = mempty ,
8183 matlabCmdArgs = mempty ,
@@ -89,6 +91,7 @@ defaultConfiguration =
8991 bokehCmdArgs = mempty ,
9092 plotsjlCmdArgs = mempty ,
9193 plantumlCmdArgs = " -jar plantuml.jar" ,
94+ sagemathCmdArgs = mempty ,
9295 -- Extras
9396 matplotlibTightBBox = False ,
9497 matplotlibTransparent = False
@@ -147,7 +150,8 @@ data ConfigPrecursor = ConfigPrecursor
147150 _graphvizPrec :: ! GraphvizPrecursor ,
148151 _bokehPrec :: ! BokehPrecursor ,
149152 _plotsjlPrec :: ! PlotsjlPrecursor ,
150- _plantumlPrec :: ! PlantUMLPrecursor
153+ _plantumlPrec :: ! PlantUMLPrecursor ,
154+ _sagemathPrec :: ! SageMathPrecursor
151155 }
152156
153157defaultConfigPrecursor :: ConfigPrecursor
@@ -173,7 +177,8 @@ defaultConfigPrecursor =
173177 _graphvizPrec = GraphvizPrecursor Nothing (graphvizExe defaultConfiguration) (graphvizCmdArgs defaultConfiguration),
174178 _bokehPrec = BokehPrecursor Nothing (bokehExe defaultConfiguration) (bokehCmdArgs defaultConfiguration),
175179 _plotsjlPrec = PlotsjlPrecursor Nothing (plotsjlExe defaultConfiguration) (plotsjlCmdArgs defaultConfiguration),
176- _plantumlPrec = PlantUMLPrecursor Nothing (plantumlExe defaultConfiguration) (plantumlCmdArgs defaultConfiguration)
180+ _plantumlPrec = PlantUMLPrecursor Nothing (plantumlExe defaultConfiguration) (plantumlCmdArgs defaultConfiguration),
181+ _sagemathPrec = SageMathPrecursor Nothing (sagemathExe defaultConfiguration) (sagemathCmdArgs defaultConfiguration)
177182 }
178183
179184data LoggingPrecursor = LoggingPrecursor
@@ -212,6 +217,8 @@ data PlotsjlPrecursor = PlotsjlPrecursor {_plotsjlPreamble :: !(Maybe FilePath),
212217
213218data PlantUMLPrecursor = PlantUMLPrecursor { _plantumlPreamble :: ! (Maybe FilePath ), _plantumlExe :: ! FilePath , _plantumlCmdArgs :: ! Text }
214219
220+ data SageMathPrecursor = SageMathPrecursor { _sagemathPreamble :: ! (Maybe FilePath ), _sagemathExe :: ! FilePath , _sagemathCmdArgs :: ! Text }
221+
215222instance FromJSON LoggingPrecursor where
216223 parseJSON (Object v) =
217224 LoggingPrecursor <$> v .:? " verbosity" .!= logVerbosity defaultConfiguration
@@ -275,6 +282,10 @@ instance FromJSON PlantUMLPrecursor where
275282 parseJSON (Object v) = PlantUMLPrecursor <$> v .:? asKey PreambleK <*> v .:? asKey ExecutableK .!= plantumlExe defaultConfiguration <*> v .:? asKey CommandLineArgsK .!= plantumlCmdArgs defaultConfiguration
276283 parseJSON _ = fail $ mconcat [" Could not parse " , show PlantUML , " configuration." ]
277284
285+ instance FromJSON SageMathPrecursor where
286+ parseJSON (Object v) = SageMathPrecursor <$> v .:? asKey PreambleK <*> v .:? asKey ExecutableK .!= sagemathExe defaultConfiguration <*> v .:? asKey CommandLineArgsK .!= sagemathCmdArgs defaultConfiguration
287+ parseJSON _ = fail $ mconcat [" Could not parse " , show SageMath , " configuration." ]
288+
278289toolkitAsKey :: Toolkit -> Key
279290toolkitAsKey = fromString . unpack . cls
280291
@@ -303,6 +314,7 @@ instance FromJSON ConfigPrecursor where
303314 _bokehPrec <- v .:? toolkitAsKey Bokeh .!= _bokehPrec defaultConfigPrecursor
304315 _plotsjlPrec <- v .:? toolkitAsKey Plotsjl .!= _plotsjlPrec defaultConfigPrecursor
305316 _plantumlPrec <- v .:? toolkitAsKey PlantUML .!= _plantumlPrec defaultConfigPrecursor
317+ _sagemathPrec <- v .:? toolkitAsKey SageMath .!= _sagemathPrec defaultConfigPrecursor
306318
307319 return $ ConfigPrecursor {.. }
308320 parseJSON _ = fail " Could not parse configuration."
@@ -336,6 +348,7 @@ renderConfig ConfigPrecursor {..} = do
336348 bokehExe = _bokehExe _bokehPrec
337349 plotsjlExe = _plotsjlExe _plotsjlPrec
338350 plantumlExe = _plantumlExe _plantumlPrec
351+ sagemathExe = _sagemathExe _sagemathPrec
339352
340353 matplotlibCmdArgs = _matplotlibCmdArgs _matplotlibPrec
341354 matlabCmdArgs = _matlabCmdArgs _matlabPrec
@@ -349,6 +362,7 @@ renderConfig ConfigPrecursor {..} = do
349362 bokehCmdArgs = _bokehCmdArgs _bokehPrec
350363 plotsjlCmdArgs = _plotsjlCmdArgs _plotsjlPrec
351364 plantumlCmdArgs = _plantumlCmdArgs _plantumlPrec
365+ sagemathCmdArgs = _sagemathCmdArgs _sagemathPrec
352366
353367 matplotlibPreamble <- readPreamble (_matplotlibPreamble _matplotlibPrec)
354368 matlabPreamble <- readPreamble (_matlabPreamble _matlabPrec)
@@ -362,6 +376,7 @@ renderConfig ConfigPrecursor {..} = do
362376 bokehPreamble <- readPreamble (_bokehPreamble _bokehPrec)
363377 plotsjlPreamble <- readPreamble (_plotsjlPreamble _plotsjlPrec)
364378 plantumlPreamble <- readPreamble (_plantumlPreamble _plantumlPrec)
379+ sagemathPreamble <- readPreamble (_sagemathPreamble _sagemathPrec)
365380
366381 return Configuration {.. }
367382 where
0 commit comments