{-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE TemplateHaskell #-}
module Patat.Presentation.Settings
( PresentationSettings (..)
, defaultPresentationSettings
, Wrap (..)
, AutoOr (..)
, MarginSettings (..)
, ExtensionList (..)
, defaultExtensionList
, ImageSettings (..)
, EvalSettingsMap
, EvalSettingsContainer (..)
, EvalSettings (..)
, SpeakerNotesSettings (..)
, TransitionSettings (..)
) where
import Control.Applicative ((<|>))
import Control.Monad (mplus)
import qualified Data.Aeson.Extended as A
import qualified Data.Aeson.TH.Extended as A
import qualified Data.Foldable as Foldable
import Data.Function (on)
import qualified Data.HashMap.Strict as HMS
import Data.List (intercalate)
import qualified Data.Text as T
import qualified Patat.Theme as Theme
import Prelude
import qualified Text.Pandoc as Pandoc
import Text.Read (readMaybe)
data PresentationSettings = PresentationSettings
{ PresentationSettings -> Maybe (FlexibleNum Int)
psRows :: !(Maybe (A.FlexibleNum Int))
, PresentationSettings -> Maybe (FlexibleNum Int)
psColumns :: !(Maybe (A.FlexibleNum Int))
, PresentationSettings -> Maybe MarginSettings
psMargins :: !(Maybe MarginSettings)
, PresentationSettings -> Maybe Wrap
psWrap :: !(Maybe Wrap)
, PresentationSettings -> Maybe (FlexibleNum Int)
psTabStop :: !(Maybe (A.FlexibleNum Int))
, PresentationSettings -> Maybe Theme
psTheme :: !(Maybe Theme.Theme)
, PresentationSettings -> Maybe Bool
psIncrementalLists :: !(Maybe Bool)
, PresentationSettings -> Maybe (FlexibleNum Int)
psAutoAdvanceDelay :: !(Maybe (A.FlexibleNum Int))
, PresentationSettings -> Maybe Int
psSlideLevel :: !(Maybe Int)
, PresentationSettings -> Maybe ExtensionList
psPandocExtensions :: !(Maybe ExtensionList)
, PresentationSettings -> Maybe ImageSettings
psImages :: !(Maybe ImageSettings)
, PresentationSettings -> Maybe Bool
psBreadcrumbs :: !(Maybe Bool)
, PresentationSettings -> Maybe EvalSettingsMap
psEval :: !(Maybe EvalSettingsMap)
, PresentationSettings -> Maybe Bool
psSlideNumber :: !(Maybe Bool)
, PresentationSettings -> Maybe [FilePath]
psSyntaxDefinitions :: !(Maybe [FilePath])
, PresentationSettings -> Maybe SpeakerNotesSettings
psSpeakerNotes :: !(Maybe SpeakerNotesSettings)
, PresentationSettings -> Maybe TransitionSettings
psTransition :: !(Maybe TransitionSettings)
} deriving (Int -> PresentationSettings -> ShowS
[PresentationSettings] -> ShowS
PresentationSettings -> FilePath
(Int -> PresentationSettings -> ShowS)
-> (PresentationSettings -> FilePath)
-> ([PresentationSettings] -> ShowS)
-> Show PresentationSettings
forall a.
(Int -> a -> ShowS) -> (a -> FilePath) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> PresentationSettings -> ShowS
showsPrec :: Int -> PresentationSettings -> ShowS
$cshow :: PresentationSettings -> FilePath
show :: PresentationSettings -> FilePath
$cshowList :: [PresentationSettings] -> ShowS
showList :: [PresentationSettings] -> ShowS
Show)
instance Semigroup PresentationSettings where
PresentationSettings
l <> :: PresentationSettings
-> PresentationSettings -> PresentationSettings
<> PresentationSettings
r = PresentationSettings
{ psRows :: Maybe (FlexibleNum Int)
psRows = (Maybe (FlexibleNum Int)
-> Maybe (FlexibleNum Int) -> Maybe (FlexibleNum Int))
-> (PresentationSettings -> Maybe (FlexibleNum Int))
-> PresentationSettings
-> PresentationSettings
-> Maybe (FlexibleNum Int)
forall b c a. (b -> b -> c) -> (a -> b) -> a -> a -> c
on Maybe (FlexibleNum Int)
-> Maybe (FlexibleNum Int) -> Maybe (FlexibleNum Int)
forall a. Maybe a -> Maybe a -> Maybe a
forall (m :: * -> *) a. MonadPlus m => m a -> m a -> m a
mplus PresentationSettings -> Maybe (FlexibleNum Int)
psRows PresentationSettings
l PresentationSettings
r
, psColumns :: Maybe (FlexibleNum Int)
psColumns = (Maybe (FlexibleNum Int)
-> Maybe (FlexibleNum Int) -> Maybe (FlexibleNum Int))
-> (PresentationSettings -> Maybe (FlexibleNum Int))
-> PresentationSettings
-> PresentationSettings
-> Maybe (FlexibleNum Int)
forall b c a. (b -> b -> c) -> (a -> b) -> a -> a -> c
on Maybe (FlexibleNum Int)
-> Maybe (FlexibleNum Int) -> Maybe (FlexibleNum Int)
forall a. Maybe a -> Maybe a -> Maybe a
forall (m :: * -> *) a. MonadPlus m => m a -> m a -> m a
mplus PresentationSettings -> Maybe (FlexibleNum Int)
psColumns PresentationSettings
l PresentationSettings
r
, psMargins :: Maybe MarginSettings
psMargins = (Maybe MarginSettings
-> Maybe MarginSettings -> Maybe MarginSettings)
-> (PresentationSettings -> Maybe MarginSettings)
-> PresentationSettings
-> PresentationSettings
-> Maybe MarginSettings
forall b c a. (b -> b -> c) -> (a -> b) -> a -> a -> c
on Maybe MarginSettings
-> Maybe MarginSettings -> Maybe MarginSettings
forall a. Semigroup a => a -> a -> a
(<>) PresentationSettings -> Maybe MarginSettings
psMargins PresentationSettings
l PresentationSettings
r
, psWrap :: Maybe Wrap
psWrap = (Maybe Wrap -> Maybe Wrap -> Maybe Wrap)
-> (PresentationSettings -> Maybe Wrap)
-> PresentationSettings
-> PresentationSettings
-> Maybe Wrap
forall b c a. (b -> b -> c) -> (a -> b) -> a -> a -> c
on Maybe Wrap -> Maybe Wrap -> Maybe Wrap
forall a. Maybe a -> Maybe a -> Maybe a
forall (m :: * -> *) a. MonadPlus m => m a -> m a -> m a
mplus PresentationSettings -> Maybe Wrap
psWrap PresentationSettings
l PresentationSettings
r
, psTabStop :: Maybe (FlexibleNum Int)
psTabStop = (Maybe (FlexibleNum Int)
-> Maybe (FlexibleNum Int) -> Maybe (FlexibleNum Int))
-> (PresentationSettings -> Maybe (FlexibleNum Int))
-> PresentationSettings
-> PresentationSettings
-> Maybe (FlexibleNum Int)
forall b c a. (b -> b -> c) -> (a -> b) -> a -> a -> c
on Maybe (FlexibleNum Int)
-> Maybe (FlexibleNum Int) -> Maybe (FlexibleNum Int)
forall a. Maybe a -> Maybe a -> Maybe a
forall (m :: * -> *) a. MonadPlus m => m a -> m a -> m a
mplus PresentationSettings -> Maybe (FlexibleNum Int)
psTabStop PresentationSettings
l PresentationSettings
r
, psTheme :: Maybe Theme
psTheme = (Maybe Theme -> Maybe Theme -> Maybe Theme)
-> (PresentationSettings -> Maybe Theme)
-> PresentationSettings
-> PresentationSettings
-> Maybe Theme
forall b c a. (b -> b -> c) -> (a -> b) -> a -> a -> c
on Maybe Theme -> Maybe Theme -> Maybe Theme
forall a. Semigroup a => a -> a -> a
(<>) PresentationSettings -> Maybe Theme
psTheme PresentationSettings
l PresentationSettings
r
, psIncrementalLists :: Maybe Bool
psIncrementalLists = (Maybe Bool -> Maybe Bool -> Maybe Bool)
-> (PresentationSettings -> Maybe Bool)
-> PresentationSettings
-> PresentationSettings
-> Maybe Bool
forall b c a. (b -> b -> c) -> (a -> b) -> a -> a -> c
on Maybe Bool -> Maybe Bool -> Maybe Bool
forall a. Maybe a -> Maybe a -> Maybe a
forall (m :: * -> *) a. MonadPlus m => m a -> m a -> m a
mplus PresentationSettings -> Maybe Bool
psIncrementalLists PresentationSettings
l PresentationSettings
r
, psAutoAdvanceDelay :: Maybe (FlexibleNum Int)
psAutoAdvanceDelay = (Maybe (FlexibleNum Int)
-> Maybe (FlexibleNum Int) -> Maybe (FlexibleNum Int))
-> (PresentationSettings -> Maybe (FlexibleNum Int))
-> PresentationSettings
-> PresentationSettings
-> Maybe (FlexibleNum Int)
forall b c a. (b -> b -> c) -> (a -> b) -> a -> a -> c
on Maybe (FlexibleNum Int)
-> Maybe (FlexibleNum Int) -> Maybe (FlexibleNum Int)
forall a. Maybe a -> Maybe a -> Maybe a
forall (m :: * -> *) a. MonadPlus m => m a -> m a -> m a
mplus PresentationSettings -> Maybe (FlexibleNum Int)
psAutoAdvanceDelay PresentationSettings
l PresentationSettings
r
, psSlideLevel :: Maybe Int
psSlideLevel = (Maybe Int -> Maybe Int -> Maybe Int)
-> (PresentationSettings -> Maybe Int)
-> PresentationSettings
-> PresentationSettings
-> Maybe Int
forall b c a. (b -> b -> c) -> (a -> b) -> a -> a -> c
on Maybe Int -> Maybe Int -> Maybe Int
forall a. Maybe a -> Maybe a -> Maybe a
forall (m :: * -> *) a. MonadPlus m => m a -> m a -> m a
mplus PresentationSettings -> Maybe Int
psSlideLevel PresentationSettings
l PresentationSettings
r
, psPandocExtensions :: Maybe ExtensionList
psPandocExtensions = (Maybe ExtensionList -> Maybe ExtensionList -> Maybe ExtensionList)
-> (PresentationSettings -> Maybe ExtensionList)
-> PresentationSettings
-> PresentationSettings
-> Maybe ExtensionList
forall b c a. (b -> b -> c) -> (a -> b) -> a -> a -> c
on Maybe ExtensionList -> Maybe ExtensionList -> Maybe ExtensionList
forall a. Maybe a -> Maybe a -> Maybe a
forall (m :: * -> *) a. MonadPlus m => m a -> m a -> m a
mplus PresentationSettings -> Maybe ExtensionList
psPandocExtensions PresentationSettings
l PresentationSettings
r
, psImages :: Maybe ImageSettings
psImages = (Maybe ImageSettings -> Maybe ImageSettings -> Maybe ImageSettings)
-> (PresentationSettings -> Maybe ImageSettings)
-> PresentationSettings
-> PresentationSettings
-> Maybe ImageSettings
forall b c a. (b -> b -> c) -> (a -> b) -> a -> a -> c
on Maybe ImageSettings -> Maybe ImageSettings -> Maybe ImageSettings
forall a. Maybe a -> Maybe a -> Maybe a
forall (m :: * -> *) a. MonadPlus m => m a -> m a -> m a
mplus PresentationSettings -> Maybe ImageSettings
psImages PresentationSettings
l PresentationSettings
r
, psBreadcrumbs :: Maybe Bool
psBreadcrumbs = (Maybe Bool -> Maybe Bool -> Maybe Bool)
-> (PresentationSettings -> Maybe Bool)
-> PresentationSettings
-> PresentationSettings
-> Maybe Bool
forall b c a. (b -> b -> c) -> (a -> b) -> a -> a -> c
on Maybe Bool -> Maybe Bool -> Maybe Bool
forall a. Maybe a -> Maybe a -> Maybe a
forall (m :: * -> *) a. MonadPlus m => m a -> m a -> m a
mplus PresentationSettings -> Maybe Bool
psBreadcrumbs PresentationSettings
l PresentationSettings
r
, psEval :: Maybe EvalSettingsMap
psEval = (Maybe EvalSettingsMap
-> Maybe EvalSettingsMap -> Maybe EvalSettingsMap)
-> (PresentationSettings -> Maybe EvalSettingsMap)
-> PresentationSettings
-> PresentationSettings
-> Maybe EvalSettingsMap
forall b c a. (b -> b -> c) -> (a -> b) -> a -> a -> c
on Maybe EvalSettingsMap
-> Maybe EvalSettingsMap -> Maybe EvalSettingsMap
forall a. Semigroup a => a -> a -> a
(<>) PresentationSettings -> Maybe EvalSettingsMap
psEval PresentationSettings
l PresentationSettings
r
, psSlideNumber :: Maybe Bool
psSlideNumber = (Maybe Bool -> Maybe Bool -> Maybe Bool)
-> (PresentationSettings -> Maybe Bool)
-> PresentationSettings
-> PresentationSettings
-> Maybe Bool
forall b c a. (b -> b -> c) -> (a -> b) -> a -> a -> c
on Maybe Bool -> Maybe Bool -> Maybe Bool
forall a. Maybe a -> Maybe a -> Maybe a
forall (m :: * -> *) a. MonadPlus m => m a -> m a -> m a
mplus PresentationSettings -> Maybe Bool
psSlideNumber PresentationSettings
l PresentationSettings
r
, psSyntaxDefinitions :: Maybe [FilePath]
psSyntaxDefinitions = (Maybe [FilePath] -> Maybe [FilePath] -> Maybe [FilePath])
-> (PresentationSettings -> Maybe [FilePath])
-> PresentationSettings
-> PresentationSettings
-> Maybe [FilePath]
forall b c a. (b -> b -> c) -> (a -> b) -> a -> a -> c
on Maybe [FilePath] -> Maybe [FilePath] -> Maybe [FilePath]
forall a. Semigroup a => a -> a -> a
(<>) PresentationSettings -> Maybe [FilePath]
psSyntaxDefinitions PresentationSettings
l PresentationSettings
r
, psSpeakerNotes :: Maybe SpeakerNotesSettings
psSpeakerNotes = (Maybe SpeakerNotesSettings
-> Maybe SpeakerNotesSettings -> Maybe SpeakerNotesSettings)
-> (PresentationSettings -> Maybe SpeakerNotesSettings)
-> PresentationSettings
-> PresentationSettings
-> Maybe SpeakerNotesSettings
forall b c a. (b -> b -> c) -> (a -> b) -> a -> a -> c
on Maybe SpeakerNotesSettings
-> Maybe SpeakerNotesSettings -> Maybe SpeakerNotesSettings
forall a. Maybe a -> Maybe a -> Maybe a
forall (m :: * -> *) a. MonadPlus m => m a -> m a -> m a
mplus PresentationSettings -> Maybe SpeakerNotesSettings
psSpeakerNotes PresentationSettings
l PresentationSettings
r
, psTransition :: Maybe TransitionSettings
psTransition = (Maybe TransitionSettings
-> Maybe TransitionSettings -> Maybe TransitionSettings)
-> (PresentationSettings -> Maybe TransitionSettings)
-> PresentationSettings
-> PresentationSettings
-> Maybe TransitionSettings
forall b c a. (b -> b -> c) -> (a -> b) -> a -> a -> c
on Maybe TransitionSettings
-> Maybe TransitionSettings -> Maybe TransitionSettings
forall a. Maybe a -> Maybe a -> Maybe a
forall (m :: * -> *) a. MonadPlus m => m a -> m a -> m a
mplus PresentationSettings -> Maybe TransitionSettings
psTransition PresentationSettings
l PresentationSettings
r
}
instance Monoid PresentationSettings where
mappend :: PresentationSettings
-> PresentationSettings -> PresentationSettings
mappend = PresentationSettings
-> PresentationSettings -> PresentationSettings
forall a. Semigroup a => a -> a -> a
(<>)
mempty :: PresentationSettings
mempty = Maybe (FlexibleNum Int)
-> Maybe (FlexibleNum Int)
-> Maybe MarginSettings
-> Maybe Wrap
-> Maybe (FlexibleNum Int)
-> Maybe Theme
-> Maybe Bool
-> Maybe (FlexibleNum Int)
-> Maybe Int
-> Maybe ExtensionList
-> Maybe ImageSettings
-> Maybe Bool
-> Maybe EvalSettingsMap
-> Maybe Bool
-> Maybe [FilePath]
-> Maybe SpeakerNotesSettings
-> Maybe TransitionSettings
-> PresentationSettings
PresentationSettings
Maybe (FlexibleNum Int)
forall a. Maybe a
Nothing Maybe (FlexibleNum Int)
forall a. Maybe a
Nothing Maybe MarginSettings
forall a. Maybe a
Nothing Maybe Wrap
forall a. Maybe a
Nothing Maybe (FlexibleNum Int)
forall a. Maybe a
Nothing Maybe Theme
forall a. Maybe a
Nothing Maybe Bool
forall a. Maybe a
Nothing Maybe (FlexibleNum Int)
forall a. Maybe a
Nothing
Maybe Int
forall a. Maybe a
Nothing Maybe ExtensionList
forall a. Maybe a
Nothing Maybe ImageSettings
forall a. Maybe a
Nothing Maybe Bool
forall a. Maybe a
Nothing Maybe EvalSettingsMap
forall a. Maybe a
Nothing Maybe Bool
forall a. Maybe a
Nothing Maybe [FilePath]
forall a. Maybe a
Nothing Maybe SpeakerNotesSettings
forall a. Maybe a
Nothing
Maybe TransitionSettings
forall a. Maybe a
Nothing
defaultPresentationSettings :: PresentationSettings
defaultPresentationSettings :: PresentationSettings
defaultPresentationSettings = PresentationSettings
forall a. Monoid a => a
mempty
{ psMargins = Nothing
, psTheme = Just Theme.defaultTheme
}
data Wrap = NoWrap | AutoWrap | WrapAt Int deriving (Int -> Wrap -> ShowS
[Wrap] -> ShowS
Wrap -> FilePath
(Int -> Wrap -> ShowS)
-> (Wrap -> FilePath) -> ([Wrap] -> ShowS) -> Show Wrap
forall a.
(Int -> a -> ShowS) -> (a -> FilePath) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> Wrap -> ShowS
showsPrec :: Int -> Wrap -> ShowS
$cshow :: Wrap -> FilePath
show :: Wrap -> FilePath
$cshowList :: [Wrap] -> ShowS
showList :: [Wrap] -> ShowS
Show)
instance A.FromJSON Wrap where
parseJSON :: Value -> Parser Wrap
parseJSON Value
val =
((\Bool
w -> if Bool
w then Wrap
AutoWrap else Wrap
NoWrap) (Bool -> Wrap) -> Parser Bool -> Parser Wrap
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Value -> Parser Bool
forall a. FromJSON a => Value -> Parser a
A.parseJSON Value
val) Parser Wrap -> Parser Wrap -> Parser Wrap
forall a. Parser a -> Parser a -> Parser a
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|>
(Int -> Wrap
WrapAt (Int -> Wrap) -> Parser Int -> Parser Wrap
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Value -> Parser Int
forall a. FromJSON a => Value -> Parser a
A.parseJSON Value
val)
data AutoOr a = Auto | NotAuto a deriving (Int -> AutoOr a -> ShowS
[AutoOr a] -> ShowS
AutoOr a -> FilePath
(Int -> AutoOr a -> ShowS)
-> (AutoOr a -> FilePath)
-> ([AutoOr a] -> ShowS)
-> Show (AutoOr a)
forall a. Show a => Int -> AutoOr a -> ShowS
forall a. Show a => [AutoOr a] -> ShowS
forall a. Show a => AutoOr a -> FilePath
forall a.
(Int -> a -> ShowS) -> (a -> FilePath) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: forall a. Show a => Int -> AutoOr a -> ShowS
showsPrec :: Int -> AutoOr a -> ShowS
$cshow :: forall a. Show a => AutoOr a -> FilePath
show :: AutoOr a -> FilePath
$cshowList :: forall a. Show a => [AutoOr a] -> ShowS
showList :: [AutoOr a] -> ShowS
Show)
instance A.FromJSON a => A.FromJSON (AutoOr a) where
parseJSON :: Value -> Parser (AutoOr a)
parseJSON (A.String Text
"auto") = AutoOr a -> Parser (AutoOr a)
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure AutoOr a
forall a. AutoOr a
Auto
parseJSON Value
val = a -> AutoOr a
forall a. a -> AutoOr a
NotAuto (a -> AutoOr a) -> Parser a -> Parser (AutoOr a)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Value -> Parser a
forall a. FromJSON a => Value -> Parser a
A.parseJSON Value
val
data MarginSettings = MarginSettings
{ MarginSettings -> Maybe (AutoOr (FlexibleNum Int))
msTop :: !(Maybe (AutoOr (A.FlexibleNum Int)))
, MarginSettings -> Maybe (AutoOr (FlexibleNum Int))
msLeft :: !(Maybe (AutoOr (A.FlexibleNum Int)))
, MarginSettings -> Maybe (AutoOr (FlexibleNum Int))
msRight :: !(Maybe (AutoOr (A.FlexibleNum Int)))
} deriving (Int -> MarginSettings -> ShowS
[MarginSettings] -> ShowS
MarginSettings -> FilePath
(Int -> MarginSettings -> ShowS)
-> (MarginSettings -> FilePath)
-> ([MarginSettings] -> ShowS)
-> Show MarginSettings
forall a.
(Int -> a -> ShowS) -> (a -> FilePath) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> MarginSettings -> ShowS
showsPrec :: Int -> MarginSettings -> ShowS
$cshow :: MarginSettings -> FilePath
show :: MarginSettings -> FilePath
$cshowList :: [MarginSettings] -> ShowS
showList :: [MarginSettings] -> ShowS
Show)
instance Semigroup MarginSettings where
MarginSettings
l <> :: MarginSettings -> MarginSettings -> MarginSettings
<> MarginSettings
r = MarginSettings
{ msTop :: Maybe (AutoOr (FlexibleNum Int))
msTop = (Maybe (AutoOr (FlexibleNum Int))
-> Maybe (AutoOr (FlexibleNum Int))
-> Maybe (AutoOr (FlexibleNum Int)))
-> (MarginSettings -> Maybe (AutoOr (FlexibleNum Int)))
-> MarginSettings
-> MarginSettings
-> Maybe (AutoOr (FlexibleNum Int))
forall b c a. (b -> b -> c) -> (a -> b) -> a -> a -> c
on Maybe (AutoOr (FlexibleNum Int))
-> Maybe (AutoOr (FlexibleNum Int))
-> Maybe (AutoOr (FlexibleNum Int))
forall a. Maybe a -> Maybe a -> Maybe a
forall (m :: * -> *) a. MonadPlus m => m a -> m a -> m a
mplus MarginSettings -> Maybe (AutoOr (FlexibleNum Int))
msTop MarginSettings
l MarginSettings
r
, msLeft :: Maybe (AutoOr (FlexibleNum Int))
msLeft = (Maybe (AutoOr (FlexibleNum Int))
-> Maybe (AutoOr (FlexibleNum Int))
-> Maybe (AutoOr (FlexibleNum Int)))
-> (MarginSettings -> Maybe (AutoOr (FlexibleNum Int)))
-> MarginSettings
-> MarginSettings
-> Maybe (AutoOr (FlexibleNum Int))
forall b c a. (b -> b -> c) -> (a -> b) -> a -> a -> c
on Maybe (AutoOr (FlexibleNum Int))
-> Maybe (AutoOr (FlexibleNum Int))
-> Maybe (AutoOr (FlexibleNum Int))
forall a. Maybe a -> Maybe a -> Maybe a
forall (m :: * -> *) a. MonadPlus m => m a -> m a -> m a
mplus MarginSettings -> Maybe (AutoOr (FlexibleNum Int))
msLeft MarginSettings
l MarginSettings
r
, msRight :: Maybe (AutoOr (FlexibleNum Int))
msRight = (Maybe (AutoOr (FlexibleNum Int))
-> Maybe (AutoOr (FlexibleNum Int))
-> Maybe (AutoOr (FlexibleNum Int)))
-> (MarginSettings -> Maybe (AutoOr (FlexibleNum Int)))
-> MarginSettings
-> MarginSettings
-> Maybe (AutoOr (FlexibleNum Int))
forall b c a. (b -> b -> c) -> (a -> b) -> a -> a -> c
on Maybe (AutoOr (FlexibleNum Int))
-> Maybe (AutoOr (FlexibleNum Int))
-> Maybe (AutoOr (FlexibleNum Int))
forall a. Maybe a -> Maybe a -> Maybe a
forall (m :: * -> *) a. MonadPlus m => m a -> m a -> m a
mplus MarginSettings -> Maybe (AutoOr (FlexibleNum Int))
msRight MarginSettings
l MarginSettings
r
}
instance Monoid MarginSettings where
mappend :: MarginSettings -> MarginSettings -> MarginSettings
mappend = MarginSettings -> MarginSettings -> MarginSettings
forall a. Semigroup a => a -> a -> a
(<>)
mempty :: MarginSettings
mempty = Maybe (AutoOr (FlexibleNum Int))
-> Maybe (AutoOr (FlexibleNum Int))
-> Maybe (AutoOr (FlexibleNum Int))
-> MarginSettings
MarginSettings Maybe (AutoOr (FlexibleNum Int))
forall a. Maybe a
Nothing Maybe (AutoOr (FlexibleNum Int))
forall a. Maybe a
Nothing Maybe (AutoOr (FlexibleNum Int))
forall a. Maybe a
Nothing
newtype ExtensionList = ExtensionList {ExtensionList -> Extensions
unExtensionList :: Pandoc.Extensions}
deriving (Int -> ExtensionList -> ShowS
[ExtensionList] -> ShowS
ExtensionList -> FilePath
(Int -> ExtensionList -> ShowS)
-> (ExtensionList -> FilePath)
-> ([ExtensionList] -> ShowS)
-> Show ExtensionList
forall a.
(Int -> a -> ShowS) -> (a -> FilePath) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> ExtensionList -> ShowS
showsPrec :: Int -> ExtensionList -> ShowS
$cshow :: ExtensionList -> FilePath
show :: ExtensionList -> FilePath
$cshowList :: [ExtensionList] -> ShowS
showList :: [ExtensionList] -> ShowS
Show)
instance A.FromJSON ExtensionList where
parseJSON :: Value -> Parser ExtensionList
parseJSON = FilePath
-> (Array -> Parser ExtensionList) -> Value -> Parser ExtensionList
forall a. FilePath -> (Array -> Parser a) -> Value -> Parser a
A.withArray FilePath
"FromJSON ExtensionList" ((Array -> Parser ExtensionList) -> Value -> Parser ExtensionList)
-> (Array -> Parser ExtensionList) -> Value -> Parser ExtensionList
forall a b. (a -> b) -> a -> b
$
([Extensions] -> ExtensionList)
-> Parser [Extensions] -> Parser ExtensionList
forall a b. (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (Extensions -> ExtensionList
ExtensionList (Extensions -> ExtensionList)
-> ([Extensions] -> Extensions) -> [Extensions] -> ExtensionList
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [Extensions] -> Extensions
forall a. Monoid a => [a] -> a
mconcat) (Parser [Extensions] -> Parser ExtensionList)
-> (Array -> Parser [Extensions]) -> Array -> Parser ExtensionList
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Value -> Parser Extensions) -> [Value] -> Parser [Extensions]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
forall (m :: * -> *) a b. Monad m => (a -> m b) -> [a] -> m [b]
mapM Value -> Parser Extensions
parseExt ([Value] -> Parser [Extensions])
-> (Array -> [Value]) -> Array -> Parser [Extensions]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Array -> [Value]
forall a. Vector a -> [a]
forall (t :: * -> *) a. Foldable t => t a -> [a]
Foldable.toList
where
parseExt :: Value -> Parser Extensions
parseExt = FilePath
-> (Text -> Parser Extensions) -> Value -> Parser Extensions
forall a. FilePath -> (Text -> Parser a) -> Value -> Parser a
A.withText FilePath
"FromJSON ExtensionList" ((Text -> Parser Extensions) -> Value -> Parser Extensions)
-> (Text -> Parser Extensions) -> Value -> Parser Extensions
forall a b. (a -> b) -> a -> b
$ \Text
txt -> case Text
txt of
Text
"patat_extensions" -> Extensions -> Parser Extensions
forall a. a -> Parser a
forall (m :: * -> *) a. Monad m => a -> m a
return (ExtensionList -> Extensions
unExtensionList ExtensionList
defaultExtensionList)
Text
_ -> case FilePath -> Maybe Extension
forall a. Read a => FilePath -> Maybe a
readMaybe (FilePath
"Ext_" FilePath -> ShowS
forall a. [a] -> [a] -> [a]
++ Text -> FilePath
T.unpack Text
txt) of
Just Extension
e -> Extensions -> Parser Extensions
forall a. a -> Parser a
forall (m :: * -> *) a. Monad m => a -> m a
return (Extensions -> Parser Extensions)
-> Extensions -> Parser Extensions
forall a b. (a -> b) -> a -> b
$ [Extension] -> Extensions
Pandoc.extensionsFromList [Extension
e]
Maybe Extension
Nothing -> FilePath -> Parser Extensions
forall a. FilePath -> Parser a
forall (m :: * -> *) a. MonadFail m => FilePath -> m a
fail (FilePath -> Parser Extensions) -> FilePath -> Parser Extensions
forall a b. (a -> b) -> a -> b
$
FilePath
"Unknown extension: " FilePath -> ShowS
forall a. [a] -> [a] -> [a]
++ Text -> FilePath
forall a. Show a => a -> FilePath
show Text
txt FilePath -> ShowS
forall a. [a] -> [a] -> [a]
++
FilePath
", known extensions are: " FilePath -> ShowS
forall a. [a] -> [a] -> [a]
++
FilePath -> [FilePath] -> FilePath
forall a. [a] -> [[a]] -> [a]
intercalate FilePath
", " ((Extension -> FilePath) -> [Extension] -> [FilePath]
forall a b. (a -> b) -> [a] -> [b]
map (Int -> ShowS
forall a. Int -> [a] -> [a]
drop Int
4 ShowS -> (Extension -> FilePath) -> Extension -> FilePath
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Extension -> FilePath
forall a. Show a => a -> FilePath
show) [Extension]
allExts)
where
allExts :: [Extension]
allExts = Extensions -> [Extension]
Pandoc.extensionsToList (Extensions -> [Extension]) -> Extensions -> [Extension]
forall a b. (a -> b) -> a -> b
$
Text -> Extensions
Pandoc.getAllExtensions Text
"markdown"
defaultExtensionList :: ExtensionList
defaultExtensionList :: ExtensionList
defaultExtensionList = Extensions -> ExtensionList
ExtensionList (Extensions -> ExtensionList) -> Extensions -> ExtensionList
forall a b. (a -> b) -> a -> b
$
ReaderOptions -> Extensions
Pandoc.readerExtensions ReaderOptions
forall a. Default a => a
Pandoc.def Extensions -> Extensions -> Extensions
forall a. Monoid a => a -> a -> a
`mappend` [Extension] -> Extensions
Pandoc.extensionsFromList
[ Extension
Pandoc.Ext_yaml_metadata_block
, Extension
Pandoc.Ext_table_captions
, Extension
Pandoc.Ext_simple_tables
, Extension
Pandoc.Ext_multiline_tables
, Extension
Pandoc.Ext_grid_tables
, Extension
Pandoc.Ext_pipe_tables
, Extension
Pandoc.Ext_raw_html
, Extension
Pandoc.Ext_tex_math_dollars
, Extension
Pandoc.Ext_fenced_code_blocks
, Extension
Pandoc.Ext_fenced_code_attributes
, Extension
Pandoc.Ext_backtick_code_blocks
, Extension
Pandoc.Ext_inline_code_attributes
, Extension
Pandoc.Ext_fancy_lists
, Extension
Pandoc.Ext_four_space_rule
, Extension
Pandoc.Ext_definition_lists
, Extension
Pandoc.Ext_compact_definition_lists
, Extension
Pandoc.Ext_example_lists
, Extension
Pandoc.Ext_strikeout
, Extension
Pandoc.Ext_superscript
, Extension
Pandoc.Ext_subscript
]
data ImageSettings = ImageSettings
{ ImageSettings -> Text
isBackend :: !T.Text
, ImageSettings -> Object
isParams :: !A.Object
} deriving (Int -> ImageSettings -> ShowS
[ImageSettings] -> ShowS
ImageSettings -> FilePath
(Int -> ImageSettings -> ShowS)
-> (ImageSettings -> FilePath)
-> ([ImageSettings] -> ShowS)
-> Show ImageSettings
forall a.
(Int -> a -> ShowS) -> (a -> FilePath) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> ImageSettings -> ShowS
showsPrec :: Int -> ImageSettings -> ShowS
$cshow :: ImageSettings -> FilePath
show :: ImageSettings -> FilePath
$cshowList :: [ImageSettings] -> ShowS
showList :: [ImageSettings] -> ShowS
Show)
instance A.FromJSON ImageSettings where
parseJSON :: Value -> Parser ImageSettings
parseJSON = FilePath
-> (Object -> Parser ImageSettings)
-> Value
-> Parser ImageSettings
forall a. FilePath -> (Object -> Parser a) -> Value -> Parser a
A.withObject FilePath
"FromJSON ImageSettings" ((Object -> Parser ImageSettings) -> Value -> Parser ImageSettings)
-> (Object -> Parser ImageSettings)
-> Value
-> Parser ImageSettings
forall a b. (a -> b) -> a -> b
$ \Object
o -> do
Text
t <- Object
o Object -> Key -> Parser Text
forall a. FromJSON a => Object -> Key -> Parser a
A..: Key
"backend"
ImageSettings -> Parser ImageSettings
forall a. a -> Parser a
forall (m :: * -> *) a. Monad m => a -> m a
return ImageSettings {isBackend :: Text
isBackend = Text
t, isParams :: Object
isParams = Object
o}
type EvalSettingsMap = HMS.HashMap T.Text EvalSettings
data EvalSettingsContainer
= EvalContainerCode
| EvalContainerNone
| EvalContainerInline
deriving (Int -> EvalSettingsContainer -> ShowS
[EvalSettingsContainer] -> ShowS
EvalSettingsContainer -> FilePath
(Int -> EvalSettingsContainer -> ShowS)
-> (EvalSettingsContainer -> FilePath)
-> ([EvalSettingsContainer] -> ShowS)
-> Show EvalSettingsContainer
forall a.
(Int -> a -> ShowS) -> (a -> FilePath) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> EvalSettingsContainer -> ShowS
showsPrec :: Int -> EvalSettingsContainer -> ShowS
$cshow :: EvalSettingsContainer -> FilePath
show :: EvalSettingsContainer -> FilePath
$cshowList :: [EvalSettingsContainer] -> ShowS
showList :: [EvalSettingsContainer] -> ShowS
Show)
instance A.FromJSON EvalSettingsContainer where
parseJSON :: Value -> Parser EvalSettingsContainer
parseJSON = FilePath
-> (Text -> Parser EvalSettingsContainer)
-> Value
-> Parser EvalSettingsContainer
forall a. FilePath -> (Text -> Parser a) -> Value -> Parser a
A.withText FilePath
"FromJSON EvalSettingsContainer" ((Text -> Parser EvalSettingsContainer)
-> Value -> Parser EvalSettingsContainer)
-> (Text -> Parser EvalSettingsContainer)
-> Value
-> Parser EvalSettingsContainer
forall a b. (a -> b) -> a -> b
$ \Text
t -> case Text
t of
Text
"code" -> EvalSettingsContainer -> Parser EvalSettingsContainer
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure EvalSettingsContainer
EvalContainerCode
Text
"none" -> EvalSettingsContainer -> Parser EvalSettingsContainer
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure EvalSettingsContainer
EvalContainerNone
Text
"inline" -> EvalSettingsContainer -> Parser EvalSettingsContainer
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure EvalSettingsContainer
EvalContainerInline
Text
"raw" -> EvalSettingsContainer -> Parser EvalSettingsContainer
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure EvalSettingsContainer
EvalContainerNone
Text
"rawInline" -> EvalSettingsContainer -> Parser EvalSettingsContainer
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure EvalSettingsContainer
EvalContainerInline
Text
_ -> FilePath -> Parser EvalSettingsContainer
forall a. FilePath -> Parser a
forall (m :: * -> *) a. MonadFail m => FilePath -> m a
fail (FilePath -> Parser EvalSettingsContainer)
-> FilePath -> Parser EvalSettingsContainer
forall a b. (a -> b) -> a -> b
$ FilePath
"unknown container: " FilePath -> ShowS
forall a. Semigroup a => a -> a -> a
<> Text -> FilePath
forall a. Show a => a -> FilePath
show Text
t
data EvalSettings = EvalSettings
{ EvalSettings -> Text
evalCommand :: !T.Text
, EvalSettings -> Bool
evalReplace :: !Bool
, EvalSettings -> Bool
evalFragment :: !Bool
, EvalSettings -> EvalSettingsContainer
evalContainer :: !EvalSettingsContainer
, EvalSettings -> Bool
evalStderr :: !Bool
} deriving (Int -> EvalSettings -> ShowS
[EvalSettings] -> ShowS
EvalSettings -> FilePath
(Int -> EvalSettings -> ShowS)
-> (EvalSettings -> FilePath)
-> ([EvalSettings] -> ShowS)
-> Show EvalSettings
forall a.
(Int -> a -> ShowS) -> (a -> FilePath) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> EvalSettings -> ShowS
showsPrec :: Int -> EvalSettings -> ShowS
$cshow :: EvalSettings -> FilePath
show :: EvalSettings -> FilePath
$cshowList :: [EvalSettings] -> ShowS
showList :: [EvalSettings] -> ShowS
Show)
instance A.FromJSON EvalSettings where
parseJSON :: Value -> Parser EvalSettings
parseJSON = FilePath
-> (Object -> Parser EvalSettings) -> Value -> Parser EvalSettings
forall a. FilePath -> (Object -> Parser a) -> Value -> Parser a
A.withObject FilePath
"FromJSON EvalSettings" ((Object -> Parser EvalSettings) -> Value -> Parser EvalSettings)
-> (Object -> Parser EvalSettings) -> Value -> Parser EvalSettings
forall a b. (a -> b) -> a -> b
$ \Object
o -> Text
-> Bool -> Bool -> EvalSettingsContainer -> Bool -> EvalSettings
EvalSettings
(Text
-> Bool -> Bool -> EvalSettingsContainer -> Bool -> EvalSettings)
-> Parser Text
-> Parser
(Bool -> Bool -> EvalSettingsContainer -> Bool -> EvalSettings)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Object
o Object -> Key -> Parser Text
forall a. FromJSON a => Object -> Key -> Parser a
A..: Key
"command"
Parser
(Bool -> Bool -> EvalSettingsContainer -> Bool -> EvalSettings)
-> Parser Bool
-> Parser (Bool -> EvalSettingsContainer -> Bool -> EvalSettings)
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
o Object -> Key -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"replace" Parser (Maybe Bool) -> Bool -> Parser Bool
forall a. Parser (Maybe a) -> a -> Parser a
A..!= Bool
False
Parser (Bool -> EvalSettingsContainer -> Bool -> EvalSettings)
-> Parser Bool
-> Parser (EvalSettingsContainer -> Bool -> EvalSettings)
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
o Object -> Key -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"fragment" Parser (Maybe Bool) -> Bool -> Parser Bool
forall a. Parser (Maybe a) -> a -> Parser a
A..!= Bool
True
Parser (EvalSettingsContainer -> Bool -> EvalSettings)
-> Parser EvalSettingsContainer -> Parser (Bool -> EvalSettings)
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Key
-> Key
-> EvalSettingsContainer
-> Object
-> Parser EvalSettingsContainer
forall {b}. FromJSON b => Key -> Key -> b -> Object -> Parser b
deprecated Key
"wrap" Key
"container" EvalSettingsContainer
EvalContainerCode Object
o
Parser (Bool -> EvalSettings) -> Parser Bool -> Parser EvalSettings
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
o Object -> Key -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"stderr" Parser (Maybe Bool) -> Bool -> Parser Bool
forall a. Parser (Maybe a) -> a -> Parser a
A..!= Bool
True
where
deprecated :: Key -> Key -> b -> Object -> Parser b
deprecated Key
old Key
new b
def Object
obj = do
Maybe b
mo <- Object
obj Object -> Key -> Parser (Maybe b)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
old
Maybe b
mn <- Object
obj Object -> Key -> Parser (Maybe b)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
new
case (Maybe b
mo, Maybe b
mn) of
(Just b
_, Just b
_) -> FilePath -> Parser b
forall a. FilePath -> Parser a
forall (m :: * -> *) a. MonadFail m => FilePath -> m a
fail (FilePath -> Parser b) -> FilePath -> Parser b
forall a b. (a -> b) -> a -> b
$
Key -> FilePath
forall a. Show a => a -> FilePath
show Key
old FilePath -> ShowS
forall a. [a] -> [a] -> [a]
++ FilePath
" (deprecated) and " FilePath -> ShowS
forall a. [a] -> [a] -> [a]
++ Key -> FilePath
forall a. Show a => a -> FilePath
show Key
new FilePath -> ShowS
forall a. [a] -> [a] -> [a]
++ FilePath
" " FilePath -> ShowS
forall a. [a] -> [a] -> [a]
++
FilePath
"are both specified, please remove " FilePath -> ShowS
forall a. [a] -> [a] -> [a]
++ Key -> FilePath
forall a. Show a => a -> FilePath
show Key
old
(Just b
o, Maybe b
Nothing) -> b -> Parser b
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure b
o
(Maybe b
Nothing, Just b
n) -> b -> Parser b
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure b
n
(Maybe b
Nothing, Maybe b
Nothing) -> b -> Parser b
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure b
def
data SpeakerNotesSettings = SpeakerNotesSettings
{ SpeakerNotesSettings -> FilePath
snsFile :: !FilePath
} deriving (Int -> SpeakerNotesSettings -> ShowS
[SpeakerNotesSettings] -> ShowS
SpeakerNotesSettings -> FilePath
(Int -> SpeakerNotesSettings -> ShowS)
-> (SpeakerNotesSettings -> FilePath)
-> ([SpeakerNotesSettings] -> ShowS)
-> Show SpeakerNotesSettings
forall a.
(Int -> a -> ShowS) -> (a -> FilePath) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> SpeakerNotesSettings -> ShowS
showsPrec :: Int -> SpeakerNotesSettings -> ShowS
$cshow :: SpeakerNotesSettings -> FilePath
show :: SpeakerNotesSettings -> FilePath
$cshowList :: [SpeakerNotesSettings] -> ShowS
showList :: [SpeakerNotesSettings] -> ShowS
Show)
data TransitionSettings = TransitionSettings
{ TransitionSettings -> Text
tsType :: !T.Text
, TransitionSettings -> Object
tsParams :: !A.Object
} deriving (Int -> TransitionSettings -> ShowS
[TransitionSettings] -> ShowS
TransitionSettings -> FilePath
(Int -> TransitionSettings -> ShowS)
-> (TransitionSettings -> FilePath)
-> ([TransitionSettings] -> ShowS)
-> Show TransitionSettings
forall a.
(Int -> a -> ShowS) -> (a -> FilePath) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> TransitionSettings -> ShowS
showsPrec :: Int -> TransitionSettings -> ShowS
$cshow :: TransitionSettings -> FilePath
show :: TransitionSettings -> FilePath
$cshowList :: [TransitionSettings] -> ShowS
showList :: [TransitionSettings] -> ShowS
Show)
instance A.FromJSON TransitionSettings where
parseJSON :: Value -> Parser TransitionSettings
parseJSON = FilePath
-> (Object -> Parser TransitionSettings)
-> Value
-> Parser TransitionSettings
forall a. FilePath -> (Object -> Parser a) -> Value -> Parser a
A.withObject FilePath
"FromJSON TransitionSettings" ((Object -> Parser TransitionSettings)
-> Value -> Parser TransitionSettings)
-> (Object -> Parser TransitionSettings)
-> Value
-> Parser TransitionSettings
forall a b. (a -> b) -> a -> b
$ \Object
o ->
Text -> Object -> TransitionSettings
TransitionSettings (Text -> Object -> TransitionSettings)
-> Parser Text -> Parser (Object -> TransitionSettings)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Object
o Object -> Key -> Parser Text
forall a. FromJSON a => Object -> Key -> Parser a
A..: Key
"type" Parser (Object -> TransitionSettings)
-> Parser Object -> Parser TransitionSettings
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object -> Parser Object
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure Object
o
$(A.deriveFromJSON A.dropPrefixOptions ''MarginSettings)
$(A.deriveFromJSON A.dropPrefixOptions ''SpeakerNotesSettings)
$(A.deriveFromJSON A.dropPrefixOptions ''PresentationSettings)