{-# LANGUAGE OverloadedStrings #-}
module Text.Pandoc.Readers.Org.ExportSettings
( exportSettings
) where
import Text.Pandoc.Class.PandocMonad (PandocMonad, report)
import Text.Pandoc.Logging (LogMessage (UnknownOrgExportOption))
import Text.Pandoc.Readers.Org.ParserState
import Text.Pandoc.Readers.Org.Parsing
import Control.Monad (mzero, void)
import Data.Char (toLower)
import Data.Maybe (listToMaybe)
import Data.Text (Text, unpack)
exportSettings :: PandocMonad m => OrgParser m ()
exportSettings :: forall (m :: * -> *). PandocMonad m => OrgParser m ()
exportSettings = ParsecT Sources OrgParserState (ReaderT OrgParserLocal m) [()]
-> ParsecT Sources OrgParserState (ReaderT OrgParserLocal m) ()
forall (f :: * -> *) a. Functor f => f a -> f ()
void (ParsecT Sources OrgParserState (ReaderT OrgParserLocal m) [()]
-> ParsecT Sources OrgParserState (ReaderT OrgParserLocal m) ())
-> ParsecT Sources OrgParserState (ReaderT OrgParserLocal m) [()]
-> ParsecT Sources OrgParserState (ReaderT OrgParserLocal m) ()
forall a b. (a -> b) -> a -> b
$ ParsecT Sources OrgParserState (ReaderT OrgParserLocal m) ()
-> ParsecT Sources OrgParserState (ReaderT OrgParserLocal m) ()
-> ParsecT Sources OrgParserState (ReaderT OrgParserLocal m) [()]
forall s (m :: * -> *) t u a sep.
Stream s m t =>
ParsecT s u m a -> ParsecT s u m sep -> ParsecT s u m [a]
sepBy ParsecT Sources OrgParserState (ReaderT OrgParserLocal m) ()
forall s (m :: * -> *) st.
(Stream s m Char, UpdateSourcePos s Char) =>
ParsecT s st m ()
skipSpaces ParsecT Sources OrgParserState (ReaderT OrgParserLocal m) ()
forall (m :: * -> *). PandocMonad m => OrgParser m ()
exportSetting
type ExportSettingSetter a = a -> ExportSettings -> ExportSettings
exportSetting :: PandocMonad m => OrgParser m ()
exportSetting :: forall (m :: * -> *). PandocMonad m => OrgParser m ()
exportSetting = [ParsecT Sources OrgParserState (ReaderT OrgParserLocal m) ()]
-> ParsecT Sources OrgParserState (ReaderT OrgParserLocal m) ()
forall s (m :: * -> *) t u a.
Stream s m t =>
[ParsecT s u m a] -> ParsecT s u m a
choice
[ Text
-> ExportSettingSetter Bool
-> ParsecT Sources OrgParserState (ReaderT OrgParserLocal m) ()
forall (m :: * -> *).
Monad m =>
Text -> ExportSettingSetter Bool -> OrgParser m ()
booleanSetting Text
"^" (\Bool
val ExportSettings
es -> ExportSettings
es { exportSubSuperscripts = val })
, Text
-> ExportSettingSetter Bool
-> ParsecT Sources OrgParserState (ReaderT OrgParserLocal m) ()
forall (m :: * -> *).
Monad m =>
Text -> ExportSettingSetter Bool -> OrgParser m ()
booleanSetting Text
"'" (\Bool
val ExportSettings
es -> ExportSettings
es { exportSmartQuotes = val })
, Text
-> ExportSettingSetter Bool
-> ParsecT Sources OrgParserState (ReaderT OrgParserLocal m) ()
forall (m :: * -> *).
Monad m =>
Text -> ExportSettingSetter Bool -> OrgParser m ()
booleanSetting Text
"*" (\Bool
val ExportSettings
es -> ExportSettings
es { exportEmphasizedText = val })
, Text
-> ExportSettingSetter Bool
-> ParsecT Sources OrgParserState (ReaderT OrgParserLocal m) ()
forall (m :: * -> *).
Monad m =>
Text -> ExportSettingSetter Bool -> OrgParser m ()
booleanSetting Text
"-" (\Bool
val ExportSettings
es -> ExportSettings
es { exportSpecialStrings = val })
, Text
-> ParsecT Sources OrgParserState (ReaderT OrgParserLocal m) ()
forall (m :: * -> *). Monad m => Text -> OrgParser m ()
ignoredSetting Text
":"
, Text
-> ParsecT Sources OrgParserState (ReaderT OrgParserLocal m) ()
forall (m :: * -> *). Monad m => Text -> OrgParser m ()
ignoredSetting Text
"<"
, Text
-> ExportSettingSetter Bool
-> ParsecT Sources OrgParserState (ReaderT OrgParserLocal m) ()
forall (m :: * -> *).
Monad m =>
Text -> ExportSettingSetter Bool -> OrgParser m ()
booleanSetting Text
"\\n" (\Bool
val ExportSettings
es -> ExportSettings
es { exportPreserveBreaks = val })
, Text
-> ExportSettingSetter ArchivedTreesOption
-> ParsecT Sources OrgParserState (ReaderT OrgParserLocal m) ()
forall (m :: * -> *).
Monad m =>
Text -> ExportSettingSetter ArchivedTreesOption -> OrgParser m ()
archivedTreeSetting Text
"arch" (\ArchivedTreesOption
val ExportSettings
es -> ExportSettings
es { exportArchivedTrees = val })
, Text
-> ExportSettingSetter Bool
-> ParsecT Sources OrgParserState (ReaderT OrgParserLocal m) ()
forall (m :: * -> *).
Monad m =>
Text -> ExportSettingSetter Bool -> OrgParser m ()
booleanSetting Text
"author" (\Bool
val ExportSettings
es -> ExportSettings
es { exportWithAuthor = val })
, Text
-> ParsecT Sources OrgParserState (ReaderT OrgParserLocal m) ()
forall (m :: * -> *). Monad m => Text -> OrgParser m ()
ignoredSetting Text
"c"
, Text
-> ExportSettingSetter Bool
-> ParsecT Sources OrgParserState (ReaderT OrgParserLocal m) ()
forall (m :: * -> *).
Monad m =>
Text -> ExportSettingSetter Bool -> OrgParser m ()
booleanSetting Text
"creator" (\Bool
val ExportSettings
es -> ExportSettings
es { exportWithCreator = val })
, Text
-> ExportSettingSetter (Either [Text] [Text])
-> ParsecT Sources OrgParserState (ReaderT OrgParserLocal m) ()
forall (m :: * -> *).
Monad m =>
Text
-> ExportSettingSetter (Either [Text] [Text]) -> OrgParser m ()
complementableListSetting Text
"d" (\Either [Text] [Text]
val ExportSettings
es -> ExportSettings
es { exportDrawers = val })
, Text
-> ParsecT Sources OrgParserState (ReaderT OrgParserLocal m) ()
forall (m :: * -> *). Monad m => Text -> OrgParser m ()
ignoredSetting Text
"date"
, Text
-> ExportSettingSetter Bool
-> ParsecT Sources OrgParserState (ReaderT OrgParserLocal m) ()
forall (m :: * -> *).
Monad m =>
Text -> ExportSettingSetter Bool -> OrgParser m ()
booleanSetting Text
"e" (\Bool
val ExportSettings
es -> ExportSettings
es { exportWithEntities = val })
, Text
-> ExportSettingSetter Bool
-> ParsecT Sources OrgParserState (ReaderT OrgParserLocal m) ()
forall (m :: * -> *).
Monad m =>
Text -> ExportSettingSetter Bool -> OrgParser m ()
booleanSetting Text
"email" (\Bool
val ExportSettings
es -> ExportSettings
es { exportWithEmail = val })
, Text
-> ExportSettingSetter Bool
-> ParsecT Sources OrgParserState (ReaderT OrgParserLocal m) ()
forall (m :: * -> *).
Monad m =>
Text -> ExportSettingSetter Bool -> OrgParser m ()
booleanSetting Text
"f" (\Bool
val ExportSettings
es -> ExportSettings
es { exportWithFootnotes = val })
, Text
-> ExportSettingSetter Int
-> ParsecT Sources OrgParserState (ReaderT OrgParserLocal m) ()
forall (m :: * -> *).
Monad m =>
Text -> ExportSettingSetter Int -> OrgParser m ()
integerSetting Text
"H" (\Int
val ExportSettings
es -> ExportSettings
es { exportHeadlineLevels = val })
, Text
-> ParsecT Sources OrgParserState (ReaderT OrgParserLocal m) ()
forall (m :: * -> *). Monad m => Text -> OrgParser m ()
ignoredSetting Text
"inline"
, Text
-> ParsecT Sources OrgParserState (ReaderT OrgParserLocal m) ()
forall (m :: * -> *). Monad m => Text -> OrgParser m ()
ignoredSetting Text
"num"
, Text
-> ExportSettingSetter Bool
-> ParsecT Sources OrgParserState (ReaderT OrgParserLocal m) ()
forall (m :: * -> *).
Monad m =>
Text -> ExportSettingSetter Bool -> OrgParser m ()
booleanSetting Text
"p" (\Bool
val ExportSettings
es -> ExportSettings
es { exportWithPlanning = val })
, Text
-> ParsecT Sources OrgParserState (ReaderT OrgParserLocal m) ()
forall (m :: * -> *). Monad m => Text -> OrgParser m ()
ignoredSetting Text
"pri"
, Text
-> ParsecT Sources OrgParserState (ReaderT OrgParserLocal m) ()
forall (m :: * -> *). Monad m => Text -> OrgParser m ()
ignoredSetting Text
"prop"
, Text
-> ParsecT Sources OrgParserState (ReaderT OrgParserLocal m) ()
forall (m :: * -> *). Monad m => Text -> OrgParser m ()
ignoredSetting Text
"stat"
, Text
-> ExportSettingSetter Bool
-> ParsecT Sources OrgParserState (ReaderT OrgParserLocal m) ()
forall (m :: * -> *).
Monad m =>
Text -> ExportSettingSetter Bool -> OrgParser m ()
booleanSetting Text
"tags" (\Bool
val ExportSettings
es -> ExportSettings
es { exportWithTags = val })
, Text
-> ParsecT Sources OrgParserState (ReaderT OrgParserLocal m) ()
forall (m :: * -> *). Monad m => Text -> OrgParser m ()
ignoredSetting Text
"tasks"
, Text
-> ExportSettingSetter TeXExport
-> ParsecT Sources OrgParserState (ReaderT OrgParserLocal m) ()
forall (m :: * -> *).
Monad m =>
Text -> ExportSettingSetter TeXExport -> OrgParser m ()
texSetting Text
"tex" (\TeXExport
val ExportSettings
es -> ExportSettings
es { exportWithLatex = val })
, Text
-> ParsecT Sources OrgParserState (ReaderT OrgParserLocal m) ()
forall (m :: * -> *). Monad m => Text -> OrgParser m ()
ignoredSetting Text
"timestamp"
, Text
-> ParsecT Sources OrgParserState (ReaderT OrgParserLocal m) ()
forall (m :: * -> *). Monad m => Text -> OrgParser m ()
ignoredSetting Text
"title"
, Text
-> ParsecT Sources OrgParserState (ReaderT OrgParserLocal m) ()
forall (m :: * -> *). Monad m => Text -> OrgParser m ()
ignoredSetting Text
"toc"
, Text
-> ExportSettingSetter Bool
-> ParsecT Sources OrgParserState (ReaderT OrgParserLocal m) ()
forall (m :: * -> *).
Monad m =>
Text -> ExportSettingSetter Bool -> OrgParser m ()
booleanSetting Text
"todo" (\Bool
val ExportSettings
es -> ExportSettings
es { exportWithTodoKeywords = val })
, Text
-> ExportSettingSetter Bool
-> ParsecT Sources OrgParserState (ReaderT OrgParserLocal m) ()
forall (m :: * -> *).
Monad m =>
Text -> ExportSettingSetter Bool -> OrgParser m ()
booleanSetting Text
"|" (\Bool
val ExportSettings
es -> ExportSettings
es { exportWithTables = val })
, ParsecT Sources OrgParserState (ReaderT OrgParserLocal m) ()
forall (m :: * -> *). PandocMonad m => OrgParser m ()
ignoreAndWarn
] ParsecT Sources OrgParserState (ReaderT OrgParserLocal m) ()
-> String
-> ParsecT Sources OrgParserState (ReaderT OrgParserLocal m) ()
forall s u (m :: * -> *) a.
ParsecT s u m a -> String -> ParsecT s u m a
<?> String
"export setting"
genericExportSetting :: Monad m
=> OrgParser m a
-> Text
-> ExportSettingSetter a
-> OrgParser m ()
genericExportSetting :: forall (m :: * -> *) a.
Monad m =>
OrgParser m a -> Text -> ExportSettingSetter a -> OrgParser m ()
genericExportSetting OrgParser m a
optionParser Text
settingIdentifier ExportSettingSetter a
setter = ParsecT Sources OrgParserState (ReaderT OrgParserLocal m) ()
-> ParsecT Sources OrgParserState (ReaderT OrgParserLocal m) ()
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try (ParsecT Sources OrgParserState (ReaderT OrgParserLocal m) ()
-> ParsecT Sources OrgParserState (ReaderT OrgParserLocal m) ())
-> ParsecT Sources OrgParserState (ReaderT OrgParserLocal m) ()
-> ParsecT Sources OrgParserState (ReaderT OrgParserLocal m) ()
forall a b. (a -> b) -> a -> b
$ do
Char
_ <- Text
-> ParsecT Sources OrgParserState (ReaderT OrgParserLocal m) Text
forall s (m :: * -> *) u.
(Stream s m Char, UpdateSourcePos s Char) =>
Text -> ParsecT s u m Text
textStr Text
settingIdentifier ParsecT Sources OrgParserState (ReaderT OrgParserLocal m) Text
-> ParsecT Sources OrgParserState (ReaderT OrgParserLocal m) Char
-> ParsecT Sources OrgParserState (ReaderT OrgParserLocal m) Char
forall a b.
ParsecT Sources OrgParserState (ReaderT OrgParserLocal m) a
-> ParsecT Sources OrgParserState (ReaderT OrgParserLocal m) b
-> ParsecT Sources OrgParserState (ReaderT OrgParserLocal m) b
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> Char
-> ParsecT Sources OrgParserState (ReaderT OrgParserLocal m) Char
forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
Char -> ParsecT s u m Char
char Char
':'
a
value <- OrgParser m a
optionParser
(OrgParserState -> OrgParserState)
-> ParsecT Sources OrgParserState (ReaderT OrgParserLocal m) ()
forall (m :: * -> *) u s. Monad m => (u -> u) -> ParsecT s u m ()
updateState ((OrgParserState -> OrgParserState)
-> ParsecT Sources OrgParserState (ReaderT OrgParserLocal m) ())
-> (OrgParserState -> OrgParserState)
-> ParsecT Sources OrgParserState (ReaderT OrgParserLocal m) ()
forall a b. (a -> b) -> a -> b
$ a -> OrgParserState -> OrgParserState
modifyExportSettings a
value
where
modifyExportSettings :: a -> OrgParserState -> OrgParserState
modifyExportSettings a
val OrgParserState
st =
OrgParserState
st { orgStateExportSettings = setter val . orgStateExportSettings $ st }
booleanSetting :: Monad m => Text -> ExportSettingSetter Bool -> OrgParser m ()
booleanSetting :: forall (m :: * -> *).
Monad m =>
Text -> ExportSettingSetter Bool -> OrgParser m ()
booleanSetting = OrgParser m Bool
-> Text -> ExportSettingSetter Bool -> OrgParser m ()
forall (m :: * -> *) a.
Monad m =>
OrgParser m a -> Text -> ExportSettingSetter a -> OrgParser m ()
genericExportSetting OrgParser m Bool
forall (m :: * -> *). Monad m => OrgParser m Bool
elispBoolean
integerSetting :: Monad m => Text -> ExportSettingSetter Int -> OrgParser m ()
integerSetting :: forall (m :: * -> *).
Monad m =>
Text -> ExportSettingSetter Int -> OrgParser m ()
integerSetting = OrgParser m Int
-> Text -> ExportSettingSetter Int -> OrgParser m ()
forall (m :: * -> *) a.
Monad m =>
OrgParser m a -> Text -> ExportSettingSetter a -> OrgParser m ()
genericExportSetting OrgParser m Int
forall {u}. ParsecT Sources u (ReaderT OrgParserLocal m) Int
parseInt
where
parseInt :: ParsecT Sources u (ReaderT OrgParserLocal m) Int
parseInt = ParsecT Sources u (ReaderT OrgParserLocal m) Int
-> ParsecT Sources u (ReaderT OrgParserLocal m) Int
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try (ParsecT Sources u (ReaderT OrgParserLocal m) Int
-> ParsecT Sources u (ReaderT OrgParserLocal m) Int)
-> ParsecT Sources u (ReaderT OrgParserLocal m) Int
-> ParsecT Sources u (ReaderT OrgParserLocal m) Int
forall a b. (a -> b) -> a -> b
$
ParsecT Sources u (ReaderT OrgParserLocal m) Char
-> ParsecT Sources u (ReaderT OrgParserLocal m) String
forall s (m :: * -> *) t u a.
Stream s m t =>
ParsecT s u m a -> ParsecT s u m [a]
many1 ParsecT Sources u (ReaderT OrgParserLocal m) Char
forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
ParsecT s u m Char
digit ParsecT Sources u (ReaderT OrgParserLocal m) String
-> (String -> ParsecT Sources u (ReaderT OrgParserLocal m) Int)
-> ParsecT Sources u (ReaderT OrgParserLocal m) Int
forall a b.
ParsecT Sources u (ReaderT OrgParserLocal m) a
-> (a -> ParsecT Sources u (ReaderT OrgParserLocal m) b)
-> ParsecT Sources u (ReaderT OrgParserLocal m) b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= ParsecT Sources u (ReaderT OrgParserLocal m) Int
-> ((Int, String)
-> ParsecT Sources u (ReaderT OrgParserLocal m) Int)
-> Maybe (Int, String)
-> ParsecT Sources u (ReaderT OrgParserLocal m) Int
forall b a. b -> (a -> b) -> Maybe a -> b
maybe ParsecT Sources u (ReaderT OrgParserLocal m) Int
forall a. ParsecT Sources u (ReaderT OrgParserLocal m) a
forall (m :: * -> *) a. MonadPlus m => m a
mzero (Int -> ParsecT Sources u (ReaderT OrgParserLocal m) Int
forall a. a -> ParsecT Sources u (ReaderT OrgParserLocal m) a
forall (m :: * -> *) a. Monad m => a -> m a
return (Int -> ParsecT Sources u (ReaderT OrgParserLocal m) Int)
-> ((Int, String) -> Int)
-> (Int, String)
-> ParsecT Sources u (ReaderT OrgParserLocal m) Int
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Int, String) -> Int
forall a b. (a, b) -> a
fst) (Maybe (Int, String)
-> ParsecT Sources u (ReaderT OrgParserLocal m) Int)
-> (String -> Maybe (Int, String))
-> String
-> ParsecT Sources u (ReaderT OrgParserLocal m) Int
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [(Int, String)] -> Maybe (Int, String)
forall a. [a] -> Maybe a
listToMaybe ([(Int, String)] -> Maybe (Int, String))
-> (String -> [(Int, String)]) -> String -> Maybe (Int, String)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> [(Int, String)]
forall a. Read a => ReadS a
reads
archivedTreeSetting :: Monad m
=> Text
-> ExportSettingSetter ArchivedTreesOption
-> OrgParser m ()
archivedTreeSetting :: forall (m :: * -> *).
Monad m =>
Text -> ExportSettingSetter ArchivedTreesOption -> OrgParser m ()
archivedTreeSetting =
OrgParser m ArchivedTreesOption
-> Text
-> ExportSettingSetter ArchivedTreesOption
-> OrgParser m ()
forall (m :: * -> *) a.
Monad m =>
OrgParser m a -> Text -> ExportSettingSetter a -> OrgParser m ()
genericExportSetting (OrgParser m ArchivedTreesOption
-> Text
-> ExportSettingSetter ArchivedTreesOption
-> OrgParser m ())
-> OrgParser m ArchivedTreesOption
-> Text
-> ExportSettingSetter ArchivedTreesOption
-> OrgParser m ()
forall a b. (a -> b) -> a -> b
$ OrgParser m ArchivedTreesOption
archivedTreesHeadlineSetting OrgParser m ArchivedTreesOption
-> OrgParser m ArchivedTreesOption
-> OrgParser m ArchivedTreesOption
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> OrgParser m ArchivedTreesOption
archivedTreesBoolean
where
archivedTreesHeadlineSetting :: OrgParser m ArchivedTreesOption
archivedTreesHeadlineSetting =
ArchivedTreesOption
ArchivedTreesHeadlineOnly ArchivedTreesOption
-> ParsecT Sources OrgParserState (ReaderT OrgParserLocal m) Text
-> OrgParser m ArchivedTreesOption
forall a b.
a
-> ParsecT Sources OrgParserState (ReaderT OrgParserLocal m) b
-> ParsecT Sources OrgParserState (ReaderT OrgParserLocal m) a
forall (f :: * -> *) a b. Functor f => a -> f b -> f a
<$ Text
-> ParsecT Sources OrgParserState (ReaderT OrgParserLocal m) Text
forall (m :: * -> *). Monad m => Text -> OrgParser m Text
optionString Text
"headline"
archivedTreesBoolean :: OrgParser m ArchivedTreesOption
archivedTreesBoolean = OrgParser m ArchivedTreesOption -> OrgParser m ArchivedTreesOption
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try (OrgParser m ArchivedTreesOption
-> OrgParser m ArchivedTreesOption)
-> OrgParser m ArchivedTreesOption
-> OrgParser m ArchivedTreesOption
forall a b. (a -> b) -> a -> b
$ do
Bool
exportBool <- OrgParser m Bool
forall (m :: * -> *). Monad m => OrgParser m Bool
elispBoolean
ArchivedTreesOption -> OrgParser m ArchivedTreesOption
forall a.
a -> ParsecT Sources OrgParserState (ReaderT OrgParserLocal m) a
forall (m :: * -> *) a. Monad m => a -> m a
return (ArchivedTreesOption -> OrgParser m ArchivedTreesOption)
-> ArchivedTreesOption -> OrgParser m ArchivedTreesOption
forall a b. (a -> b) -> a -> b
$
if Bool
exportBool
then ArchivedTreesOption
ArchivedTreesExport
else ArchivedTreesOption
ArchivedTreesNoExport
complementableListSetting :: Monad m
=> Text
-> ExportSettingSetter (Either [Text] [Text])
-> OrgParser m ()
complementableListSetting :: forall (m :: * -> *).
Monad m =>
Text
-> ExportSettingSetter (Either [Text] [Text]) -> OrgParser m ()
complementableListSetting = OrgParser m (Either [Text] [Text])
-> Text
-> ExportSettingSetter (Either [Text] [Text])
-> OrgParser m ()
forall (m :: * -> *) a.
Monad m =>
OrgParser m a -> Text -> ExportSettingSetter a -> OrgParser m ()
genericExportSetting (OrgParser m (Either [Text] [Text])
-> Text
-> ExportSettingSetter (Either [Text] [Text])
-> OrgParser m ())
-> OrgParser m (Either [Text] [Text])
-> Text
-> ExportSettingSetter (Either [Text] [Text])
-> OrgParser m ()
forall a b. (a -> b) -> a -> b
$ [OrgParser m (Either [Text] [Text])]
-> OrgParser m (Either [Text] [Text])
forall s (m :: * -> *) t u a.
Stream s m t =>
[ParsecT s u m a] -> ParsecT s u m a
choice
[ [Text] -> Either [Text] [Text]
forall a b. a -> Either a b
Left ([Text] -> Either [Text] [Text])
-> ParsecT Sources OrgParserState (ReaderT OrgParserLocal m) [Text]
-> OrgParser m (Either [Text] [Text])
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ParsecT Sources OrgParserState (ReaderT OrgParserLocal m) [Text]
forall (m :: * -> *). Monad m => OrgParser m [Text]
complementTextList
, [Text] -> Either [Text] [Text]
forall a b. b -> Either a b
Right ([Text] -> Either [Text] [Text])
-> ParsecT Sources OrgParserState (ReaderT OrgParserLocal m) [Text]
-> OrgParser m (Either [Text] [Text])
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ParsecT Sources OrgParserState (ReaderT OrgParserLocal m) [Text]
forall (m :: * -> *). Monad m => OrgParser m [Text]
stringList
, (\Bool
b -> if Bool
b then [Text] -> Either [Text] [Text]
forall a b. a -> Either a b
Left [] else [Text] -> Either [Text] [Text]
forall a b. b -> Either a b
Right []) (Bool -> Either [Text] [Text])
-> ParsecT Sources OrgParserState (ReaderT OrgParserLocal m) Bool
-> OrgParser m (Either [Text] [Text])
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ParsecT Sources OrgParserState (ReaderT OrgParserLocal m) Bool
forall (m :: * -> *). Monad m => OrgParser m Bool
elispBoolean
]
where
stringList :: Monad m => OrgParser m [Text]
stringList :: forall (m :: * -> *). Monad m => OrgParser m [Text]
stringList = ParsecT Sources OrgParserState (ReaderT OrgParserLocal m) [Text]
-> ParsecT Sources OrgParserState (ReaderT OrgParserLocal m) [Text]
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try (ParsecT Sources OrgParserState (ReaderT OrgParserLocal m) [Text]
-> ParsecT
Sources OrgParserState (ReaderT OrgParserLocal m) [Text])
-> ParsecT Sources OrgParserState (ReaderT OrgParserLocal m) [Text]
-> ParsecT Sources OrgParserState (ReaderT OrgParserLocal m) [Text]
forall a b. (a -> b) -> a -> b
$
Char
-> ParsecT Sources OrgParserState (ReaderT OrgParserLocal m) Char
forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
Char -> ParsecT s u m Char
char Char
'('
ParsecT Sources OrgParserState (ReaderT OrgParserLocal m) Char
-> ParsecT Sources OrgParserState (ReaderT OrgParserLocal m) [Text]
-> ParsecT Sources OrgParserState (ReaderT OrgParserLocal m) [Text]
forall a b.
ParsecT Sources OrgParserState (ReaderT OrgParserLocal m) a
-> ParsecT Sources OrgParserState (ReaderT OrgParserLocal m) b
-> ParsecT Sources OrgParserState (ReaderT OrgParserLocal m) b
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> ParsecT Sources OrgParserState (ReaderT OrgParserLocal m) Text
-> ParsecT Sources OrgParserState (ReaderT OrgParserLocal m) ()
-> ParsecT Sources OrgParserState (ReaderT OrgParserLocal m) [Text]
forall s (m :: * -> *) t u a sep.
Stream s m t =>
ParsecT s u m a -> ParsecT s u m sep -> ParsecT s u m [a]
sepBy ParsecT Sources OrgParserState (ReaderT OrgParserLocal m) Text
forall (m :: * -> *). Monad m => OrgParser m Text
elispText ParsecT Sources OrgParserState (ReaderT OrgParserLocal m) ()
forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
ParsecT s u m ()
spaces
ParsecT Sources OrgParserState (ReaderT OrgParserLocal m) [Text]
-> ParsecT Sources OrgParserState (ReaderT OrgParserLocal m) Char
-> ParsecT Sources OrgParserState (ReaderT OrgParserLocal m) [Text]
forall a b.
ParsecT Sources OrgParserState (ReaderT OrgParserLocal m) a
-> ParsecT Sources OrgParserState (ReaderT OrgParserLocal m) b
-> ParsecT Sources OrgParserState (ReaderT OrgParserLocal m) a
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
<* Char
-> ParsecT Sources OrgParserState (ReaderT OrgParserLocal m) Char
forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
Char -> ParsecT s u m Char
char Char
')'
complementTextList :: Monad m => OrgParser m [Text]
complementTextList :: forall (m :: * -> *). Monad m => OrgParser m [Text]
complementTextList = ParsecT Sources OrgParserState (ReaderT OrgParserLocal m) [Text]
-> ParsecT Sources OrgParserState (ReaderT OrgParserLocal m) [Text]
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try (ParsecT Sources OrgParserState (ReaderT OrgParserLocal m) [Text]
-> ParsecT
Sources OrgParserState (ReaderT OrgParserLocal m) [Text])
-> ParsecT Sources OrgParserState (ReaderT OrgParserLocal m) [Text]
-> ParsecT Sources OrgParserState (ReaderT OrgParserLocal m) [Text]
forall a b. (a -> b) -> a -> b
$
String
-> ParsecT Sources OrgParserState (ReaderT OrgParserLocal m) String
forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
String -> ParsecT s u m String
string String
"(not "
ParsecT Sources OrgParserState (ReaderT OrgParserLocal m) String
-> ParsecT Sources OrgParserState (ReaderT OrgParserLocal m) [Text]
-> ParsecT Sources OrgParserState (ReaderT OrgParserLocal m) [Text]
forall a b.
ParsecT Sources OrgParserState (ReaderT OrgParserLocal m) a
-> ParsecT Sources OrgParserState (ReaderT OrgParserLocal m) b
-> ParsecT Sources OrgParserState (ReaderT OrgParserLocal m) b
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> ParsecT Sources OrgParserState (ReaderT OrgParserLocal m) Text
-> ParsecT Sources OrgParserState (ReaderT OrgParserLocal m) ()
-> ParsecT Sources OrgParserState (ReaderT OrgParserLocal m) [Text]
forall s (m :: * -> *) t u a sep.
Stream s m t =>
ParsecT s u m a -> ParsecT s u m sep -> ParsecT s u m [a]
sepBy ParsecT Sources OrgParserState (ReaderT OrgParserLocal m) Text
forall (m :: * -> *). Monad m => OrgParser m Text
elispText ParsecT Sources OrgParserState (ReaderT OrgParserLocal m) ()
forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
ParsecT s u m ()
spaces
ParsecT Sources OrgParserState (ReaderT OrgParserLocal m) [Text]
-> ParsecT Sources OrgParserState (ReaderT OrgParserLocal m) Char
-> ParsecT Sources OrgParserState (ReaderT OrgParserLocal m) [Text]
forall a b.
ParsecT Sources OrgParserState (ReaderT OrgParserLocal m) a
-> ParsecT Sources OrgParserState (ReaderT OrgParserLocal m) b
-> ParsecT Sources OrgParserState (ReaderT OrgParserLocal m) a
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
<* Char
-> ParsecT Sources OrgParserState (ReaderT OrgParserLocal m) Char
forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
Char -> ParsecT s u m Char
char Char
')'
elispText :: Monad m => OrgParser m Text
elispText :: forall (m :: * -> *). Monad m => OrgParser m Text
elispText = ParsecT Sources OrgParserState (ReaderT OrgParserLocal m) Text
-> ParsecT Sources OrgParserState (ReaderT OrgParserLocal m) Text
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try (ParsecT Sources OrgParserState (ReaderT OrgParserLocal m) Text
-> ParsecT Sources OrgParserState (ReaderT OrgParserLocal m) Text)
-> ParsecT Sources OrgParserState (ReaderT OrgParserLocal m) Text
-> ParsecT Sources OrgParserState (ReaderT OrgParserLocal m) Text
forall a b. (a -> b) -> a -> b
$
Char
-> ParsecT Sources OrgParserState (ReaderT OrgParserLocal m) Char
forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
Char -> ParsecT s u m Char
char Char
'"'
ParsecT Sources OrgParserState (ReaderT OrgParserLocal m) Char
-> ParsecT Sources OrgParserState (ReaderT OrgParserLocal m) Text
-> ParsecT Sources OrgParserState (ReaderT OrgParserLocal m) Text
forall a b.
ParsecT Sources OrgParserState (ReaderT OrgParserLocal m) a
-> ParsecT Sources OrgParserState (ReaderT OrgParserLocal m) b
-> ParsecT Sources OrgParserState (ReaderT OrgParserLocal m) b
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> ParsecT Sources OrgParserState (ReaderT OrgParserLocal m) Char
-> ParsecT Sources OrgParserState (ReaderT OrgParserLocal m) Char
-> ParsecT Sources OrgParserState (ReaderT OrgParserLocal m) Text
forall s (m :: * -> *) t st a.
Stream s m t =>
ParsecT s st m Char -> ParsecT s st m a -> ParsecT s st m Text
manyTillChar ParsecT Sources OrgParserState (ReaderT OrgParserLocal m) Char
forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
ParsecT s u m Char
alphaNum (Char
-> ParsecT Sources OrgParserState (ReaderT OrgParserLocal m) Char
forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
Char -> ParsecT s u m Char
char Char
'"')
texSetting :: Monad m
=> Text
-> ExportSettingSetter TeXExport
-> OrgParser m ()
texSetting :: forall (m :: * -> *).
Monad m =>
Text -> ExportSettingSetter TeXExport -> OrgParser m ()
texSetting = OrgParser m TeXExport
-> Text -> ExportSettingSetter TeXExport -> OrgParser m ()
forall (m :: * -> *) a.
Monad m =>
OrgParser m a -> Text -> ExportSettingSetter a -> OrgParser m ()
genericExportSetting (OrgParser m TeXExport
-> Text -> ExportSettingSetter TeXExport -> OrgParser m ())
-> OrgParser m TeXExport
-> Text
-> ExportSettingSetter TeXExport
-> OrgParser m ()
forall a b. (a -> b) -> a -> b
$ OrgParser m TeXExport
texVerbatim OrgParser m TeXExport
-> OrgParser m TeXExport -> OrgParser m TeXExport
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> OrgParser m TeXExport
texBoolean
where
texVerbatim :: OrgParser m TeXExport
texVerbatim = TeXExport
TeXVerbatim TeXExport
-> ParsecT Sources OrgParserState (ReaderT OrgParserLocal m) Text
-> OrgParser m TeXExport
forall a b.
a
-> ParsecT Sources OrgParserState (ReaderT OrgParserLocal m) b
-> ParsecT Sources OrgParserState (ReaderT OrgParserLocal m) a
forall (f :: * -> *) a b. Functor f => a -> f b -> f a
<$ Text
-> ParsecT Sources OrgParserState (ReaderT OrgParserLocal m) Text
forall (m :: * -> *). Monad m => Text -> OrgParser m Text
optionString Text
"verbatim"
texBoolean :: OrgParser m TeXExport
texBoolean = OrgParser m TeXExport -> OrgParser m TeXExport
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try (OrgParser m TeXExport -> OrgParser m TeXExport)
-> OrgParser m TeXExport -> OrgParser m TeXExport
forall a b. (a -> b) -> a -> b
$ do
Bool
exportBool <- OrgParser m Bool
forall (m :: * -> *). Monad m => OrgParser m Bool
elispBoolean
TeXExport -> OrgParser m TeXExport
forall a.
a -> ParsecT Sources OrgParserState (ReaderT OrgParserLocal m) a
forall (m :: * -> *) a. Monad m => a -> m a
return (TeXExport -> OrgParser m TeXExport)
-> TeXExport -> OrgParser m TeXExport
forall a b. (a -> b) -> a -> b
$
if Bool
exportBool
then TeXExport
TeXExport
else TeXExport
TeXIgnore
ignoredSetting :: Monad m => Text -> OrgParser m ()
ignoredSetting :: forall (m :: * -> *). Monad m => Text -> OrgParser m ()
ignoredSetting Text
s = ParsecT Sources OrgParserState (ReaderT OrgParserLocal m) ()
-> ParsecT Sources OrgParserState (ReaderT OrgParserLocal m) ()
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try (() ()
-> ParsecT Sources OrgParserState (ReaderT OrgParserLocal m) Text
-> ParsecT Sources OrgParserState (ReaderT OrgParserLocal m) ()
forall a b.
a
-> ParsecT Sources OrgParserState (ReaderT OrgParserLocal m) b
-> ParsecT Sources OrgParserState (ReaderT OrgParserLocal m) a
forall (f :: * -> *) a b. Functor f => a -> f b -> f a
<$ Text
-> ParsecT Sources OrgParserState (ReaderT OrgParserLocal m) Text
forall s (m :: * -> *) u.
(Stream s m Char, UpdateSourcePos s Char) =>
Text -> ParsecT s u m Text
textStr Text
s ParsecT Sources OrgParserState (ReaderT OrgParserLocal m) ()
-> ParsecT Sources OrgParserState (ReaderT OrgParserLocal m) Char
-> ParsecT Sources OrgParserState (ReaderT OrgParserLocal m) ()
forall a b.
ParsecT Sources OrgParserState (ReaderT OrgParserLocal m) a
-> ParsecT Sources OrgParserState (ReaderT OrgParserLocal m) b
-> ParsecT Sources OrgParserState (ReaderT OrgParserLocal m) a
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
<* Char
-> ParsecT Sources OrgParserState (ReaderT OrgParserLocal m) Char
forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
Char -> ParsecT s u m Char
char Char
':' ParsecT Sources OrgParserState (ReaderT OrgParserLocal m) ()
-> ParsecT Sources OrgParserState (ReaderT OrgParserLocal m) String
-> ParsecT Sources OrgParserState (ReaderT OrgParserLocal m) ()
forall a b.
ParsecT Sources OrgParserState (ReaderT OrgParserLocal m) a
-> ParsecT Sources OrgParserState (ReaderT OrgParserLocal m) b
-> ParsecT Sources OrgParserState (ReaderT OrgParserLocal m) a
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
<* ParsecT Sources OrgParserState (ReaderT OrgParserLocal m) Char
-> ParsecT Sources OrgParserState (ReaderT OrgParserLocal m) String
forall s (m :: * -> *) t u a.
Stream s m t =>
ParsecT s u m a -> ParsecT s u m [a]
many1 ParsecT Sources OrgParserState (ReaderT OrgParserLocal m) Char
forall s (m :: * -> *) st.
(Stream s m Char, UpdateSourcePos s Char) =>
ParsecT s st m Char
nonspaceChar)
ignoreAndWarn :: PandocMonad m => OrgParser m ()
ignoreAndWarn :: forall (m :: * -> *). PandocMonad m => OrgParser m ()
ignoreAndWarn = ParsecT Sources OrgParserState (ReaderT OrgParserLocal m) ()
-> ParsecT Sources OrgParserState (ReaderT OrgParserLocal m) ()
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try (ParsecT Sources OrgParserState (ReaderT OrgParserLocal m) ()
-> ParsecT Sources OrgParserState (ReaderT OrgParserLocal m) ())
-> ParsecT Sources OrgParserState (ReaderT OrgParserLocal m) ()
-> ParsecT Sources OrgParserState (ReaderT OrgParserLocal m) ()
forall a b. (a -> b) -> a -> b
$ do
Text
opt <- ParsecT Sources OrgParserState (ReaderT OrgParserLocal m) Char
-> ParsecT Sources OrgParserState (ReaderT OrgParserLocal m) Text
forall s (m :: * -> *) t st.
Stream s m t =>
ParsecT s st m Char -> ParsecT s st m Text
many1Char ParsecT Sources OrgParserState (ReaderT OrgParserLocal m) Char
forall s (m :: * -> *) st.
(Stream s m Char, UpdateSourcePos s Char) =>
ParsecT s st m Char
nonspaceChar
LogMessage
-> ParsecT Sources OrgParserState (ReaderT OrgParserLocal m) ()
forall (m :: * -> *). PandocMonad m => LogMessage -> m ()
report (Text -> LogMessage
UnknownOrgExportOption Text
opt)
() -> ParsecT Sources OrgParserState (ReaderT OrgParserLocal m) ()
forall a.
a -> ParsecT Sources OrgParserState (ReaderT OrgParserLocal m) a
forall (m :: * -> *) a. Monad m => a -> m a
return ()
elispBoolean :: Monad m => OrgParser m Bool
elispBoolean :: forall (m :: * -> *). Monad m => OrgParser m Bool
elispBoolean = ParsecT Sources OrgParserState (ReaderT OrgParserLocal m) Bool
-> ParsecT Sources OrgParserState (ReaderT OrgParserLocal m) Bool
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try (ParsecT Sources OrgParserState (ReaderT OrgParserLocal m) Bool
-> ParsecT Sources OrgParserState (ReaderT OrgParserLocal m) Bool)
-> ParsecT Sources OrgParserState (ReaderT OrgParserLocal m) Bool
-> ParsecT Sources OrgParserState (ReaderT OrgParserLocal m) Bool
forall a b. (a -> b) -> a -> b
$ do
String
value <- ParsecT Sources OrgParserState (ReaderT OrgParserLocal m) Char
-> ParsecT Sources OrgParserState (ReaderT OrgParserLocal m) String
forall s (m :: * -> *) t u a.
Stream s m t =>
ParsecT s u m a -> ParsecT s u m [a]
many1 ParsecT Sources OrgParserState (ReaderT OrgParserLocal m) Char
forall s (m :: * -> *) st.
(Stream s m Char, UpdateSourcePos s Char) =>
ParsecT s st m Char
nonspaceChar
Bool
-> ParsecT Sources OrgParserState (ReaderT OrgParserLocal m) Bool
forall a.
a -> ParsecT Sources OrgParserState (ReaderT OrgParserLocal m) a
forall (m :: * -> *) a. Monad m => a -> m a
return (Bool
-> ParsecT Sources OrgParserState (ReaderT OrgParserLocal m) Bool)
-> Bool
-> ParsecT Sources OrgParserState (ReaderT OrgParserLocal m) Bool
forall a b. (a -> b) -> a -> b
$ case (Char -> Char) -> String -> String
forall a b. (a -> b) -> [a] -> [b]
map Char -> Char
toLower String
value of
String
"nil" -> Bool
False
String
"{}" -> Bool
False
String
"()" -> Bool
False
String
_ -> Bool
True
optionString :: Monad m => Text -> OrgParser m Text
optionString :: forall (m :: * -> *). Monad m => Text -> OrgParser m Text
optionString Text
s = ParsecT Sources OrgParserState (ReaderT OrgParserLocal m) Text
-> ParsecT Sources OrgParserState (ReaderT OrgParserLocal m) Text
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try (ParsecT Sources OrgParserState (ReaderT OrgParserLocal m) Text
-> ParsecT Sources OrgParserState (ReaderT OrgParserLocal m) Text)
-> ParsecT Sources OrgParserState (ReaderT OrgParserLocal m) Text
-> ParsecT Sources OrgParserState (ReaderT OrgParserLocal m) Text
forall a b. (a -> b) -> a -> b
$ do
String
_ <- String
-> ParsecT Sources OrgParserState (ReaderT OrgParserLocal m) String
forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
String -> ParsecT s u m String
string (Text -> String
unpack Text
s)
ParsecT Sources OrgParserState (ReaderT OrgParserLocal m) Char
-> ParsecT Sources OrgParserState (ReaderT OrgParserLocal m) Char
forall s (m :: * -> *) t u a.
Stream s m t =>
ParsecT s u m a -> ParsecT s u m a
lookAhead (ParsecT Sources OrgParserState (ReaderT OrgParserLocal m) Char
forall (m :: * -> *). Monad m => OrgParser m Char
newline ParsecT Sources OrgParserState (ReaderT OrgParserLocal m) Char
-> ParsecT Sources OrgParserState (ReaderT OrgParserLocal m) Char
-> ParsecT Sources OrgParserState (ReaderT OrgParserLocal m) Char
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> ParsecT Sources OrgParserState (ReaderT OrgParserLocal m) Char
forall s (m :: * -> *) st.
(Stream s m Char, UpdateSourcePos s Char) =>
ParsecT s st m Char
spaceChar)
Text
-> ParsecT Sources OrgParserState (ReaderT OrgParserLocal m) Text
forall a.
a -> ParsecT Sources OrgParserState (ReaderT OrgParserLocal m) a
forall (m :: * -> *) a. Monad m => a -> m a
return Text
s