@@ -66,6 +66,7 @@ defaultConfiguration =
6666 sagemathPreamble = mempty ,
6767 d2Preamble = mempty ,
6868 asyPreamble = mempty ,
69+ mermaidPreamble = mempty ,
6970 -- Executables
7071 matplotlibExe = python,
7172 matlabExe = " matlab" ,
@@ -82,6 +83,7 @@ defaultConfiguration =
8283 sagemathExe = " sage" ,
8384 d2Exe = " d2" ,
8485 asyExe = " asy" ,
86+ mermaidExe = " mmdc" ,
8587 -- Command line arguments
8688 matplotlibCmdArgs = mempty ,
8789 matlabCmdArgs = mempty ,
@@ -98,6 +100,7 @@ defaultConfiguration =
98100 sagemathCmdArgs = mempty ,
99101 d2CmdArgs = mempty ,
100102 asyCmdArgs = mempty ,
103+ mermaidCmdArgs = mempty ,
101104 -- Extras
102105 matplotlibTightBBox = False ,
103106 matplotlibTransparent = False
@@ -159,7 +162,8 @@ data ConfigPrecursor = ConfigPrecursor
159162 _plantumlPrec :: ! PlantUMLPrecursor ,
160163 _sagemathPrec :: ! SageMathPrecursor ,
161164 _d2Prec :: ! D2Precursor ,
162- _asyPrec :: ! AsyPrecursor
165+ _asyPrec :: ! AsyPrecursor ,
166+ _mermaidPrec :: ! MermaidPrecursor
163167 }
164168
165169defaultConfigPrecursor :: ConfigPrecursor
@@ -188,7 +192,8 @@ defaultConfigPrecursor =
188192 _plantumlPrec = PlantUMLPrecursor Nothing (plantumlExe defaultConfiguration) (plantumlCmdArgs defaultConfiguration),
189193 _sagemathPrec = SageMathPrecursor Nothing (sagemathExe defaultConfiguration) (sagemathCmdArgs defaultConfiguration),
190194 _d2Prec = D2Precursor Nothing (d2Exe defaultConfiguration) (d2CmdArgs defaultConfiguration),
191- _asyPrec = AsyPrecursor Nothing (asyExe defaultConfiguration) (asyCmdArgs defaultConfiguration)
195+ _asyPrec = AsyPrecursor Nothing (asyExe defaultConfiguration) (asyCmdArgs defaultConfiguration),
196+ _mermaidPrec = MermaidPrecursor Nothing (mermaidExe defaultConfiguration) (mermaidCmdArgs defaultConfiguration)
192197 }
193198
194199data LoggingPrecursor = LoggingPrecursor
@@ -233,6 +238,8 @@ data D2Precursor = D2Precursor {_d2Preamble :: !(Maybe FilePath), _d2Exe :: !Fil
233238
234239data AsyPrecursor = AsyPrecursor { _asyPreamble :: ! (Maybe FilePath ), _asyExe :: ! FilePath , _asyCmdArgs :: ! Text }
235240
241+ data MermaidPrecursor = MermaidPrecursor { _mermaidPreamble :: ! (Maybe FilePath ), _mermaidExe :: ! FilePath , _mermaidCmdArgs :: ! Text }
242+
236243instance FromJSON LoggingPrecursor where
237244 parseJSON (Object v) =
238245 LoggingPrecursor
@@ -303,12 +310,16 @@ instance FromJSON SageMathPrecursor where
303310
304311instance FromJSON D2Precursor where
305312 parseJSON (Object v) = D2Precursor <$> v .:? asKey PreambleK <*> v .:? asKey ExecutableK .!= d2Exe defaultConfiguration <*> v .:? asKey CommandLineArgsK .!= d2CmdArgs defaultConfiguration
306- parseJSON _ = fail $ mconcat [" Could not parse " , show SageMath , " configuration." ]
313+ parseJSON _ = fail $ mconcat [" Could not parse " , show D2 , " configuration." ]
307314
308315instance FromJSON AsyPrecursor where
309316 parseJSON (Object v) = AsyPrecursor <$> v .:? asKey PreambleK <*> v .:? asKey ExecutableK .!= asyExe defaultConfiguration <*> v .:? asKey CommandLineArgsK .!= asyCmdArgs defaultConfiguration
310317 parseJSON _ = fail $ mconcat [" Could not parse " , show Asymptote , " configuration." ]
311318
319+ instance FromJSON MermaidPrecursor where
320+ parseJSON (Object v) = MermaidPrecursor <$> v .:? asKey PreambleK <*> v .:? asKey ExecutableK .!= mermaidExe defaultConfiguration <*> v .:? asKey CommandLineArgsK .!= mermaidCmdArgs defaultConfiguration
321+ parseJSON _ = fail $ mconcat [" Could not parse " , show Mermaid , " configuration." ]
322+
312323toolkitAsKey :: Toolkit -> Key
313324toolkitAsKey = fromString . unpack . cls
314325
@@ -340,6 +351,7 @@ instance FromJSON ConfigPrecursor where
340351 _sagemathPrec <- v .:? toolkitAsKey SageMath .!= _sagemathPrec defaultConfigPrecursor
341352 _d2Prec <- v .:? toolkitAsKey D2 .!= _d2Prec defaultConfigPrecursor
342353 _asyPrec <- v .:? toolkitAsKey Asymptote .!= _asyPrec defaultConfigPrecursor
354+ _mermaidPrec <- v .:? toolkitAsKey Mermaid .!= _mermaidPrec defaultConfigPrecursor
343355
344356 return $ ConfigPrecursor {.. }
345357 parseJSON _ = fail " Could not parse configuration."
@@ -376,6 +388,7 @@ renderConfig ConfigPrecursor {..} = do
376388 sagemathExe = _sagemathExe _sagemathPrec
377389 d2Exe = _d2Exe _d2Prec
378390 asyExe = _asyExe _asyPrec
391+ mermaidExe = _mermaidExe _mermaidPrec
379392
380393 matplotlibCmdArgs = _matplotlibCmdArgs _matplotlibPrec
381394 matlabCmdArgs = _matlabCmdArgs _matlabPrec
@@ -392,6 +405,7 @@ renderConfig ConfigPrecursor {..} = do
392405 sagemathCmdArgs = _sagemathCmdArgs _sagemathPrec
393406 d2CmdArgs = _d2CmdArgs _d2Prec
394407 asyCmdArgs = _asyCmdArgs _asyPrec
408+ mermaidCmdArgs = _mermaidCmdArgs _mermaidPrec
395409
396410 matplotlibPreamble <- readPreamble (_matplotlibPreamble _matplotlibPrec)
397411 matlabPreamble <- readPreamble (_matlabPreamble _matlabPrec)
@@ -408,6 +422,7 @@ renderConfig ConfigPrecursor {..} = do
408422 sagemathPreamble <- readPreamble (_sagemathPreamble _sagemathPrec)
409423 d2Preamble <- readPreamble (_d2Preamble _d2Prec)
410424 asyPreamble <- readPreamble (_asyPreamble _asyPrec)
425+ mermaidPreamble <- readPreamble (_mermaidPreamble _mermaidPrec)
411426
412427 return Configuration {.. }
413428 where
0 commit comments