{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE PatternGuards #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE ViewPatterns #-}
module Text.Pandoc.Readers.LaTeX ( readLaTeX,
applyMacros,
rawLaTeXInline,
rawLaTeXBlock,
inlineCommand
) where
import Control.Applicative (many, optional, (<|>))
import Control.Monad
import Control.Monad.Except (throwError)
import Data.Containers.ListUtils (nubOrd)
import Data.Char (isDigit, isLetter, isAlphaNum, toUpper, chr)
import Data.Default
import Data.List (intercalate)
import qualified Data.Map as M
import Data.Maybe (fromMaybe, maybeToList)
import qualified Data.Set as Set
import Data.Text (Text)
import qualified Data.Text as T
import Data.Either (partitionEithers)
import Skylighting (defaultSyntaxMap)
import System.FilePath (addExtension, replaceExtension, takeExtension)
import Text.Collate.Lang (renderLang)
import Text.Pandoc.Builder as B
import Text.Pandoc.Class (PandocPure, PandocMonad (..), getResourcePath,
readFileFromDirs, report,
setResourcePath, getZonedTime)
import Data.Time (ZonedTime(..), LocalTime(..), showGregorian)
import Text.Pandoc.Error (PandocError (PandocParseError))
import Text.Pandoc.Highlighting (languagesByExtension)
import Text.Pandoc.ImageSize (numUnit, showFl)
import Text.Pandoc.Logging
import Text.Pandoc.Options
import Text.Pandoc.Parsing hiding (blankline, many, mathDisplay, mathInline,
optional, space, spaces, withRaw, (<|>))
import Text.Pandoc.TeX (Tok (..), TokType (..))
import Text.Pandoc.Readers.LaTeX.Parsing
import Text.Pandoc.Readers.LaTeX.Citation (citationCommands, cites)
import Text.Pandoc.Readers.LaTeX.Math (withMathMode, dollarsMath,
inlineEnvironments, inlineEnvironment,
mathDisplay, mathInline,
newtheorem, theoremstyle, proof,
theoremEnvironment)
import Text.Pandoc.Readers.LaTeX.Table (tableEnvironments)
import Text.Pandoc.Readers.LaTeX.Macro (macroDef)
import Text.Pandoc.Readers.LaTeX.Lang (inlineLanguageCommands,
enquoteCommands,
babelLangToBCP47,
setDefaultLanguage)
import Text.Pandoc.Readers.LaTeX.SIunitx (siunitxCommands)
import Text.Pandoc.Readers.LaTeX.Inline (acronymCommands, refCommands,
nameCommands, charCommands,
accentCommands,
miscCommands,
biblatexInlineCommands,
verbCommands, rawInlineOr,
listingsLanguage)
import Text.Pandoc.Shared
import Text.Pandoc.Walk
import Data.List.NonEmpty (nonEmpty)
readLaTeX :: (PandocMonad m, ToSources a)
=> ReaderOptions
-> a
-> m Pandoc
readLaTeX :: forall (m :: * -> *) a.
(PandocMonad m, ToSources a) =>
ReaderOptions -> a -> m Pandoc
readLaTeX ReaderOptions
opts a
ltx = do
let sources :: Sources
sources = a -> Sources
forall a. ToSources a => a -> Sources
toSources a
ltx
parsed <- ParsecT TokStream LaTeXState m Pandoc
-> LaTeXState
-> [Char]
-> TokStream
-> m (Either ParseError Pandoc)
forall s (m :: * -> *) t u a.
Stream s m t =>
ParsecT s u m a -> u -> [Char] -> s -> m (Either ParseError a)
runParserT ParsecT TokStream LaTeXState m Pandoc
forall (m :: * -> *). PandocMonad m => LP m Pandoc
parseLaTeX LaTeXState
forall a. Default a => a
def{ sOptions = opts } [Char]
"source"
(Bool -> [Tok] -> TokStream
TokStream Bool
False (Sources -> [Tok]
tokenizeSources Sources
sources))
case parsed of
Right Pandoc
result -> Pandoc -> m Pandoc
forall a. a -> m a
forall (m :: * -> *) a. Monad m => a -> m a
return Pandoc
result
Left ParseError
e -> PandocError -> m Pandoc
forall a. PandocError -> m a
forall e (m :: * -> *) a. MonadError e m => e -> m a
throwError (PandocError -> m Pandoc) -> PandocError -> m Pandoc
forall a b. (a -> b) -> a -> b
$ Sources -> ParseError -> PandocError
fromParsecError Sources
sources ParseError
e
parseLaTeX :: PandocMonad m => LP m Pandoc
parseLaTeX :: forall (m :: * -> *). PandocMonad m => LP m Pandoc
parseLaTeX = do
bs <- LP m (Many Block)
forall (m :: * -> *). PandocMonad m => LP m (Many Block)
blocks
eof
st <- getState
let meta = LaTeXState -> Meta
sMeta LaTeXState
st
let doc' = Many Block -> Pandoc
doc Many Block
bs
let headerLevel (Header Int
n Attr
_ [Inline]
_) = [Int
n]
headerLevel Block
_ = []
let bottomLevel = Int -> (NonEmpty Int -> Int) -> Maybe (NonEmpty Int) -> Int
forall b a. b -> (a -> b) -> Maybe a -> b
maybe Int
1 NonEmpty Int -> Int
forall a. Ord a => NonEmpty a -> a
forall (t :: * -> *) a. (Foldable t, Ord a) => t a -> a
minimum (Maybe (NonEmpty Int) -> Int) -> Maybe (NonEmpty Int) -> Int
forall a b. (a -> b) -> a -> b
$ [Int] -> Maybe (NonEmpty Int)
forall a. [a] -> Maybe (NonEmpty a)
nonEmpty ([Int] -> Maybe (NonEmpty Int)) -> [Int] -> Maybe (NonEmpty Int)
forall a b. (a -> b) -> a -> b
$ (Block -> [Int]) -> Pandoc -> [Int]
forall c. Monoid c => (Block -> c) -> Pandoc -> c
forall a b c. (Walkable a b, Monoid c) => (a -> c) -> b -> c
query Block -> [Int]
headerLevel Pandoc
doc'
let adjustHeaders Int
m (Header Int
n Attr
attr [Inline]
ils) = Int -> Attr -> [Inline] -> Block
Header (Int
nInt -> Int -> Int
forall a. Num a => a -> a -> a
+Int
m) Attr
attr [Inline]
ils
adjustHeaders Int
_ Block
x = Block
x
let (Pandoc _ bs') =
(if bottomLevel < 1
then walk (adjustHeaders (1 - bottomLevel))
else id) $
walk (resolveFootnoteMarks (sFootnoteTexts st)) $
walk (resolveRefs (sLabels st)) doc'
return $ Pandoc meta bs'
resolveRefs :: M.Map Text [Inline] -> Inline -> Inline
resolveRefs :: Map Text [Inline] -> Inline -> Inline
resolveRefs Map Text [Inline]
labels x :: Inline
x@(Link (Text
ident,[Text]
classes,[(Text, Text)]
kvs) [Inline]
_ (Text, Text)
_) =
case ((Char -> Bool) -> Text -> Text
T.takeWhile (Char -> Char -> Bool
forall a. Eq a => a -> a -> Bool
/=Char
'+') (Text -> Text) -> Maybe Text -> Maybe Text
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Text -> [(Text, Text)] -> Maybe Text
forall a b. Eq a => a -> [(a, b)] -> Maybe b
lookup Text
"reference-type" [(Text, Text)]
kvs,
Text -> [(Text, Text)] -> Maybe Text
forall a b. Eq a => a -> [(a, b)] -> Maybe b
lookup Text
"reference" [(Text, Text)]
kvs) of
(Just Text
"ref", Just Text
lab) ->
case Text -> Map Text [Inline] -> Maybe [Inline]
forall k a. Ord k => k -> Map k a -> Maybe a
M.lookup Text
lab Map Text [Inline]
labels of
Just [Inline]
txt -> Attr -> [Inline] -> (Text, Text) -> Inline
Link (Text
ident,[Text]
classes,[(Text, Text)]
kvs) [Inline]
txt (Text
"#" Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
lab, Text
"")
Maybe [Inline]
Nothing -> Inline
x
(Maybe Text, Maybe Text)
_ -> Inline
x
resolveRefs Map Text [Inline]
_ Inline
x = Inline
x
resolveFootnoteMarks :: M.Map Int Blocks -> Inline -> Inline
Map Int (Many Block)
fnTexts (Span (Text
_, [Text]
classes, [(Text, Text)]
kvs) [Inline]
_)
| Text
"footnote-mark" Text -> [Text] -> Bool
forall a. Eq a => a -> [a] -> Bool
forall (t :: * -> *) a. (Foldable t, Eq a) => a -> t a -> Bool
`elem` [Text]
classes
, Just Text
numText <- Text -> [(Text, Text)] -> Maybe Text
forall a b. Eq a => a -> [(a, b)] -> Maybe b
lookup Text
"note-num" [(Text, Text)]
kvs
, [(Int
n, [Char]
"")] <- ReadS Int
forall a. Read a => ReadS a
reads (Text -> [Char]
T.unpack Text
numText)
= case Int -> Map Int (Many Block) -> Maybe (Many Block)
forall k a. Ord k => k -> Map k a -> Maybe a
M.lookup Int
n Map Int (Many Block)
fnTexts of
Just Many Block
contents -> [Block] -> Inline
Note (Many Block -> [Block]
forall a. Many a -> [a]
toList Many Block
contents)
Maybe (Many Block)
Nothing -> Text -> Inline
Str Text
""
resolveFootnoteMarks Map Int (Many Block)
_ Inline
x = Inline
x
rawLaTeXBlock :: (PandocMonad m, HasMacros s, HasReaderOptions s)
=> ParsecT Sources s m Text
rawLaTeXBlock :: forall (m :: * -> *) s.
(PandocMonad m, HasMacros s, HasReaderOptions s) =>
ParsecT Sources s m Text
rawLaTeXBlock = do
ParsecT Sources s m Char -> ParsecT Sources s 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 s m Char -> ParsecT Sources s m Char
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try (Char -> ParsecT Sources s 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 s m Char
-> ParsecT Sources s m Char -> ParsecT Sources s m Char
forall a b.
ParsecT Sources s m a
-> ParsecT Sources s m b -> ParsecT Sources s m b
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> ParsecT Sources s m Char
forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
ParsecT s u m Char
letter))
toks <- ParsecT Sources s m [Tok]
forall (m :: * -> *) s. PandocMonad m => ParsecT Sources s m [Tok]
getInputTokens
snd <$> (
rawLaTeXParser toks
(makeAtLetterSection <|>
macroDef (const mempty) <|>
do choice (map controlSeq
["include", "input", "subfile", "usepackage"])
skipMany opt
braced
return mempty) blocks
<|> rawLaTeXParser toks
(void (environment <|> blockCommand))
(mconcat <$> many (block <|> beginOrEndCommand)))
makeAtLetterSection :: PandocMonad m => LP m ()
makeAtLetterSection :: forall (m :: * -> *). PandocMonad m => LP m ()
makeAtLetterSection = ParsecT TokStream LaTeXState m ()
-> ParsecT TokStream LaTeXState m ()
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try (ParsecT TokStream LaTeXState m ()
-> ParsecT TokStream LaTeXState m ())
-> ParsecT TokStream LaTeXState m ()
-> ParsecT TokStream LaTeXState m ()
forall a b. (a -> b) -> a -> b
$ do
Text -> LP m Tok
forall (m :: * -> *). PandocMonad m => Text -> LP m Tok
controlSeq Text
"makeatletter"
ParsecT TokStream LaTeXState m [()]
-> ParsecT TokStream LaTeXState m ()
forall (f :: * -> *) a. Functor f => f a -> f ()
void (ParsecT TokStream LaTeXState m [()]
-> ParsecT TokStream LaTeXState m ())
-> ParsecT TokStream LaTeXState m [()]
-> ParsecT TokStream LaTeXState m ()
forall a b. (a -> b) -> a -> b
$ ParsecT TokStream LaTeXState m ()
-> LP m Tok -> ParsecT TokStream LaTeXState m [()]
forall s (m :: * -> *) t u a end.
Stream s m t =>
ParsecT s u m a -> ParsecT s u m end -> ParsecT s u m [a]
manyTill
( ParsecT TokStream LaTeXState m ()
forall (m :: * -> *). PandocMonad m => LP m ()
whitespace
ParsecT TokStream LaTeXState m ()
-> ParsecT TokStream LaTeXState m ()
-> ParsecT TokStream LaTeXState m ()
forall a.
ParsecT TokStream LaTeXState m a
-> ParsecT TokStream LaTeXState m a
-> ParsecT TokStream LaTeXState m a
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> ParsecT TokStream LaTeXState m ()
forall (m :: * -> *). PandocMonad m => LP m ()
newlineTok
ParsecT TokStream LaTeXState m ()
-> ParsecT TokStream LaTeXState m ()
-> ParsecT TokStream LaTeXState m ()
forall a.
ParsecT TokStream LaTeXState m a
-> ParsecT TokStream LaTeXState m a
-> ParsecT TokStream LaTeXState m a
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> (Text -> ()) -> ParsecT TokStream LaTeXState m ()
forall (m :: * -> *) a.
(PandocMonad m, Monoid a) =>
(Text -> a) -> LP m a
macroDef (() -> Text -> ()
forall a b. a -> b -> a
const ())
ParsecT TokStream LaTeXState m ()
-> ParsecT TokStream LaTeXState m ()
-> ParsecT TokStream LaTeXState m ()
forall a.
ParsecT TokStream LaTeXState m a
-> ParsecT TokStream LaTeXState m a
-> ParsecT TokStream LaTeXState m a
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> ParsecT TokStream LaTeXState m (Many Block)
-> ParsecT TokStream LaTeXState m ()
forall (f :: * -> *) a. Functor f => f a -> f ()
void ParsecT TokStream LaTeXState m (Many Block)
forall (m :: * -> *). PandocMonad m => LP m (Many Block)
environment
ParsecT TokStream LaTeXState m ()
-> ParsecT TokStream LaTeXState m ()
-> ParsecT TokStream LaTeXState m ()
forall a.
ParsecT TokStream LaTeXState m a
-> ParsecT TokStream LaTeXState m a
-> ParsecT TokStream LaTeXState m a
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> ParsecT TokStream LaTeXState m (Many Block)
-> ParsecT TokStream LaTeXState m ()
forall (f :: * -> *) a. Functor f => f a -> f ()
void ParsecT TokStream LaTeXState m (Many Block)
forall (m :: * -> *). PandocMonad m => LP m (Many Block)
blockCommand
) (Text -> LP m Tok
forall (m :: * -> *). PandocMonad m => Text -> LP m Tok
controlSeq Text
"makeatother")
beginOrEndCommand :: PandocMonad m => LP m Blocks
beginOrEndCommand :: forall (m :: * -> *). PandocMonad m => LP m (Many Block)
beginOrEndCommand = ParsecT TokStream LaTeXState m (Many Block)
-> ParsecT TokStream LaTeXState m (Many Block)
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try (ParsecT TokStream LaTeXState m (Many Block)
-> ParsecT TokStream LaTeXState m (Many Block))
-> ParsecT TokStream LaTeXState m (Many Block)
-> ParsecT TokStream LaTeXState m (Many Block)
forall a b. (a -> b) -> a -> b
$ do
Tok _ (CtrlSeq name) txt <- LP m Tok
forall (m :: * -> *). PandocMonad m => LP m Tok
anyControlSeq
guard $ name == "begin" || name == "end"
(envname, rawargs) <- withRaw braced
if M.member (untokenize envname)
(inlineEnvironments :: M.Map Text (LP PandocPure Inlines))
then mzero
else return $ rawBlock "latex"
(txt <> untokenize rawargs)
rawLaTeXInline :: (PandocMonad m, HasMacros s, HasReaderOptions s)
=> ParsecT Sources s m Text
rawLaTeXInline :: forall (m :: * -> *) s.
(PandocMonad m, HasMacros s, HasReaderOptions s) =>
ParsecT Sources s m Text
rawLaTeXInline = do
ParsecT Sources s m Char -> ParsecT Sources s 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 s m Char -> ParsecT Sources s m Char
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try (Char -> ParsecT Sources s 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 s m Char
-> ParsecT Sources s m Char -> ParsecT Sources s m Char
forall a b.
ParsecT Sources s m a
-> ParsecT Sources s m b -> ParsecT Sources s m b
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> ParsecT Sources s m Char
forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
ParsecT s u m Char
letter))
toks <- ParsecT Sources s m [Tok]
forall (m :: * -> *) s. PandocMonad m => ParsecT Sources s m [Tok]
getInputTokens
raw <- snd <$>
( rawLaTeXParser toks
(mempty <$ (controlSeq "input" >> skipMany rawopt >> braced))
inlines
<|> rawLaTeXParser toks (void inline) inlines
)
finalbraces <- mconcat <$> many (try (string "{}"))
return $ raw <> T.pack finalbraces
inlineCommand :: PandocMonad m => ParsecT Sources ParserState m Inlines
inlineCommand :: forall (m :: * -> *).
PandocMonad m =>
ParsecT Sources ParserState m (Many Inline)
inlineCommand = do
ParsecT Sources ParserState m Char
-> ParsecT Sources ParserState 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 ParserState m Char
-> ParsecT Sources ParserState m Char
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try (Char -> ParsecT Sources ParserState 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 ParserState m Char
-> ParsecT Sources ParserState m Char
-> ParsecT Sources ParserState m Char
forall a b.
ParsecT Sources ParserState m a
-> ParsecT Sources ParserState m b
-> ParsecT Sources ParserState m b
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> ParsecT Sources ParserState m Char
forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
ParsecT s u m Char
letter))
toks <- ParsecT Sources ParserState m [Tok]
forall (m :: * -> *) s. PandocMonad m => ParsecT Sources s m [Tok]
getInputTokens
fst <$> rawLaTeXParser toks (void (inlineEnvironment <|> inlineCommand'))
inlines
inlineGroup :: PandocMonad m => LP m Inlines
inlineGroup :: forall (m :: * -> *). PandocMonad m => LP m (Many Inline)
inlineGroup = do
ils <- LP m (Many Inline) -> LP m (Many Inline)
forall (m :: * -> *) a.
(PandocMonad m, Monoid a) =>
LP m a -> LP m a
grouped LP m (Many Inline)
forall (m :: * -> *). PandocMonad m => LP m (Many Inline)
inline
if null ils
then return mempty
else return $ spanWith nullAttr ils
doLHSverb :: PandocMonad m => LP m Inlines
doLHSverb :: forall (m :: * -> *). PandocMonad m => LP m (Many Inline)
doLHSverb =
Attr -> Text -> Many Inline
codeWith (Text
"",[Text
"haskell"],[]) (Text -> Many Inline) -> ([Tok] -> Text) -> [Tok] -> Many Inline
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [Tok] -> Text
untokenize
([Tok] -> Many Inline)
-> ParsecT TokStream LaTeXState m [Tok]
-> ParsecT TokStream LaTeXState m (Many Inline)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ParsecT TokStream LaTeXState m Tok
-> ParsecT TokStream LaTeXState m Tok
-> ParsecT TokStream LaTeXState m [Tok]
forall s (m :: * -> *) t u a end.
Stream s m t =>
ParsecT s u m a -> ParsecT s u m end -> ParsecT s u m [a]
manyTill ((Tok -> Bool) -> ParsecT TokStream LaTeXState m Tok
forall (m :: * -> *). PandocMonad m => (Tok -> Bool) -> LP m Tok
satisfyTok (Bool -> Bool
not (Bool -> Bool) -> (Tok -> Bool) -> Tok -> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Tok -> Bool
isNewlineTok)) (Char -> ParsecT TokStream LaTeXState m Tok
forall (m :: * -> *). PandocMonad m => Char -> LP m Tok
symbol Char
'|')
mkImage :: PandocMonad m => [(Text, Text)] -> Text -> LP m Inlines
mkImage :: forall (m :: * -> *).
PandocMonad m =>
[(Text, Text)] -> Text -> LP m (Many Inline)
mkImage [(Text, Text)]
options (Text -> [Char]
T.unpack -> [Char]
src) = do
let replaceRelative :: (a, Text) -> (a, Text)
replaceRelative (a
k,Text
v) =
case Text -> Maybe (Double, Text)
numUnit Text
v of
Just (Double
num, Text
"\\textwidth") -> (a
k, Double -> Text
forall a. RealFloat a => a -> Text
showFl (Double
num Double -> Double -> Double
forall a. Num a => a -> a -> a
* Double
100) Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
"%")
Just (Double
num, Text
"\\linewidth") -> (a
k, Double -> Text
forall a. RealFloat a => a -> Text
showFl (Double
num Double -> Double -> Double
forall a. Num a => a -> a -> a
* Double
100) Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
"%")
Just (Double
num, Text
"\\textheight") -> (a
k, Double -> Text
forall a. RealFloat a => a -> Text
showFl (Double
num Double -> Double -> Double
forall a. Num a => a -> a -> a
* Double
100) Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
"%")
Maybe (Double, Text)
_ -> (a
k, Text
v)
let kvs :: [(Text, Text)]
kvs = ((Text, Text) -> (Text, Text)) -> [(Text, Text)] -> [(Text, Text)]
forall a b. (a -> b) -> [a] -> [b]
map (Text, Text) -> (Text, Text)
forall {a}. (a, Text) -> (a, Text)
replaceRelative
([(Text, Text)] -> [(Text, Text)])
-> [(Text, Text)] -> [(Text, Text)]
forall a b. (a -> b) -> a -> b
$ ((Text, Text) -> Bool) -> [(Text, Text)] -> [(Text, Text)]
forall a. (a -> Bool) -> [a] -> [a]
filter (\(Text
k,Text
_) -> Text
k Text -> [Text] -> Bool
forall a. Eq a => a -> [a] -> Bool
forall (t :: * -> *) a. (Foldable t, Eq a) => a -> t a -> Bool
`elem` [Text
"width", Text
"height"]) [(Text, Text)]
options
let attr :: (Text, [a], [(Text, Text)])
attr = (Text
"",[], [(Text, Text)]
kvs)
let alt :: Many Inline
alt = Many Inline -> (Text -> Many Inline) -> Maybe Text -> Many Inline
forall b a. b -> (a -> b) -> Maybe a -> b
maybe (Text -> Many Inline
str Text
"image") Text -> Many Inline
str (Maybe Text -> Many Inline) -> Maybe Text -> Many Inline
forall a b. (a -> b) -> a -> b
$ Text -> [(Text, Text)] -> Maybe Text
forall a b. Eq a => a -> [(a, b)] -> Maybe b
lookup Text
"alt" [(Text, Text)]
options
defaultExt <- (ReaderOptions -> Text) -> ParsecT TokStream LaTeXState m Text
forall st s (m :: * -> *) t b.
(HasReaderOptions st, Stream s m t) =>
(ReaderOptions -> b) -> ParsecT s st m b
forall s (m :: * -> *) t b.
Stream s m t =>
(ReaderOptions -> b) -> ParsecT s LaTeXState m b
getOption ReaderOptions -> Text
readerDefaultImageExtension
let exts' = [[Char]
".pdf", [Char]
".png", [Char]
".jpg", [Char]
".mps", [Char]
".jpeg", [Char]
".jbig2", [Char]
".jb2"]
let exts = [[Char]]
exts' [[Char]] -> [[Char]] -> [[Char]]
forall a. [a] -> [a] -> [a]
++ ([Char] -> [Char]) -> [[Char]] -> [[Char]]
forall a b. (a -> b) -> [a] -> [b]
map ((Char -> Char) -> [Char] -> [Char]
forall a b. (a -> b) -> [a] -> [b]
map Char -> Char
toUpper) [[Char]]
exts'
let findFile [Char]
s [] = [Char] -> m [Char]
forall a. a -> m a
forall (m :: * -> *) a. Monad m => a -> m a
return [Char]
s
findFile [Char]
s ([Char]
e:[[Char]]
es) = do
let s' :: [Char]
s' = [Char] -> [Char] -> [Char]
addExtension [Char]
s [Char]
e
exists <- [Char] -> m Bool
forall (m :: * -> *). PandocMonad m => [Char] -> m Bool
fileExists [Char]
s'
if exists
then return s'
else findFile s es
src' <- case takeExtension src of
[Char]
"" | Bool -> Bool
not (Text -> Bool
T.null Text
defaultExt) -> [Char] -> ParsecT TokStream LaTeXState m [Char]
forall a. a -> ParsecT TokStream LaTeXState m a
forall (m :: * -> *) a. Monad m => a -> m a
return ([Char] -> ParsecT TokStream LaTeXState m [Char])
-> [Char] -> ParsecT TokStream LaTeXState m [Char]
forall a b. (a -> b) -> a -> b
$ [Char] -> [Char] -> [Char]
addExtension [Char]
src ([Char] -> [Char]) -> [Char] -> [Char]
forall a b. (a -> b) -> a -> b
$ Text -> [Char]
T.unpack Text
defaultExt
| Bool
otherwise -> [Char] -> [[Char]] -> ParsecT TokStream LaTeXState m [Char]
forall {m :: * -> *}.
PandocMonad m =>
[Char] -> [[Char]] -> m [Char]
findFile [Char]
src [[Char]]
exts
[Char]
_ -> [Char] -> ParsecT TokStream LaTeXState m [Char]
forall a. a -> ParsecT TokStream LaTeXState m a
forall (m :: * -> *) a. Monad m => a -> m a
return [Char]
src
return $ imageWith attr (T.pack src') "" alt
removeDoubleQuotes :: Text -> Text
removeDoubleQuotes :: Text -> Text
removeDoubleQuotes Text
t =
Text -> Maybe Text -> Text
forall a. a -> Maybe a -> a
Data.Maybe.fromMaybe Text
t (Maybe Text -> Text) -> Maybe Text -> Text
forall a b. (a -> b) -> a -> b
$ Text -> Text -> Maybe Text
T.stripPrefix Text
"\"" Text
t Maybe Text -> (Text -> Maybe Text) -> Maybe Text
forall a b. Maybe a -> (a -> Maybe b) -> Maybe b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= Text -> Text -> Maybe Text
T.stripSuffix Text
"\""
doubleQuote :: PandocMonad m => LP m Inlines
doubleQuote :: forall (m :: * -> *). PandocMonad m => LP m (Many Inline)
doubleQuote =
(Many Inline -> Many Inline)
-> LP m [Tok] -> LP m () -> LP m (Many Inline)
forall (m :: * -> *).
PandocMonad m =>
(Many Inline -> Many Inline)
-> LP m [Tok] -> LP m () -> LP m (Many Inline)
quoted' Many Inline -> Many Inline
doubleQuoted (LP m [Tok] -> LP m [Tok]
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try (LP m [Tok] -> LP m [Tok]) -> LP m [Tok] -> LP m [Tok]
forall a b. (a -> b) -> a -> b
$ Int -> ParsecT TokStream LaTeXState m Tok -> LP m [Tok]
forall s (m :: * -> *) t u a.
Stream s m t =>
Int -> ParsecT s u m a -> ParsecT s u m [a]
count Int
2 (ParsecT TokStream LaTeXState m Tok -> LP m [Tok])
-> ParsecT TokStream LaTeXState m Tok -> LP m [Tok]
forall a b. (a -> b) -> a -> b
$ Char -> ParsecT TokStream LaTeXState m Tok
forall (m :: * -> *). PandocMonad m => Char -> LP m Tok
symbol Char
'`')
(LP m [Tok] -> LP m ()
forall (f :: * -> *) a. Functor f => f a -> f ()
void (LP m [Tok] -> LP m ()) -> LP m [Tok] -> LP m ()
forall a b. (a -> b) -> a -> b
$ LP m [Tok] -> LP m [Tok]
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try (LP m [Tok] -> LP m [Tok]) -> LP m [Tok] -> LP m [Tok]
forall a b. (a -> b) -> a -> b
$ Int -> ParsecT TokStream LaTeXState m Tok -> LP m [Tok]
forall s (m :: * -> *) t u a.
Stream s m t =>
Int -> ParsecT s u m a -> ParsecT s u m [a]
count Int
2 (ParsecT TokStream LaTeXState m Tok -> LP m [Tok])
-> ParsecT TokStream LaTeXState m Tok -> LP m [Tok]
forall a b. (a -> b) -> a -> b
$ Char -> ParsecT TokStream LaTeXState m Tok
forall (m :: * -> *). PandocMonad m => Char -> LP m Tok
symbol Char
'\'')
LP m (Many Inline) -> LP m (Many Inline) -> LP m (Many Inline)
forall a.
ParsecT TokStream LaTeXState m a
-> ParsecT TokStream LaTeXState m a
-> ParsecT TokStream LaTeXState m a
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> (Many Inline -> Many Inline)
-> LP m [Tok] -> LP m () -> LP m (Many Inline)
forall (m :: * -> *).
PandocMonad m =>
(Many Inline -> Many Inline)
-> LP m [Tok] -> LP m () -> LP m (Many Inline)
quoted' Many Inline -> Many Inline
doubleQuoted ((Tok -> [Tok] -> [Tok]
forall a. a -> [a] -> [a]
:[]) (Tok -> [Tok]) -> ParsecT TokStream LaTeXState m Tok -> LP m [Tok]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Char -> ParsecT TokStream LaTeXState m Tok
forall (m :: * -> *). PandocMonad m => Char -> LP m Tok
symbol Char
'“') (ParsecT TokStream LaTeXState m Tok -> LP m ()
forall (f :: * -> *) a. Functor f => f a -> f ()
void (ParsecT TokStream LaTeXState m Tok -> LP m ())
-> ParsecT TokStream LaTeXState m Tok -> LP m ()
forall a b. (a -> b) -> a -> b
$ Char -> ParsecT TokStream LaTeXState m Tok
forall (m :: * -> *). PandocMonad m => Char -> LP m Tok
symbol Char
'”')
LP m (Many Inline) -> LP m (Many Inline) -> LP m (Many Inline)
forall a.
ParsecT TokStream LaTeXState m a
-> ParsecT TokStream LaTeXState m a
-> ParsecT TokStream LaTeXState m a
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> (Many Inline -> Many Inline)
-> LP m [Tok] -> LP m () -> LP m (Many Inline)
forall (m :: * -> *).
PandocMonad m =>
(Many Inline -> Many Inline)
-> LP m [Tok] -> LP m () -> LP m (Many Inline)
quoted' Many Inline -> Many Inline
doubleQuoted (LP m [Tok] -> LP m [Tok]
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try (LP m [Tok] -> LP m [Tok]) -> LP m [Tok] -> LP m [Tok]
forall a b. (a -> b) -> a -> b
$ [ParsecT TokStream LaTeXState m Tok] -> LP m [Tok]
forall (t :: * -> *) (m :: * -> *) a.
(Traversable t, Monad m) =>
t (m a) -> m (t a)
forall (m :: * -> *) a. Monad m => [m a] -> m [a]
sequence [Char -> ParsecT TokStream LaTeXState m Tok
forall (m :: * -> *). PandocMonad m => Char -> LP m Tok
symbol Char
'"', Char -> ParsecT TokStream LaTeXState m Tok
forall (m :: * -> *). PandocMonad m => Char -> LP m Tok
symbol Char
'`'])
(LP m [Tok] -> LP m ()
forall (f :: * -> *) a. Functor f => f a -> f ()
void (LP m [Tok] -> LP m ()) -> LP m [Tok] -> LP m ()
forall a b. (a -> b) -> a -> b
$ LP m [Tok] -> LP m [Tok]
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try (LP m [Tok] -> LP m [Tok]) -> LP m [Tok] -> LP m [Tok]
forall a b. (a -> b) -> a -> b
$ [ParsecT TokStream LaTeXState m Tok] -> LP m [Tok]
forall (t :: * -> *) (m :: * -> *) a.
(Traversable t, Monad m) =>
t (m a) -> m (t a)
forall (m :: * -> *) a. Monad m => [m a] -> m [a]
sequence [Char -> ParsecT TokStream LaTeXState m Tok
forall (m :: * -> *). PandocMonad m => Char -> LP m Tok
symbol Char
'"', Char -> ParsecT TokStream LaTeXState m Tok
forall (m :: * -> *). PandocMonad m => Char -> LP m Tok
symbol Char
'\''])
singleQuote :: PandocMonad m => LP m Inlines
singleQuote :: forall (m :: * -> *). PandocMonad m => LP m (Many Inline)
singleQuote =
(Many Inline -> Many Inline)
-> LP m [Tok] -> LP m () -> LP m (Many Inline)
forall (m :: * -> *).
PandocMonad m =>
(Many Inline -> Many Inline)
-> LP m [Tok] -> LP m () -> LP m (Many Inline)
quoted' Many Inline -> Many Inline
singleQuoted ((Tok -> [Tok] -> [Tok]
forall a. a -> [a] -> [a]
:[]) (Tok -> [Tok]) -> ParsecT TokStream LaTeXState m Tok -> LP m [Tok]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Char -> ParsecT TokStream LaTeXState m Tok
forall (m :: * -> *). PandocMonad m => Char -> LP m Tok
symbol Char
'`')
(LP m () -> LP m ()
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try (LP m () -> LP m ()) -> LP m () -> LP m ()
forall a b. (a -> b) -> a -> b
$ Char -> ParsecT TokStream LaTeXState m Tok
forall (m :: * -> *). PandocMonad m => Char -> LP m Tok
symbol Char
'\'' ParsecT TokStream LaTeXState m Tok -> LP m () -> LP m ()
forall a b.
ParsecT TokStream LaTeXState m a
-> ParsecT TokStream LaTeXState m b
-> ParsecT TokStream LaTeXState m b
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>>
ParsecT TokStream LaTeXState m Tok -> LP m ()
forall s (m :: * -> *) t a u.
(Stream s m t, Show a) =>
ParsecT s u m a -> ParsecT s u m ()
notFollowedBy ((Tok -> Bool) -> ParsecT TokStream LaTeXState m Tok
forall (m :: * -> *). PandocMonad m => (Tok -> Bool) -> LP m Tok
satisfyTok Tok -> Bool
startsWithLetter))
LP m (Many Inline) -> LP m (Many Inline) -> LP m (Many Inline)
forall a.
ParsecT TokStream LaTeXState m a
-> ParsecT TokStream LaTeXState m a
-> ParsecT TokStream LaTeXState m a
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> (Many Inline -> Many Inline)
-> LP m [Tok] -> LP m () -> LP m (Many Inline)
forall (m :: * -> *).
PandocMonad m =>
(Many Inline -> Many Inline)
-> LP m [Tok] -> LP m () -> LP m (Many Inline)
quoted' Many Inline -> Many Inline
singleQuoted ((Tok -> [Tok] -> [Tok]
forall a. a -> [a] -> [a]
:[]) (Tok -> [Tok]) -> ParsecT TokStream LaTeXState m Tok -> LP m [Tok]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Char -> ParsecT TokStream LaTeXState m Tok
forall (m :: * -> *). PandocMonad m => Char -> LP m Tok
symbol Char
'‘')
(LP m () -> LP m ()
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try (LP m () -> LP m ()) -> LP m () -> LP m ()
forall a b. (a -> b) -> a -> b
$ Char -> ParsecT TokStream LaTeXState m Tok
forall (m :: * -> *). PandocMonad m => Char -> LP m Tok
symbol Char
'’' ParsecT TokStream LaTeXState m Tok -> LP m () -> LP m ()
forall a b.
ParsecT TokStream LaTeXState m a
-> ParsecT TokStream LaTeXState m b
-> ParsecT TokStream LaTeXState m b
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>>
ParsecT TokStream LaTeXState m Tok -> LP m ()
forall s (m :: * -> *) t a u.
(Stream s m t, Show a) =>
ParsecT s u m a -> ParsecT s u m ()
notFollowedBy ((Tok -> Bool) -> ParsecT TokStream LaTeXState m Tok
forall (m :: * -> *). PandocMonad m => (Tok -> Bool) -> LP m Tok
satisfyTok Tok -> Bool
startsWithLetter))
where startsWithLetter :: Tok -> Bool
startsWithLetter (Tok SourcePos
_ TokType
Word Text
t) =
case Text -> Maybe (Char, Text)
T.uncons Text
t of
Just (Char
c, Text
_) | Char -> Bool
isLetter Char
c -> Bool
True
Maybe (Char, Text)
_ -> Bool
False
startsWithLetter Tok
_ = Bool
False
quoted' :: PandocMonad m
=> (Inlines -> Inlines)
-> LP m [Tok]
-> LP m ()
-> LP m Inlines
quoted' :: forall (m :: * -> *).
PandocMonad m =>
(Many Inline -> Many Inline)
-> LP m [Tok] -> LP m () -> LP m (Many Inline)
quoted' Many Inline -> Many Inline
f LP m [Tok]
starter LP m ()
ender = do
startchs <- [Tok] -> Text
untokenize ([Tok] -> Text)
-> LP m [Tok] -> ParsecT TokStream LaTeXState m Text
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> LP m [Tok]
starter
smart <- extensionEnabled Ext_smart <$> getOption readerExtensions
if smart
then do
ils <- many (notFollowedBy ender >> inline)
(ender >> return (f (mconcat ils))) <|>
(<> mconcat ils) <$>
lit (case startchs of
Text
"``" -> Text
"“"
Text
"`" -> Text
"‘"
Text
cs -> Text
cs)
else lit startchs
lit :: Text -> LP m Inlines
lit :: forall (m :: * -> *). Text -> LP m (Many Inline)
lit = Many Inline -> ParsecT TokStream LaTeXState m (Many Inline)
forall a. a -> ParsecT TokStream LaTeXState m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Many Inline -> ParsecT TokStream LaTeXState m (Many Inline))
-> (Text -> Many Inline)
-> Text
-> ParsecT TokStream LaTeXState m (Many Inline)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Text -> Many Inline
str
blockquote :: PandocMonad m => Bool -> Maybe Text -> LP m Blocks
blockquote :: forall (m :: * -> *).
PandocMonad m =>
Bool -> Maybe Text -> LP m (Many Block)
blockquote Bool
cvariant Maybe Text
mblang = do
citepar <- if Bool
cvariant
then (\[Citation]
xs -> Many Inline -> Many Block
para ([Citation] -> Many Inline -> Many Inline
cite [Citation]
xs Many Inline
forall a. Monoid a => a
mempty))
([Citation] -> Many Block)
-> ParsecT TokStream LaTeXState m [Citation]
-> ParsecT TokStream LaTeXState m (Many Block)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> LP m (Many Inline)
-> CitationMode
-> Bool
-> ParsecT TokStream LaTeXState m [Citation]
forall (m :: * -> *).
PandocMonad m =>
LP m (Many Inline) -> CitationMode -> Bool -> LP m [Citation]
cites LP m (Many Inline)
forall (m :: * -> *). PandocMonad m => LP m (Many Inline)
inline CitationMode
NormalCitation Bool
False
else Many Block
-> ParsecT TokStream LaTeXState m (Many Block)
-> ParsecT TokStream LaTeXState m (Many Block)
forall s (m :: * -> *) t a u.
Stream s m t =>
a -> ParsecT s u m a -> ParsecT s u m a
option Many Block
forall a. Monoid a => a
mempty (ParsecT TokStream LaTeXState m (Many Block)
-> ParsecT TokStream LaTeXState m (Many Block))
-> ParsecT TokStream LaTeXState m (Many Block)
-> ParsecT TokStream LaTeXState m (Many Block)
forall a b. (a -> b) -> a -> b
$ Many Inline -> Many Block
para (Many Inline -> Many Block)
-> LP m (Many Inline)
-> ParsecT TokStream LaTeXState m (Many Block)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> LP m (Many Inline) -> LP m (Many Inline)
forall (m :: * -> *) a.
(PandocMonad m, Monoid a) =>
LP m a -> LP m a
bracketed LP m (Many Inline)
forall (m :: * -> *). PandocMonad m => LP m (Many Inline)
inline
let lang = Maybe Text
mblang Maybe Text -> (Text -> Maybe Lang) -> Maybe Lang
forall a b. Maybe a -> (a -> Maybe b) -> Maybe b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= Text -> Maybe Lang
babelLangToBCP47
let langdiv = case Maybe Lang
lang of
Maybe Lang
Nothing -> Many Block -> Many Block
forall a. a -> a
id
Just Lang
l -> Attr -> Many Block -> Many Block
divWith (Text
"",[],[(Text
"lang", Lang -> Text
renderLang Lang
l)])
_closingPunct <- option mempty $ bracketed inline
bs <- grouped block
optional $ symbolIn (".:;?!" :: [Char])
return $ blockQuote . langdiv $ (bs <> citepar)
inlineCommand' :: PandocMonad m => LP m Inlines
inlineCommand' :: forall (m :: * -> *). PandocMonad m => LP m (Many Inline)
inlineCommand' = ParsecT TokStream LaTeXState m (Many Inline)
-> ParsecT TokStream LaTeXState m (Many Inline)
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try (ParsecT TokStream LaTeXState m (Many Inline)
-> ParsecT TokStream LaTeXState m (Many Inline))
-> ParsecT TokStream LaTeXState m (Many Inline)
-> ParsecT TokStream LaTeXState m (Many Inline)
forall a b. (a -> b) -> a -> b
$ do
Tok _ (CtrlSeq name) cmd <- LP m Tok
forall (m :: * -> *). PandocMonad m => LP m Tok
anyControlSeq
guard $ name /= "begin" && name /= "end" && name /= "and"
star <- if T.all isAlphaNum name
then option "" ("*" <$ symbol '*' <* sp)
else pure ""
overlay <- option "" overlaySpecification
let name' = Text
name Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
star Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
overlay
let names = [Text] -> [Text]
forall a. Ord a => [a] -> [a]
nubOrd [Text
name', Text
name]
let raw = do
Bool -> ParsecT TokStream LaTeXState m ()
forall (f :: * -> *). Alternative f => Bool -> f ()
guard (Bool -> ParsecT TokStream LaTeXState m ())
-> Bool -> ParsecT TokStream LaTeXState m ()
forall a b. (a -> b) -> a -> b
$ Text -> Bool
isInlineCommand Text
name Bool -> Bool -> Bool
|| Bool -> Bool
not (Text -> Bool
isBlockCommand Text
name)
rawcommand <- Text -> Text -> ParsecT TokStream LaTeXState m Text
forall (m :: * -> *). PandocMonad m => Text -> Text -> LP m Text
getRawCommand Text
name (Text
cmd Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
star)
(guardEnabled Ext_raw_tex >> return (rawInline "latex" rawcommand))
<|> ignore rawcommand
lookupListDefault raw names inlineCommands
tok :: PandocMonad m => LP m Inlines
tok :: forall (m :: * -> *). PandocMonad m => LP m (Many Inline)
tok = LP m (Many Inline) -> LP m (Many Inline)
forall (m :: * -> *).
PandocMonad m =>
LP m (Many Inline) -> LP m (Many Inline)
tokWith LP m (Many Inline)
forall (m :: * -> *). PandocMonad m => LP m (Many Inline)
inline
unescapeURL :: Text -> Text
unescapeURL :: Text -> Text
unescapeURL = [Text] -> Text
T.concat ([Text] -> Text) -> (Text -> [Text]) -> Text -> Text
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [Text] -> [Text]
go ([Text] -> [Text]) -> (Text -> [Text]) -> Text -> [Text]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. HasCallStack => Text -> Text -> [Text]
Text -> Text -> [Text]
T.splitOn Text
"\\"
where
isEscapable :: Char -> Bool
isEscapable Char
c = (Char -> Bool) -> Text -> Bool
T.any (Char -> Char -> Bool
forall a. Eq a => a -> a -> Bool
== Char
c) Text
"#$%&~_^\\{}"
go :: [Text] -> [Text]
go (Text
x:[Text]
xs) = Text
x Text -> [Text] -> [Text]
forall a. a -> [a] -> [a]
: (Text -> Text) -> [Text] -> [Text]
forall a b. (a -> b) -> [a] -> [b]
map Text -> Text
unescapeInterior [Text]
xs
go [] = []
unescapeInterior :: Text -> Text
unescapeInterior Text
t
| Just (Char
c, Text
_) <- Text -> Maybe (Char, Text)
T.uncons Text
t
, Char -> Bool
isEscapable Char
c = Text
t
| Bool
otherwise = Text
"\\" Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
t
inlineCommands :: PandocMonad m => M.Map Text (LP m Inlines)
inlineCommands :: forall (m :: * -> *).
PandocMonad m =>
Map Text (LP m (Many Inline))
inlineCommands = [Map Text (LP m (Many Inline))] -> Map Text (LP m (Many Inline))
forall (f :: * -> *) k a.
(Foldable f, Ord k) =>
f (Map k a) -> Map k a
M.unions
[ LP m (Many Inline) -> Map Text (LP m (Many Inline))
forall (m :: * -> *).
PandocMonad m =>
LP m (Many Inline) -> Map Text (LP m (Many Inline))
accentCommands LP m (Many Inline)
forall (m :: * -> *). PandocMonad m => LP m (Many Inline)
tok
, Map Text (LP m (Many Inline))
forall (m :: * -> *).
PandocMonad m =>
Map Text (LP m (Many Inline))
miscCommands
, LP m (Many Inline) -> Map Text (LP m (Many Inline))
forall (m :: * -> *).
PandocMonad m =>
LP m (Many Inline) -> Map Text (LP m (Many Inline))
citationCommands LP m (Many Inline)
forall (m :: * -> *). PandocMonad m => LP m (Many Inline)
inline
, LP m (Many Inline) -> Map Text (LP m (Many Inline))
forall (m :: * -> *).
PandocMonad m =>
LP m (Many Inline) -> Map Text (LP m (Many Inline))
siunitxCommands LP m (Many Inline)
forall (m :: * -> *). PandocMonad m => LP m (Many Inline)
tok
, Map Text (LP m (Many Inline))
forall (m :: * -> *).
PandocMonad m =>
Map Text (LP m (Many Inline))
acronymCommands
, Map Text (LP m (Many Inline))
forall (m :: * -> *).
PandocMonad m =>
Map Text (LP m (Many Inline))
refCommands
, Map Text (LP m (Many Inline))
forall (m :: * -> *).
PandocMonad m =>
Map Text (LP m (Many Inline))
nameCommands
, Map Text (LP m (Many Inline))
forall (m :: * -> *).
PandocMonad m =>
Map Text (LP m (Many Inline))
verbCommands
, Map Text (LP m (Many Inline))
forall (m :: * -> *).
PandocMonad m =>
Map Text (LP m (Many Inline))
charCommands
, LP m (Many Inline) -> Map Text (LP m (Many Inline))
forall (m :: * -> *).
PandocMonad m =>
LP m (Many Inline) -> Map Text (LP m (Many Inline))
enquoteCommands LP m (Many Inline)
forall (m :: * -> *). PandocMonad m => LP m (Many Inline)
tok
, LP m (Many Inline) -> Map Text (LP m (Many Inline))
forall (m :: * -> *).
PandocMonad m =>
LP m (Many Inline) -> Map Text (LP m (Many Inline))
inlineLanguageCommands LP m (Many Inline)
forall (m :: * -> *). PandocMonad m => LP m (Many Inline)
tok
, LP m (Many Inline) -> Map Text (LP m (Many Inline))
forall (m :: * -> *).
PandocMonad m =>
LP m (Many Inline) -> Map Text (LP m (Many Inline))
biblatexInlineCommands LP m (Many Inline)
forall (m :: * -> *). PandocMonad m => LP m (Many Inline)
tok
, Map Text (LP m (Many Inline))
rest ]
where
disableLigatures :: ParsecT s LaTeXState m b -> ParsecT s LaTeXState m b
disableLigatures ParsecT s LaTeXState m b
p = do
oldLigatures <- LaTeXState -> Bool
sLigatures (LaTeXState -> Bool)
-> ParsecT s LaTeXState m LaTeXState -> ParsecT s LaTeXState m Bool
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ParsecT s LaTeXState m LaTeXState
forall (m :: * -> *) s u. Monad m => ParsecT s u m u
getState
updateState (\LaTeXState
s -> LaTeXState
s{ sLigatures = False })
res <- p
updateState (\LaTeXState
s -> LaTeXState
s{ sLigatures = oldLigatures })
pure res
rest :: Map Text (LP m (Many Inline))
rest = [(Text, LP m (Many Inline))] -> Map Text (LP m (Many Inline))
forall k a. Ord k => [(k, a)] -> Map k a
M.fromList
[ (Text
"emph", (Many Inline -> Many Inline) -> Many Inline -> Many Inline
extractSpaces Many Inline -> Many Inline
emph (Many Inline -> Many Inline)
-> LP m (Many Inline) -> LP m (Many Inline)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> LP m (Many Inline)
forall (m :: * -> *). PandocMonad m => LP m (Many Inline)
tok)
, (Text
"textit", (Many Inline -> Many Inline) -> Many Inline -> Many Inline
extractSpaces Many Inline -> Many Inline
emph (Many Inline -> Many Inline)
-> LP m (Many Inline) -> LP m (Many Inline)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> LP m (Many Inline)
forall (m :: * -> *). PandocMonad m => LP m (Many Inline)
tok)
, (Text
"textsl", (Many Inline -> Many Inline) -> Many Inline -> Many Inline
extractSpaces Many Inline -> Many Inline
emph (Many Inline -> Many Inline)
-> LP m (Many Inline) -> LP m (Many Inline)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> LP m (Many Inline)
forall (m :: * -> *). PandocMonad m => LP m (Many Inline)
tok)
, (Text
"textsc", (Many Inline -> Many Inline) -> Many Inline -> Many Inline
extractSpaces Many Inline -> Many Inline
smallcaps (Many Inline -> Many Inline)
-> LP m (Many Inline) -> LP m (Many Inline)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> LP m (Many Inline)
forall (m :: * -> *). PandocMonad m => LP m (Many Inline)
tok)
, (Text
"textsf", (Many Inline -> Many Inline) -> Many Inline -> Many Inline
extractSpaces (Attr -> Many Inline -> Many Inline
spanWith (Text
"",[Text
"sans-serif"],[])) (Many Inline -> Many Inline)
-> LP m (Many Inline) -> LP m (Many Inline)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> LP m (Many Inline)
forall (m :: * -> *). PandocMonad m => LP m (Many Inline)
tok)
, (Text
"textmd", (Many Inline -> Many Inline) -> Many Inline -> Many Inline
extractSpaces (Attr -> Many Inline -> Many Inline
spanWith (Text
"",[Text
"medium"],[])) (Many Inline -> Many Inline)
-> LP m (Many Inline) -> LP m (Many Inline)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> LP m (Many Inline)
forall (m :: * -> *). PandocMonad m => LP m (Many Inline)
tok)
, (Text
"textrm", (Many Inline -> Many Inline) -> Many Inline -> Many Inline
extractSpaces (Attr -> Many Inline -> Many Inline
spanWith (Text
"",[Text
"roman"],[])) (Many Inline -> Many Inline)
-> LP m (Many Inline) -> LP m (Many Inline)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> LP m (Many Inline)
forall (m :: * -> *). PandocMonad m => LP m (Many Inline)
tok)
, (Text
"textup", (Many Inline -> Many Inline) -> Many Inline -> Many Inline
extractSpaces (Attr -> Many Inline -> Many Inline
spanWith (Text
"",[Text
"upright"],[])) (Many Inline -> Many Inline)
-> LP m (Many Inline) -> LP m (Many Inline)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> LP m (Many Inline)
forall (m :: * -> *). PandocMonad m => LP m (Many Inline)
tok)
, (Text
"texttt", Attr -> Many Inline -> Many Inline
formatCode Attr
nullAttr (Many Inline -> Many Inline)
-> LP m (Many Inline) -> LP m (Many Inline)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> LP m (Many Inline) -> LP m (Many Inline)
forall {m :: * -> *} {s} {b}.
Monad m =>
ParsecT s LaTeXState m b -> ParsecT s LaTeXState m b
disableLigatures LP m (Many Inline)
forall (m :: * -> *). PandocMonad m => LP m (Many Inline)
tok)
, (Text
"alert", LP m ()
forall (m :: * -> *). PandocMonad m => LP m ()
skipopts LP m () -> LP m (Many Inline) -> LP m (Many Inline)
forall a b.
ParsecT TokStream LaTeXState m a
-> ParsecT TokStream LaTeXState m b
-> ParsecT TokStream LaTeXState m b
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> Attr -> Many Inline -> Many Inline
spanWith (Text
"",[Text
"alert"],[]) (Many Inline -> Many Inline)
-> LP m (Many Inline) -> LP m (Many Inline)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> LP m (Many Inline)
forall (m :: * -> *). PandocMonad m => LP m (Many Inline)
tok)
, (Text
"textsuperscript", (Many Inline -> Many Inline) -> Many Inline -> Many Inline
extractSpaces Many Inline -> Many Inline
superscript (Many Inline -> Many Inline)
-> LP m (Many Inline) -> LP m (Many Inline)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> LP m (Many Inline)
forall (m :: * -> *). PandocMonad m => LP m (Many Inline)
tok)
, (Text
"textsubscript", (Many Inline -> Many Inline) -> Many Inline -> Many Inline
extractSpaces Many Inline -> Many Inline
subscript (Many Inline -> Many Inline)
-> LP m (Many Inline) -> LP m (Many Inline)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> LP m (Many Inline)
forall (m :: * -> *). PandocMonad m => LP m (Many Inline)
tok)
, (Text
"textbf", (Many Inline -> Many Inline) -> Many Inline -> Many Inline
extractSpaces Many Inline -> Many Inline
strong (Many Inline -> Many Inline)
-> LP m (Many Inline) -> LP m (Many Inline)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> LP m (Many Inline)
forall (m :: * -> *). PandocMonad m => LP m (Many Inline)
tok)
, (Text
"textnormal", (Many Inline -> Many Inline) -> Many Inline -> Many Inline
extractSpaces (Attr -> Many Inline -> Many Inline
spanWith (Text
"",[Text
"nodecor"],[])) (Many Inline -> Many Inline)
-> LP m (Many Inline) -> LP m (Many Inline)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> LP m (Many Inline)
forall (m :: * -> *). PandocMonad m => LP m (Many Inline)
tok)
, (Text
"underline", Many Inline -> Many Inline
underline (Many Inline -> Many Inline)
-> LP m (Many Inline) -> LP m (Many Inline)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> LP m (Many Inline)
forall (m :: * -> *). PandocMonad m => LP m (Many Inline)
tok)
, (Text
"mbox", Text -> LP m (Many Inline) -> LP m (Many Inline)
forall (m :: * -> *).
PandocMonad m =>
Text -> LP m (Many Inline) -> LP m (Many Inline)
rawInlineOr Text
"mbox" (LP m (Many Inline) -> LP m (Many Inline))
-> LP m (Many Inline) -> LP m (Many Inline)
forall a b. (a -> b) -> a -> b
$ Many Inline -> Many Inline
processHBox (Many Inline -> Many Inline)
-> LP m (Many Inline) -> LP m (Many Inline)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> LP m (Many Inline)
forall (m :: * -> *). PandocMonad m => LP m (Many Inline)
tok)
, (Text
"hbox", Text -> LP m (Many Inline) -> LP m (Many Inline)
forall (m :: * -> *).
PandocMonad m =>
Text -> LP m (Many Inline) -> LP m (Many Inline)
rawInlineOr Text
"hbox" (LP m (Many Inline) -> LP m (Many Inline))
-> LP m (Many Inline) -> LP m (Many Inline)
forall a b. (a -> b) -> a -> b
$ Many Inline -> Many Inline
processHBox (Many Inline -> Many Inline)
-> LP m (Many Inline) -> LP m (Many Inline)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> LP m (Many Inline)
forall (m :: * -> *). PandocMonad m => LP m (Many Inline)
tok)
, (Text
"vbox", Text -> LP m (Many Inline) -> LP m (Many Inline)
forall (m :: * -> *).
PandocMonad m =>
Text -> LP m (Many Inline) -> LP m (Many Inline)
rawInlineOr Text
"vbox" LP m (Many Inline)
forall (m :: * -> *). PandocMonad m => LP m (Many Inline)
tok)
, (Text
"lettrine", Text -> LP m (Many Inline) -> LP m (Many Inline)
forall (m :: * -> *).
PandocMonad m =>
Text -> LP m (Many Inline) -> LP m (Many Inline)
rawInlineOr Text
"lettrine" LP m (Many Inline)
forall (m :: * -> *). PandocMonad m => LP m (Many Inline)
lettrine)
, (Text
"(", LP m (Many Inline) -> LP m (Many Inline)
forall (m :: * -> *) a. PandocMonad m => LP m a -> LP m a
withMathMode
(Text -> Many Inline
mathInline (Text -> Many Inline) -> ([Tok] -> Text) -> [Tok] -> Many Inline
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [Tok] -> Text
untokenize ([Tok] -> Many Inline)
-> ParsecT TokStream LaTeXState m [Tok] -> LP m (Many Inline)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ParsecT TokStream LaTeXState m Tok
-> ParsecT TokStream LaTeXState m Tok
-> ParsecT TokStream LaTeXState m [Tok]
forall s (m :: * -> *) t u a end.
Stream s m t =>
ParsecT s u m a -> ParsecT s u m end -> ParsecT s u m [a]
manyTill ParsecT TokStream LaTeXState m Tok
forall (m :: * -> *). PandocMonad m => LP m Tok
anyTok (Text -> ParsecT TokStream LaTeXState m Tok
forall (m :: * -> *). PandocMonad m => Text -> LP m Tok
controlSeq Text
")")))
, (Text
"[", LP m (Many Inline) -> LP m (Many Inline)
forall (m :: * -> *) a. PandocMonad m => LP m a -> LP m a
withMathMode
(Text -> Many Inline
mathDisplay (Text -> Many Inline) -> ([Tok] -> Text) -> [Tok] -> Many Inline
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [Tok] -> Text
untokenize ([Tok] -> Many Inline)
-> ParsecT TokStream LaTeXState m [Tok] -> LP m (Many Inline)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ParsecT TokStream LaTeXState m Tok
-> ParsecT TokStream LaTeXState m Tok
-> ParsecT TokStream LaTeXState m [Tok]
forall s (m :: * -> *) t u a end.
Stream s m t =>
ParsecT s u m a -> ParsecT s u m end -> ParsecT s u m [a]
manyTill ParsecT TokStream LaTeXState m Tok
forall (m :: * -> *). PandocMonad m => LP m Tok
anyTok (Text -> ParsecT TokStream LaTeXState m Tok
forall (m :: * -> *). PandocMonad m => Text -> LP m Tok
controlSeq Text
"]")))
, (Text
"ensuremath", LP m (Many Inline) -> LP m (Many Inline)
forall (m :: * -> *) a. PandocMonad m => LP m a -> LP m a
withMathMode (Text -> Many Inline
mathInline (Text -> Many Inline) -> ([Tok] -> Text) -> [Tok] -> Many Inline
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [Tok] -> Text
untokenize ([Tok] -> Many Inline)
-> ParsecT TokStream LaTeXState m [Tok] -> LP m (Many Inline)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ParsecT TokStream LaTeXState m [Tok]
forall (m :: * -> *). PandocMonad m => LP m [Tok]
braced))
, (Text
"texorpdfstring", Many Inline -> Many Inline -> Many Inline
forall a b. a -> b -> a
const (Many Inline -> Many Inline -> Many Inline)
-> LP m (Many Inline)
-> ParsecT TokStream LaTeXState m (Many Inline -> Many Inline)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> LP m (Many Inline)
forall (m :: * -> *). PandocMonad m => LP m (Many Inline)
tok ParsecT TokStream LaTeXState m (Many Inline -> Many Inline)
-> LP m (Many Inline) -> LP m (Many Inline)
forall a b.
ParsecT TokStream LaTeXState m (a -> b)
-> ParsecT TokStream LaTeXState m a
-> ParsecT TokStream LaTeXState m b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> LP m (Many Inline)
forall (m :: * -> *). PandocMonad m => LP m (Many Inline)
tok)
, (Text
"em", (Many Inline -> Many Inline) -> Many Inline -> Many Inline
extractSpaces Many Inline -> Many Inline
emph (Many Inline -> Many Inline)
-> LP m (Many Inline) -> LP m (Many Inline)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> LP m (Many Inline)
forall (m :: * -> *). PandocMonad m => LP m (Many Inline)
inlines)
, (Text
"it", (Many Inline -> Many Inline) -> Many Inline -> Many Inline
extractSpaces Many Inline -> Many Inline
emph (Many Inline -> Many Inline)
-> LP m (Many Inline) -> LP m (Many Inline)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> LP m (Many Inline)
forall (m :: * -> *). PandocMonad m => LP m (Many Inline)
inlines)
, (Text
"sl", (Many Inline -> Many Inline) -> Many Inline -> Many Inline
extractSpaces Many Inline -> Many Inline
emph (Many Inline -> Many Inline)
-> LP m (Many Inline) -> LP m (Many Inline)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> LP m (Many Inline)
forall (m :: * -> *). PandocMonad m => LP m (Many Inline)
inlines)
, (Text
"bf", (Many Inline -> Many Inline) -> Many Inline -> Many Inline
extractSpaces Many Inline -> Many Inline
strong (Many Inline -> Many Inline)
-> LP m (Many Inline) -> LP m (Many Inline)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> LP m (Many Inline)
forall (m :: * -> *). PandocMonad m => LP m (Many Inline)
inlines)
, (Text
"tt", Attr -> Many Inline -> Many Inline
formatCode Attr
nullAttr (Many Inline -> Many Inline)
-> LP m (Many Inline) -> LP m (Many Inline)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> LP m (Many Inline)
forall (m :: * -> *). PandocMonad m => LP m (Many Inline)
inlines)
, (Text
"rm", LP m (Many Inline)
forall (m :: * -> *). PandocMonad m => LP m (Many Inline)
inlines)
, (Text
"itshape", (Many Inline -> Many Inline) -> Many Inline -> Many Inline
extractSpaces Many Inline -> Many Inline
emph (Many Inline -> Many Inline)
-> LP m (Many Inline) -> LP m (Many Inline)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> LP m (Many Inline)
forall (m :: * -> *). PandocMonad m => LP m (Many Inline)
inlines)
, (Text
"slshape", (Many Inline -> Many Inline) -> Many Inline -> Many Inline
extractSpaces Many Inline -> Many Inline
emph (Many Inline -> Many Inline)
-> LP m (Many Inline) -> LP m (Many Inline)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> LP m (Many Inline)
forall (m :: * -> *). PandocMonad m => LP m (Many Inline)
inlines)
, (Text
"scshape", (Many Inline -> Many Inline) -> Many Inline -> Many Inline
extractSpaces Many Inline -> Many Inline
smallcaps (Many Inline -> Many Inline)
-> LP m (Many Inline) -> LP m (Many Inline)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> LP m (Many Inline)
forall (m :: * -> *). PandocMonad m => LP m (Many Inline)
inlines)
, (Text
"bfseries", (Many Inline -> Many Inline) -> Many Inline -> Many Inline
extractSpaces Many Inline -> Many Inline
strong (Many Inline -> Many Inline)
-> LP m (Many Inline) -> LP m (Many Inline)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> LP m (Many Inline)
forall (m :: * -> *). PandocMonad m => LP m (Many Inline)
inlines)
, (Text
"MakeUppercase", Many Inline -> Many Inline
makeUppercase (Many Inline -> Many Inline)
-> LP m (Many Inline) -> LP m (Many Inline)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> LP m (Many Inline)
forall (m :: * -> *). PandocMonad m => LP m (Many Inline)
tok)
, (Text
"MakeTextUppercase", Many Inline -> Many Inline
makeUppercase (Many Inline -> Many Inline)
-> LP m (Many Inline) -> LP m (Many Inline)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> LP m (Many Inline)
forall (m :: * -> *). PandocMonad m => LP m (Many Inline)
tok)
, (Text
"uppercase", Many Inline -> Many Inline
makeUppercase (Many Inline -> Many Inline)
-> LP m (Many Inline) -> LP m (Many Inline)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> LP m (Many Inline)
forall (m :: * -> *). PandocMonad m => LP m (Many Inline)
tok)
, (Text
"MakeLowercase", Many Inline -> Many Inline
makeLowercase (Many Inline -> Many Inline)
-> LP m (Many Inline) -> LP m (Many Inline)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> LP m (Many Inline)
forall (m :: * -> *). PandocMonad m => LP m (Many Inline)
tok)
, (Text
"MakeTextLowercase", Many Inline -> Many Inline
makeLowercase (Many Inline -> Many Inline)
-> LP m (Many Inline) -> LP m (Many Inline)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> LP m (Many Inline)
forall (m :: * -> *). PandocMonad m => LP m (Many Inline)
tok)
, (Text
"lowercase", Many Inline -> Many Inline
makeLowercase (Many Inline -> Many Inline)
-> LP m (Many Inline) -> LP m (Many Inline)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> LP m (Many Inline)
forall (m :: * -> *). PandocMonad m => LP m (Many Inline)
tok)
, (Text
"thanks", LP m ()
forall (m :: * -> *). PandocMonad m => LP m ()
skipopts LP m () -> LP m (Many Inline) -> LP m (Many Inline)
forall a b.
ParsecT TokStream LaTeXState m a
-> ParsecT TokStream LaTeXState m b
-> ParsecT TokStream LaTeXState m b
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> Many Block -> Many Inline
note (Many Block -> Many Inline)
-> ParsecT TokStream LaTeXState m (Many Block)
-> LP m (Many Inline)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ParsecT TokStream LaTeXState m (Many Block)
-> ParsecT TokStream LaTeXState m (Many Block)
forall (m :: * -> *) a.
(PandocMonad m, Monoid a) =>
LP m a -> LP m a
grouped ParsecT TokStream LaTeXState m (Many Block)
forall (m :: * -> *). PandocMonad m => LP m (Many Block)
block)
, (Text
"footnote", LP m ()
forall (m :: * -> *). PandocMonad m => LP m ()
skipopts LP m () -> LP m (Many Inline) -> LP m (Many Inline)
forall a b.
ParsecT TokStream LaTeXState m a
-> ParsecT TokStream LaTeXState m b
-> ParsecT TokStream LaTeXState m b
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> LP m (Many Inline)
forall (m :: * -> *). PandocMonad m => LP m (Many Inline)
footnote)
, (Text
"footnotemark", LP m (Many Inline)
forall (m :: * -> *). PandocMonad m => LP m (Many Inline)
footnotemark)
, (Text
"footnotetext", LP m (Many Inline)
forall (m :: * -> *). PandocMonad m => LP m (Many Inline)
footnotetext)
, (Text
"newline", Many Inline -> LP m (Many Inline)
forall a. a -> ParsecT TokStream LaTeXState m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure Many Inline
B.linebreak)
, (Text
"passthrough", Many Inline -> Many Inline
fixPassthroughEscapes (Many Inline -> Many Inline)
-> LP m (Many Inline) -> LP m (Many Inline)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> LP m (Many Inline)
forall (m :: * -> *). PandocMonad m => LP m (Many Inline)
tok)
, (Text
"includegraphics", do options <- [(Text, Text)]
-> ParsecT TokStream LaTeXState m [(Text, Text)]
-> ParsecT TokStream LaTeXState m [(Text, Text)]
forall s (m :: * -> *) t a u.
Stream s m t =>
a -> ParsecT s u m a -> ParsecT s u m a
option [] ParsecT TokStream LaTeXState m [(Text, Text)]
forall (m :: * -> *). PandocMonad m => LP m [(Text, Text)]
keyvals
src <- bracedFilename
mkImage options . unescapeURL $ src)
, (Text
"includesvg", do options <- [(Text, Text)]
-> ParsecT TokStream LaTeXState m [(Text, Text)]
-> ParsecT TokStream LaTeXState m [(Text, Text)]
forall s (m :: * -> *) t a u.
Stream s m t =>
a -> ParsecT s u m a -> ParsecT s u m a
option [] ParsecT TokStream LaTeXState m [(Text, Text)]
forall (m :: * -> *). PandocMonad m => LP m [(Text, Text)]
keyvals
src <- bracedFilename
mkImage options . unescapeURL $ src)
, (Text
"url", (\Text
url -> Attr -> Text -> Text -> Many Inline -> Many Inline
linkWith (Text
"",[Text
"uri"],[]) Text
url Text
"" (Text -> Many Inline
str Text
url))
(Text -> Many Inline) -> ([Tok] -> Text) -> [Tok] -> Many Inline
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Text -> Text
unescapeURL (Text -> Text) -> ([Tok] -> Text) -> [Tok] -> Text
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [Tok] -> Text
untokenize ([Tok] -> Many Inline)
-> ParsecT TokStream LaTeXState m [Tok] -> LP m (Many Inline)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ParsecT TokStream LaTeXState m [Tok]
forall (m :: * -> *). PandocMonad m => LP m [Tok]
bracedUrl)
, (Text
"nolinkurl", Text -> Many Inline
code (Text -> Many Inline) -> ([Tok] -> Text) -> [Tok] -> Many Inline
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Text -> Text
unescapeURL (Text -> Text) -> ([Tok] -> Text) -> [Tok] -> Text
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [Tok] -> Text
untokenize ([Tok] -> Many Inline)
-> ParsecT TokStream LaTeXState m [Tok] -> LP m (Many Inline)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ParsecT TokStream LaTeXState m [Tok]
forall (m :: * -> *). PandocMonad m => LP m [Tok]
bracedUrl)
, (Text
"href", do url <- ParsecT TokStream LaTeXState m [Tok]
forall (m :: * -> *). PandocMonad m => LP m [Tok]
bracedUrl
sp
link (unescapeURL $ untokenize url) "" <$> tok)
, (Text
"hyperlink", LP m (Many Inline)
forall (m :: * -> *). PandocMonad m => LP m (Many Inline)
hyperlink)
, (Text
"hyperref", LP m (Many Inline)
forall (m :: * -> *). PandocMonad m => LP m (Many Inline)
hyperref)
, (Text
"hypertarget", LP m (Many Inline)
forall (m :: * -> *). PandocMonad m => LP m (Many Inline)
hypertargetInline)
, (Text
"nohyphens", LP m (Many Inline)
forall (m :: * -> *). PandocMonad m => LP m (Many Inline)
tok)
, (Text
"textnhtt", Attr -> Many Inline -> Many Inline
formatCode Attr
nullAttr (Many Inline -> Many Inline)
-> LP m (Many Inline) -> LP m (Many Inline)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> LP m (Many Inline)
forall (m :: * -> *). PandocMonad m => LP m (Many Inline)
tok)
, (Text
"nhttfamily", Attr -> Many Inline -> Many Inline
formatCode Attr
nullAttr (Many Inline -> Many Inline)
-> LP m (Many Inline) -> LP m (Many Inline)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> LP m (Many Inline)
forall (m :: * -> *). PandocMonad m => LP m (Many Inline)
tok)
, (Text
"textcolor", Text -> LP m (Many Inline)
forall (m :: * -> *). PandocMonad m => Text -> LP m (Many Inline)
coloredInline Text
"color")
, (Text
"colorbox", Text -> LP m (Many Inline)
forall (m :: * -> *). PandocMonad m => Text -> LP m (Many Inline)
coloredInline Text
"background-color")
, (Text
"newtoggle", ParsecT TokStream LaTeXState m [Tok]
forall (m :: * -> *). PandocMonad m => LP m [Tok]
braced ParsecT TokStream LaTeXState m [Tok]
-> ([Tok] -> LP m (Many Inline)) -> LP m (Many Inline)
forall a b.
ParsecT TokStream LaTeXState m a
-> (a -> ParsecT TokStream LaTeXState m b)
-> ParsecT TokStream LaTeXState m b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= [Tok] -> LP m (Many Inline)
forall a (m :: * -> *).
(Monoid a, PandocMonad m) =>
[Tok] -> LP m a
newToggle)
, (Text
"toggletrue", ParsecT TokStream LaTeXState m [Tok]
forall (m :: * -> *). PandocMonad m => LP m [Tok]
braced ParsecT TokStream LaTeXState m [Tok]
-> ([Tok] -> LP m (Many Inline)) -> LP m (Many Inline)
forall a b.
ParsecT TokStream LaTeXState m a
-> (a -> ParsecT TokStream LaTeXState m b)
-> ParsecT TokStream LaTeXState m b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= Bool -> [Tok] -> LP m (Many Inline)
forall a (m :: * -> *).
(Monoid a, PandocMonad m) =>
Bool -> [Tok] -> LP m a
setToggle Bool
True)
, (Text
"togglefalse", ParsecT TokStream LaTeXState m [Tok]
forall (m :: * -> *). PandocMonad m => LP m [Tok]
braced ParsecT TokStream LaTeXState m [Tok]
-> ([Tok] -> LP m (Many Inline)) -> LP m (Many Inline)
forall a b.
ParsecT TokStream LaTeXState m a
-> (a -> ParsecT TokStream LaTeXState m b)
-> ParsecT TokStream LaTeXState m b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= Bool -> [Tok] -> LP m (Many Inline)
forall a (m :: * -> *).
(Monoid a, PandocMonad m) =>
Bool -> [Tok] -> LP m a
setToggle Bool
False)
, (Text
"iftoggle", LP m (Many Inline) -> LP m (Many Inline)
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try (LP m (Many Inline) -> LP m (Many Inline))
-> LP m (Many Inline) -> LP m (Many Inline)
forall a b. (a -> b) -> a -> b
$ LP m ()
forall (m :: * -> *). PandocMonad m => LP m ()
ifToggle LP m () -> LP m (Many Inline) -> LP m (Many Inline)
forall a b.
ParsecT TokStream LaTeXState m a
-> ParsecT TokStream LaTeXState m b
-> ParsecT TokStream LaTeXState m b
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> LP m (Many Inline)
forall (m :: * -> *). PandocMonad m => LP m (Many Inline)
inline)
, (Text
"input", Text -> LP m (Many Inline) -> LP m (Many Inline)
forall (m :: * -> *).
PandocMonad m =>
Text -> LP m (Many Inline) -> LP m (Many Inline)
rawInlineOr Text
"input" (LP m (Many Inline) -> LP m (Many Inline))
-> LP m (Many Inline) -> LP m (Many Inline)
forall a b. (a -> b) -> a -> b
$ Text -> LP m (Many Inline)
forall (m :: * -> *) a. (PandocMonad m, Monoid a) => Text -> LP m a
include Text
"input")
, (Text
"st", (Many Inline -> Many Inline) -> Many Inline -> Many Inline
extractSpaces Many Inline -> Many Inline
strikeout (Many Inline -> Many Inline)
-> LP m (Many Inline) -> LP m (Many Inline)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> LP m (Many Inline)
forall (m :: * -> *). PandocMonad m => LP m (Many Inline)
tok)
, (Text
"ul", Many Inline -> Many Inline
underline (Many Inline -> Many Inline)
-> LP m (Many Inline) -> LP m (Many Inline)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> LP m (Many Inline)
forall (m :: * -> *). PandocMonad m => LP m (Many Inline)
tok)
, (Text
"hl", (Many Inline -> Many Inline) -> Many Inline -> Many Inline
extractSpaces (Attr -> Many Inline -> Many Inline
spanWith (Text
"",[Text
"mark"],[])) (Many Inline -> Many Inline)
-> LP m (Many Inline) -> LP m (Many Inline)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> LP m (Many Inline)
forall (m :: * -> *). PandocMonad m => LP m (Many Inline)
tok)
, (Text
"sout", (Many Inline -> Many Inline) -> Many Inline -> Many Inline
extractSpaces Many Inline -> Many Inline
strikeout (Many Inline -> Many Inline)
-> LP m (Many Inline) -> LP m (Many Inline)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> LP m (Many Inline)
forall (m :: * -> *). PandocMonad m => LP m (Many Inline)
tok)
, (Text
"uline", Many Inline -> Many Inline
underline (Many Inline -> Many Inline)
-> LP m (Many Inline) -> LP m (Many Inline)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> LP m (Many Inline)
forall (m :: * -> *). PandocMonad m => LP m (Many Inline)
tok)
, (Text
"ifdim", LP m (Many Inline)
forall (m :: * -> *). PandocMonad m => LP m (Many Inline)
ifdim)
, (Text
"today", LP m (Many Inline)
forall (m :: * -> *). PandocMonad m => LP m (Many Inline)
today)
, (Text
"pandocbounded", LP m (Many Inline)
forall (m :: * -> *). PandocMonad m => LP m (Many Inline)
tok)
]
bracedFilename :: PandocMonad m => LP m Text
bracedFilename :: forall (m :: * -> *). PandocMonad m => LP m Text
bracedFilename =
Text -> Text
removeDoubleQuotes (Text -> Text) -> ([Tok] -> Text) -> [Tok] -> Text
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Text -> Text
T.strip (Text -> Text) -> ([Tok] -> Text) -> [Tok] -> Text
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [Tok] -> Text
untokenize ([Tok] -> Text) -> ([Tok] -> [Tok]) -> [Tok] -> Text
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Tok -> Bool) -> [Tok] -> [Tok]
forall a. (a -> Bool) -> [a] -> [a]
filter (Bool -> Bool
not (Bool -> Bool) -> (Tok -> Bool) -> Tok -> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Tok -> Bool
isComment) ([Tok] -> Text)
-> ParsecT TokStream LaTeXState m [Tok]
-> ParsecT TokStream LaTeXState m Text
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ParsecT TokStream LaTeXState m [Tok]
forall (m :: * -> *). PandocMonad m => LP m [Tok]
braced
isComment :: Tok -> Bool
(Tok SourcePos
_ TokType
Comment Text
_) = Bool
True
isComment Tok
_ = Bool
False
today :: PandocMonad m => LP m Inlines
today :: forall (m :: * -> *). PandocMonad m => LP m (Many Inline)
today =
Text -> Many Inline
text (Text -> Many Inline)
-> (ZonedTime -> Text) -> ZonedTime -> Many Inline
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [Char] -> Text
T.pack ([Char] -> Text) -> (ZonedTime -> [Char]) -> ZonedTime -> Text
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Day -> [Char]
showGregorian (Day -> [Char]) -> (ZonedTime -> Day) -> ZonedTime -> [Char]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. LocalTime -> Day
localDay (LocalTime -> Day) -> (ZonedTime -> LocalTime) -> ZonedTime -> Day
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ZonedTime -> LocalTime
zonedTimeToLocalTime
(ZonedTime -> Many Inline)
-> ParsecT TokStream LaTeXState m ZonedTime
-> ParsecT TokStream LaTeXState m (Many Inline)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ParsecT TokStream LaTeXState m ZonedTime
forall (m :: * -> *). PandocMonad m => m ZonedTime
getZonedTime
footnote :: PandocMonad m => LP m Inlines
= do
(LaTeXState -> LaTeXState) -> ParsecT TokStream LaTeXState m ()
forall (m :: * -> *) u s. Monad m => (u -> u) -> ParsecT s u m ()
updateState ((LaTeXState -> LaTeXState) -> ParsecT TokStream LaTeXState m ())
-> (LaTeXState -> LaTeXState) -> ParsecT TokStream LaTeXState m ()
forall a b. (a -> b) -> a -> b
$ \LaTeXState
st -> LaTeXState
st{ sLastNoteNum = sLastNoteNum st + 1 }
contents <- LP m (Many Block) -> LP m (Many Block)
forall (m :: * -> *) a.
(PandocMonad m, Monoid a) =>
LP m a -> LP m a
grouped LP m (Many Block)
forall (m :: * -> *). PandocMonad m => LP m (Many Block)
block LP m (Many Block)
-> (Many Block -> LP m (Many Block)) -> LP m (Many Block)
forall a b.
ParsecT TokStream LaTeXState m a
-> (a -> ParsecT TokStream LaTeXState m b)
-> ParsecT TokStream LaTeXState m b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= (Inline -> ParsecT TokStream LaTeXState m Inline)
-> Many Block -> LP m (Many Block)
forall a b (m :: * -> *).
(Walkable a b, Monad m, Applicative m, Functor m) =>
(a -> m a) -> b -> m b
forall (m :: * -> *).
(Monad m, Applicative m, Functor m) =>
(Inline -> m Inline) -> Many Block -> m (Many Block)
walkM Inline -> ParsecT TokStream LaTeXState m Inline
forall (m :: * -> *). PandocMonad m => Inline -> LP m Inline
resolveNoteLabel
return $ note contents
footnotemark :: PandocMonad m => LP m Inlines
= do
mbNum <- LP m (Maybe Int)
forall (m :: * -> *). PandocMonad m => LP m (Maybe Int)
optionalFootnoteNum
noteNum <- case mbNum of
Just Int
n -> Int -> ParsecT TokStream LaTeXState m Int
forall a. a -> ParsecT TokStream LaTeXState m a
forall (m :: * -> *) a. Monad m => a -> m a
return Int
n
Maybe Int
Nothing -> do
(LaTeXState -> LaTeXState) -> ParsecT TokStream LaTeXState m ()
forall (m :: * -> *) u s. Monad m => (u -> u) -> ParsecT s u m ()
updateState ((LaTeXState -> LaTeXState) -> ParsecT TokStream LaTeXState m ())
-> (LaTeXState -> LaTeXState) -> ParsecT TokStream LaTeXState m ()
forall a b. (a -> b) -> a -> b
$ \LaTeXState
st -> LaTeXState
st{ sLastNoteNum = sLastNoteNum st + 1 }
LaTeXState -> Int
sLastNoteNum (LaTeXState -> Int)
-> ParsecT TokStream LaTeXState m LaTeXState
-> ParsecT TokStream LaTeXState m Int
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ParsecT TokStream LaTeXState m LaTeXState
forall (m :: * -> *) s u. Monad m => ParsecT s u m u
getState
return $ B.spanWith ("", ["footnote-mark"], [("note-num", tshow noteNum)]) mempty
footnotetext :: PandocMonad m => LP m Inlines
= do
mbNum <- LP m (Maybe Int)
forall (m :: * -> *). PandocMonad m => LP m (Maybe Int)
optionalFootnoteNum
noteNum <- case mbNum of
Just Int
n -> Int -> ParsecT TokStream LaTeXState m Int
forall a. a -> ParsecT TokStream LaTeXState m a
forall (m :: * -> *) a. Monad m => a -> m a
return Int
n
Maybe Int
Nothing -> LaTeXState -> Int
sLastNoteNum (LaTeXState -> Int)
-> ParsecT TokStream LaTeXState m LaTeXState
-> ParsecT TokStream LaTeXState m Int
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ParsecT TokStream LaTeXState m LaTeXState
forall (m :: * -> *) s u. Monad m => ParsecT s u m u
getState
contents <- grouped block >>= walkM resolveNoteLabel
updateState $ \LaTeXState
st -> LaTeXState
st{
sFootnoteTexts = M.insert noteNum contents (sFootnoteTexts st) }
return mempty
optionalFootnoteNum :: PandocMonad m => LP m (Maybe Int)
= Maybe Int
-> ParsecT TokStream LaTeXState m (Maybe Int)
-> ParsecT TokStream LaTeXState m (Maybe Int)
forall s (m :: * -> *) t a u.
Stream s m t =>
a -> ParsecT s u m a -> ParsecT s u m a
option Maybe Int
forall a. Maybe a
Nothing (ParsecT TokStream LaTeXState m (Maybe Int)
-> ParsecT TokStream LaTeXState m (Maybe Int))
-> ParsecT TokStream LaTeXState m (Maybe Int)
-> ParsecT TokStream LaTeXState m (Maybe Int)
forall a b. (a -> b) -> a -> b
$ do
t <- LP m [Tok]
forall (m :: * -> *). PandocMonad m => LP m [Tok]
bracketedToks
case reads (T.unpack $ untokenize t) of
[(Int
n, [Char]
"")] -> Maybe Int -> ParsecT TokStream LaTeXState m (Maybe Int)
forall a. a -> ParsecT TokStream LaTeXState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (Maybe Int -> ParsecT TokStream LaTeXState m (Maybe Int))
-> Maybe Int -> ParsecT TokStream LaTeXState m (Maybe Int)
forall a b. (a -> b) -> a -> b
$ Int -> Maybe Int
forall a. a -> Maybe a
Just Int
n
[(Int, [Char])]
_ -> Maybe Int -> ParsecT TokStream LaTeXState m (Maybe Int)
forall a. a -> ParsecT TokStream LaTeXState m a
forall (m :: * -> *) a. Monad m => a -> m a
return Maybe Int
forall a. Maybe a
Nothing
resolveNoteLabel :: PandocMonad m => Inline -> LP m Inline
resolveNoteLabel :: forall (m :: * -> *). PandocMonad m => Inline -> LP m Inline
resolveNoteLabel (Span (Text
_,[Text]
cls,[(Text, Text)]
kvs) [Inline]
_)
| Just Text
lab <- Text -> [(Text, Text)] -> Maybe Text
forall a b. Eq a => a -> [(a, b)] -> Maybe b
lookup Text
"label" [(Text, Text)]
kvs = do
(LaTeXState -> LaTeXState) -> ParsecT TokStream LaTeXState m ()
forall (m :: * -> *) u s. Monad m => (u -> u) -> ParsecT s u m ()
updateState ((LaTeXState -> LaTeXState) -> ParsecT TokStream LaTeXState m ())
-> (LaTeXState -> LaTeXState) -> ParsecT TokStream LaTeXState m ()
forall a b. (a -> b) -> a -> b
$ \LaTeXState
st -> LaTeXState
st{
sLabels = M.insert lab (toList . text . tshow $ sLastNoteNum st)
$ sLabels st }
Inline -> ParsecT TokStream LaTeXState m Inline
forall a. a -> ParsecT TokStream LaTeXState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (Inline -> ParsecT TokStream LaTeXState m Inline)
-> Inline -> ParsecT TokStream LaTeXState m Inline
forall a b. (a -> b) -> a -> b
$ Attr -> [Inline] -> Inline
Span (Text
lab,[Text]
cls,[(Text, Text)]
kvs) []
resolveNoteLabel Inline
il = Inline -> ParsecT TokStream LaTeXState m Inline
forall a. a -> ParsecT TokStream LaTeXState m a
forall (m :: * -> *) a. Monad m => a -> m a
return Inline
il
lettrine :: PandocMonad m => LP m Inlines
lettrine :: forall (m :: * -> *). PandocMonad m => LP m (Many Inline)
lettrine = do
ParsecT TokStream LaTeXState m Text
-> ParsecT TokStream LaTeXState m (Maybe Text)
forall (f :: * -> *) a. Alternative f => f a -> f (Maybe a)
optional ParsecT TokStream LaTeXState m Text
forall (m :: * -> *). PandocMonad m => LP m Text
rawopt
x <- LP m (Many Inline)
forall (m :: * -> *). PandocMonad m => LP m (Many Inline)
tok
y <- tok
return $ extractSpaces (spanWith ("",["lettrine"],[])) x <> smallcaps y
ifdim :: PandocMonad m => LP m Inlines
ifdim :: forall (m :: * -> *). PandocMonad m => LP m (Many Inline)
ifdim = do
contents <- ParsecT TokStream LaTeXState m Tok
-> ParsecT TokStream LaTeXState m Tok
-> ParsecT TokStream LaTeXState m [Tok]
forall s (m :: * -> *) t u a end.
Stream s m t =>
ParsecT s u m a -> ParsecT s u m end -> ParsecT s u m [a]
manyTill ParsecT TokStream LaTeXState m Tok
forall (m :: * -> *). PandocMonad m => LP m Tok
anyTok (Text -> ParsecT TokStream LaTeXState m Tok
forall (m :: * -> *). PandocMonad m => Text -> LP m Tok
controlSeq Text
"fi")
return $ rawInline "latex" $ "\\ifdim" <> untokenize contents <> "\\fi"
makeUppercase :: Inlines -> Inlines
makeUppercase :: Many Inline -> Many Inline
makeUppercase = [Inline] -> Many Inline
forall a. [a] -> Many a
fromList ([Inline] -> Many Inline)
-> (Many Inline -> [Inline]) -> Many Inline -> Many Inline
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Inline -> Inline) -> [Inline] -> [Inline]
forall a b. Walkable a b => (a -> a) -> b -> b
walk ((Text -> Text) -> Inline -> Inline
alterStr Text -> Text
T.toUpper) ([Inline] -> [Inline])
-> (Many Inline -> [Inline]) -> Many Inline -> [Inline]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Many Inline -> [Inline]
forall a. Many a -> [a]
toList
makeLowercase :: Inlines -> Inlines
makeLowercase :: Many Inline -> Many Inline
makeLowercase = [Inline] -> Many Inline
forall a. [a] -> Many a
fromList ([Inline] -> Many Inline)
-> (Many Inline -> [Inline]) -> Many Inline -> Many Inline
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Inline -> Inline) -> [Inline] -> [Inline]
forall a b. Walkable a b => (a -> a) -> b -> b
walk ((Text -> Text) -> Inline -> Inline
alterStr Text -> Text
T.toLower) ([Inline] -> [Inline])
-> (Many Inline -> [Inline]) -> Many Inline -> [Inline]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Many Inline -> [Inline]
forall a. Many a -> [a]
toList
alterStr :: (Text -> Text) -> Inline -> Inline
alterStr :: (Text -> Text) -> Inline -> Inline
alterStr Text -> Text
f (Str Text
xs) = Text -> Inline
Str (Text -> Text
f Text
xs)
alterStr Text -> Text
_ Inline
x = Inline
x
fixPassthroughEscapes :: Inlines -> Inlines
fixPassthroughEscapes :: Many Inline -> Many Inline
fixPassthroughEscapes = (Inline -> Inline) -> Many Inline -> Many Inline
forall a b. Walkable a b => (a -> a) -> b -> b
walk Inline -> Inline
go
where
go :: Inline -> Inline
go (Code Attr
attr Text
txt) = Attr -> Text -> Inline
Code Attr
attr ([Char] -> Text
T.pack ([Char] -> Text) -> [Char] -> Text
forall a b. (a -> b) -> a -> b
$ [Char] -> [Char]
unescapePassthrough ([Char] -> [Char]) -> [Char] -> [Char]
forall a b. (a -> b) -> a -> b
$ Text -> [Char]
T.unpack Text
txt)
go Inline
x = Inline
x
unescapePassthrough :: [Char] -> [Char]
unescapePassthrough [] = []
unescapePassthrough (Char
'\\':Char
c:[Char]
cs)
| Char
c Char -> [Char] -> Bool
forall a. Eq a => a -> [a] -> Bool
forall (t :: * -> *) a. (Foldable t, Eq a) => a -> t a -> Bool
`elem` [Char
'%',Char
'{',Char
'}',Char
'\\'] = Char
c Char -> [Char] -> [Char]
forall a. a -> [a] -> [a]
: [Char] -> [Char]
unescapePassthrough [Char]
cs
unescapePassthrough (Char
c:[Char]
cs) = Char
c Char -> [Char] -> [Char]
forall a. a -> [a] -> [a]
: [Char] -> [Char]
unescapePassthrough [Char]
cs
hyperlink :: PandocMonad m => LP m Inlines
hyperlink :: forall (m :: * -> *). PandocMonad m => LP m (Many Inline)
hyperlink = ParsecT TokStream LaTeXState m (Many Inline)
-> ParsecT TokStream LaTeXState m (Many Inline)
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try (ParsecT TokStream LaTeXState m (Many Inline)
-> ParsecT TokStream LaTeXState m (Many Inline))
-> ParsecT TokStream LaTeXState m (Many Inline)
-> ParsecT TokStream LaTeXState m (Many Inline)
forall a b. (a -> b) -> a -> b
$ do
src <- [Tok] -> Text
untokenize ([Tok] -> Text)
-> ParsecT TokStream LaTeXState m [Tok]
-> ParsecT TokStream LaTeXState m Text
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ParsecT TokStream LaTeXState m [Tok]
forall (m :: * -> *). PandocMonad m => LP m [Tok]
braced
lab <- tok
return $ link ("#" <> src) "" lab
hyperref :: PandocMonad m => LP m Inlines
hyperref :: forall (m :: * -> *). PandocMonad m => LP m (Many Inline)
hyperref = ParsecT TokStream LaTeXState m (Many Inline)
-> ParsecT TokStream LaTeXState m (Many Inline)
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try (ParsecT TokStream LaTeXState m (Many Inline)
-> ParsecT TokStream LaTeXState m (Many Inline))
-> ParsecT TokStream LaTeXState m (Many Inline)
-> ParsecT TokStream LaTeXState m (Many Inline)
forall a b. (a -> b) -> a -> b
$ do
url <- ((Text
"#" Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<>) (Text -> Text) -> ([Tok] -> Text) -> [Tok] -> Text
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [Tok] -> Text
untokenize ([Tok] -> Text)
-> ParsecT TokStream LaTeXState m [Tok]
-> ParsecT TokStream LaTeXState m Text
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ParsecT TokStream LaTeXState m [Tok]
-> ParsecT TokStream LaTeXState m [Tok]
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try (LP m ()
forall (m :: * -> *). PandocMonad m => LP m ()
sp LP m ()
-> ParsecT TokStream LaTeXState m [Tok]
-> ParsecT TokStream LaTeXState m [Tok]
forall a b.
ParsecT TokStream LaTeXState m a
-> ParsecT TokStream LaTeXState m b
-> ParsecT TokStream LaTeXState m b
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> ParsecT TokStream LaTeXState m [Tok]
forall (m :: * -> *). PandocMonad m => LP m [Tok]
bracketedToks ParsecT TokStream LaTeXState m [Tok]
-> LP m () -> ParsecT TokStream LaTeXState m [Tok]
forall a b.
ParsecT TokStream LaTeXState m a
-> ParsecT TokStream LaTeXState m b
-> ParsecT TokStream LaTeXState m a
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
<* LP m ()
forall (m :: * -> *). PandocMonad m => LP m ()
sp))
ParsecT TokStream LaTeXState m Text
-> ParsecT TokStream LaTeXState m Text
-> ParsecT TokStream LaTeXState m Text
forall a.
ParsecT TokStream LaTeXState m a
-> ParsecT TokStream LaTeXState m a
-> ParsecT TokStream LaTeXState m a
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> [Tok] -> Text
untokenize ([Tok] -> Text)
-> ParsecT TokStream LaTeXState m [Tok]
-> ParsecT TokStream LaTeXState m Text
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (ParsecT TokStream LaTeXState m [Tok]
forall (m :: * -> *). PandocMonad m => LP m [Tok]
bracedUrl ParsecT TokStream LaTeXState m [Tok]
-> ParsecT TokStream LaTeXState m [Tok]
-> ParsecT TokStream LaTeXState m [Tok]
forall a b.
ParsecT TokStream LaTeXState m a
-> ParsecT TokStream LaTeXState m b
-> ParsecT TokStream LaTeXState m a
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
<* ParsecT TokStream LaTeXState m [Tok]
forall (m :: * -> *). PandocMonad m => LP m [Tok]
bracedUrl ParsecT TokStream LaTeXState m [Tok]
-> ParsecT TokStream LaTeXState m [Tok]
-> ParsecT TokStream LaTeXState m [Tok]
forall a b.
ParsecT TokStream LaTeXState m a
-> ParsecT TokStream LaTeXState m b
-> ParsecT TokStream LaTeXState m a
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
<* ParsecT TokStream LaTeXState m [Tok]
forall (m :: * -> *). PandocMonad m => LP m [Tok]
bracedUrl)
link url "" <$> tok
hypertargetBlock :: PandocMonad m => LP m Blocks
hypertargetBlock :: forall (m :: * -> *). PandocMonad m => LP m (Many Block)
hypertargetBlock = ParsecT TokStream LaTeXState m (Many Block)
-> ParsecT TokStream LaTeXState m (Many Block)
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try (ParsecT TokStream LaTeXState m (Many Block)
-> ParsecT TokStream LaTeXState m (Many Block))
-> ParsecT TokStream LaTeXState m (Many Block)
-> ParsecT TokStream LaTeXState m (Many Block)
forall a b. (a -> b) -> a -> b
$ do
ref <- [Tok] -> Text
untokenize ([Tok] -> Text)
-> ParsecT TokStream LaTeXState m [Tok]
-> ParsecT TokStream LaTeXState m Text
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ParsecT TokStream LaTeXState m [Tok]
forall (m :: * -> *). PandocMonad m => LP m [Tok]
braced
bs <- grouped block
case toList bs of
[Header Int
1 (Text
ident,[Text]
_,[(Text, Text)]
_) [Inline]
_] | Text
ident Text -> Text -> Bool
forall a. Eq a => a -> a -> Bool
== Text
ref -> Many Block -> ParsecT TokStream LaTeXState m (Many Block)
forall a. a -> ParsecT TokStream LaTeXState m a
forall (m :: * -> *) a. Monad m => a -> m a
return Many Block
bs
[Block]
_ -> Many Block -> ParsecT TokStream LaTeXState m (Many Block)
forall a. a -> ParsecT TokStream LaTeXState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (Many Block -> ParsecT TokStream LaTeXState m (Many Block))
-> Many Block -> ParsecT TokStream LaTeXState m (Many Block)
forall a b. (a -> b) -> a -> b
$ Attr -> Many Block -> Many Block
divWith (Text
ref, [], []) Many Block
bs
hypertargetInline :: PandocMonad m => LP m Inlines
hypertargetInline :: forall (m :: * -> *). PandocMonad m => LP m (Many Inline)
hypertargetInline = ParsecT TokStream LaTeXState m (Many Inline)
-> ParsecT TokStream LaTeXState m (Many Inline)
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try (ParsecT TokStream LaTeXState m (Many Inline)
-> ParsecT TokStream LaTeXState m (Many Inline))
-> ParsecT TokStream LaTeXState m (Many Inline)
-> ParsecT TokStream LaTeXState m (Many Inline)
forall a b. (a -> b) -> a -> b
$ do
ref <- [Tok] -> Text
untokenize ([Tok] -> Text)
-> ParsecT TokStream LaTeXState m [Tok]
-> ParsecT TokStream LaTeXState m Text
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ParsecT TokStream LaTeXState m [Tok]
forall (m :: * -> *). PandocMonad m => LP m [Tok]
braced
ils <- grouped inline
return $ spanWith (ref, [], []) ils
newToggle :: (Monoid a, PandocMonad m) => [Tok] -> LP m a
newToggle :: forall a (m :: * -> *).
(Monoid a, PandocMonad m) =>
[Tok] -> LP m a
newToggle [Tok]
name = do
(LaTeXState -> LaTeXState) -> ParsecT TokStream LaTeXState m ()
forall (m :: * -> *) u s. Monad m => (u -> u) -> ParsecT s u m ()
updateState ((LaTeXState -> LaTeXState) -> ParsecT TokStream LaTeXState m ())
-> (LaTeXState -> LaTeXState) -> ParsecT TokStream LaTeXState m ()
forall a b. (a -> b) -> a -> b
$ \LaTeXState
st ->
LaTeXState
st{ sToggles = M.insert (untokenize name) False (sToggles st) }
a -> ParsecT TokStream LaTeXState m a
forall a. a -> ParsecT TokStream LaTeXState m a
forall (m :: * -> *) a. Monad m => a -> m a
return a
forall a. Monoid a => a
mempty
setToggle :: (Monoid a, PandocMonad m) => Bool -> [Tok] -> LP m a
setToggle :: forall a (m :: * -> *).
(Monoid a, PandocMonad m) =>
Bool -> [Tok] -> LP m a
setToggle Bool
on [Tok]
name = do
(LaTeXState -> LaTeXState) -> ParsecT TokStream LaTeXState m ()
forall (m :: * -> *) u s. Monad m => (u -> u) -> ParsecT s u m ()
updateState ((LaTeXState -> LaTeXState) -> ParsecT TokStream LaTeXState m ())
-> (LaTeXState -> LaTeXState) -> ParsecT TokStream LaTeXState m ()
forall a b. (a -> b) -> a -> b
$ \LaTeXState
st ->
LaTeXState
st{ sToggles = M.adjust (const on) (untokenize name) (sToggles st) }
a -> ParsecT TokStream LaTeXState m a
forall a. a -> ParsecT TokStream LaTeXState m a
forall (m :: * -> *) a. Monad m => a -> m a
return a
forall a. Monoid a => a
mempty
ifToggle :: PandocMonad m => LP m ()
ifToggle :: forall (m :: * -> *). PandocMonad m => LP m ()
ifToggle = do
name <- LP m [Tok]
forall (m :: * -> *). PandocMonad m => LP m [Tok]
braced
spaces
yes <- withVerbatimMode braced
spaces
no <- withVerbatimMode braced
toggles <- sToggles <$> getState
TokStream _ inp <- getInput
let name' = [Tok] -> Text
untokenize [Tok]
name
case M.lookup name' toggles of
Just Bool
True -> TokStream -> LP m ()
forall (m :: * -> *) s u. Monad m => s -> ParsecT s u m ()
setInput (TokStream -> LP m ()) -> TokStream -> LP m ()
forall a b. (a -> b) -> a -> b
$ Bool -> [Tok] -> TokStream
TokStream Bool
False ([Tok]
yes [Tok] -> [Tok] -> [Tok]
forall a. [a] -> [a] -> [a]
++ [Tok]
inp)
Just Bool
False -> TokStream -> LP m ()
forall (m :: * -> *) s u. Monad m => s -> ParsecT s u m ()
setInput (TokStream -> LP m ()) -> TokStream -> LP m ()
forall a b. (a -> b) -> a -> b
$ Bool -> [Tok] -> TokStream
TokStream Bool
False ([Tok]
no [Tok] -> [Tok] -> [Tok]
forall a. [a] -> [a] -> [a]
++ [Tok]
inp)
Maybe Bool
Nothing -> do
pos <- ParsecT TokStream LaTeXState m SourcePos
forall (m :: * -> *) s u. Monad m => ParsecT s u m SourcePos
getPosition
report $ UndefinedToggle name' pos
return ()
coloredInline :: PandocMonad m => Text -> LP m Inlines
coloredInline :: forall (m :: * -> *). PandocMonad m => Text -> LP m (Many Inline)
coloredInline Text
stylename = do
LP m ()
forall (m :: * -> *). PandocMonad m => LP m ()
skipopts
color <- LP m [Tok]
forall (m :: * -> *). PandocMonad m => LP m [Tok]
braced
spanWith ("",[],[("style",stylename <> ": " <> untokenize color)]) <$> tok
processHBox :: Inlines -> Inlines
processHBox :: Many Inline -> Many Inline
processHBox = (Inline -> Inline) -> Many Inline -> Many Inline
forall a b. Walkable a b => (a -> a) -> b -> b
walk Inline -> Inline
convert
where
convert :: Inline -> Inline
convert Inline
Space = Text -> Inline
Str (Text -> Inline) -> Text -> Inline
forall a b. (a -> b) -> a -> b
$ Char -> Text
T.singleton (Char -> Text) -> Char -> Text
forall a b. (a -> b) -> a -> b
$ Int -> Char
chr Int
160
convert Inline
SoftBreak = Text -> Inline
Str (Text -> Inline) -> Text -> Inline
forall a b. (a -> b) -> a -> b
$ Char -> Text
T.singleton (Char -> Text) -> Char -> Text
forall a b. (a -> b) -> a -> b
$ Int -> Char
chr Int
160
convert Inline
LineBreak = Text -> Inline
Str Text
""
convert Inline
x = Inline
x
isBlockCommand :: Text -> Bool
isBlockCommand :: Text -> Bool
isBlockCommand Text
s =
Text
s Text -> Map Text (LP PandocPure (Many Block)) -> Bool
forall k a. Ord k => k -> Map k a -> Bool
`M.member` (Map Text (LP PandocPure (Many Block))
forall (m :: * -> *). PandocMonad m => Map Text (LP m (Many Block))
blockCommands :: M.Map Text (LP PandocPure Blocks))
Bool -> Bool -> Bool
|| Text
s Text -> Set Text -> Bool
forall a. Ord a => a -> Set a -> Bool
`Set.member` Set Text
treatAsBlock
treatAsBlock :: Set.Set Text
treatAsBlock :: Set Text
treatAsBlock = [Text] -> Set Text
forall a. Ord a => [a] -> Set a
Set.fromList
[ Text
"special", Text
"pdfannot", Text
"pdfstringdef"
, Text
"bibliographystyle"
, Text
"maketitle", Text
"makeindex", Text
"makeglossary"
, Text
"addcontentsline", Text
"addtocontents", Text
"addtocounter"
, Text
"ignore"
, Text
"hyperdef"
, Text
"markboth", Text
"markright", Text
"markleft"
, Text
"hspace", Text
"vspace"
, Text
"newpage"
, Text
"clearpage"
, Text
"pagebreak"
, Text
"titleformat"
, Text
"listoffigures"
, Text
"listoftables"
, Text
"write"
]
isInlineCommand :: Text -> Bool
isInlineCommand :: Text -> Bool
isInlineCommand Text
s =
Text
s Text -> Map Text (LP PandocPure (Many Inline)) -> Bool
forall k a. Ord k => k -> Map k a -> Bool
`M.member` (Map Text (LP PandocPure (Many Inline))
forall (m :: * -> *).
PandocMonad m =>
Map Text (LP m (Many Inline))
inlineCommands :: M.Map Text (LP PandocPure Inlines))
Bool -> Bool -> Bool
|| Text
s Text -> Set Text -> Bool
forall a. Ord a => a -> Set a -> Bool
`Set.member` Set Text
treatAsInline
treatAsInline :: Set.Set Text
treatAsInline :: Set Text
treatAsInline = [Text] -> Set Text
forall a. Ord a => [a] -> Set a
Set.fromList
[ Text
"index"
, Text
"hspace"
, Text
"vspace"
, Text
"noindent"
, Text
"newpage"
, Text
"clearpage"
, Text
"pagebreak"
]
lookupListDefault :: (Ord k) => v -> [k] -> M.Map k v -> v
lookupListDefault :: forall k v. Ord k => v -> [k] -> Map k v -> v
lookupListDefault v
d = (v -> Maybe v -> v
forall a. a -> Maybe a -> a
fromMaybe v
d (Maybe v -> v) -> (Map k v -> Maybe v) -> Map k v -> v
forall b c a. (b -> c) -> (a -> b) -> a -> c
.) ((Map k v -> Maybe v) -> Map k v -> v)
-> ([k] -> Map k v -> Maybe v) -> [k] -> Map k v -> v
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [k] -> Map k v -> Maybe v
forall {a} {a}. Ord a => [a] -> Map a a -> Maybe a
lookupList
where lookupList :: [a] -> Map a a -> Maybe a
lookupList [a]
l Map a a
m = [Maybe a] -> Maybe a
forall (t :: * -> *) (m :: * -> *) a.
(Foldable t, MonadPlus m) =>
t (m a) -> m a
msum ([Maybe a] -> Maybe a) -> [Maybe a] -> Maybe a
forall a b. (a -> b) -> a -> b
$ (a -> Maybe a) -> [a] -> [Maybe a]
forall a b. (a -> b) -> [a] -> [b]
map (a -> Map a a -> Maybe a
forall k a. Ord k => k -> Map k a -> Maybe a
`M.lookup` Map a a
m) [a]
l
inline :: PandocMonad m => LP m Inlines
inline :: forall (m :: * -> *). PandocMonad m => LP m (Many Inline)
inline = do
Tok pos toktype t <- LP m Tok
forall (m :: * -> *). PandocMonad m => LP m Tok
peekTok
let eatOneToken = (Tok -> Bool) -> LP m Tok
forall (m :: * -> *). PandocMonad m => (Tok -> Bool) -> LP m Tok
satisfyTok (Bool -> Tok -> Bool
forall a b. a -> b -> a
const Bool
True)
let symbolAsString = Text -> Many Inline
str Text
t Many Inline
-> LP m Tok -> ParsecT TokStream LaTeXState m (Many Inline)
forall a b.
a
-> ParsecT TokStream LaTeXState m b
-> ParsecT TokStream LaTeXState m a
forall (f :: * -> *) a b. Functor f => a -> f b -> f a
<$ LP m Tok
eatOneToken
let unescapedSymbolAsString =
do LP m Tok
eatOneToken
LogMessage -> ParsecT TokStream LaTeXState m ()
forall (m :: * -> *). PandocMonad m => LogMessage -> m ()
report (LogMessage -> ParsecT TokStream LaTeXState m ())
-> LogMessage -> ParsecT TokStream LaTeXState m ()
forall a b. (a -> b) -> a -> b
$ Text -> SourcePos -> LogMessage
ParsingUnescaped Text
t SourcePos
pos
Many Inline -> ParsecT TokStream LaTeXState m (Many Inline)
forall a. a -> ParsecT TokStream LaTeXState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (Many Inline -> ParsecT TokStream LaTeXState m (Many Inline))
-> Many Inline -> ParsecT TokStream LaTeXState m (Many Inline)
forall a b. (a -> b) -> a -> b
$ Text -> Many Inline
str Text
t
ligatures <- sLigatures <$> getState
case toktype of
TokType
Comment -> Many Inline
forall a. Monoid a => a
mempty Many Inline
-> LP m Tok -> ParsecT TokStream LaTeXState m (Many Inline)
forall a b.
a
-> ParsecT TokStream LaTeXState m b
-> ParsecT TokStream LaTeXState m a
forall (f :: * -> *) a b. Functor f => a -> f b -> f a
<$ LP m Tok
eatOneToken
TokType
Spaces -> Many Inline
space Many Inline
-> LP m Tok -> ParsecT TokStream LaTeXState m (Many Inline)
forall a b.
a
-> ParsecT TokStream LaTeXState m b
-> ParsecT TokStream LaTeXState m a
forall (f :: * -> *) a b. Functor f => a -> f b -> f a
<$ LP m Tok
eatOneToken
TokType
Newline -> Many Inline
softbreak Many Inline
-> ParsecT TokStream LaTeXState m ()
-> ParsecT TokStream LaTeXState m (Many Inline)
forall a b.
a
-> ParsecT TokStream LaTeXState m b
-> ParsecT TokStream LaTeXState m a
forall (f :: * -> *) a b. Functor f => a -> f b -> f a
<$ ParsecT TokStream LaTeXState m ()
forall (m :: * -> *). PandocMonad m => LP m ()
endline
TokType
Word -> Text -> Many Inline
str Text
t Many Inline
-> LP m Tok -> ParsecT TokStream LaTeXState m (Many Inline)
forall a b.
a
-> ParsecT TokStream LaTeXState m b
-> ParsecT TokStream LaTeXState m a
forall (f :: * -> *) a b. Functor f => a -> f b -> f a
<$ LP m Tok
eatOneToken
TokType
Symbol ->
case Text
t of
Text
"-" | Bool
ligatures
-> LP m Tok
eatOneToken LP m Tok
-> ParsecT TokStream LaTeXState m (Many Inline)
-> ParsecT TokStream LaTeXState m (Many Inline)
forall a b.
ParsecT TokStream LaTeXState m a
-> ParsecT TokStream LaTeXState m b
-> ParsecT TokStream LaTeXState m b
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*>
Many Inline
-> ParsecT TokStream LaTeXState m (Many Inline)
-> ParsecT TokStream LaTeXState m (Many Inline)
forall s (m :: * -> *) t a u.
Stream s m t =>
a -> ParsecT s u m a -> ParsecT s u m a
option (Text -> Many Inline
str Text
"-") (Char -> LP m Tok
forall (m :: * -> *). PandocMonad m => Char -> LP m Tok
symbol Char
'-' LP m Tok
-> ParsecT TokStream LaTeXState m (Many Inline)
-> ParsecT TokStream LaTeXState m (Many Inline)
forall a b.
ParsecT TokStream LaTeXState m a
-> ParsecT TokStream LaTeXState m b
-> ParsecT TokStream LaTeXState m b
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*>
Many Inline
-> ParsecT TokStream LaTeXState m (Many Inline)
-> ParsecT TokStream LaTeXState m (Many Inline)
forall s (m :: * -> *) t a u.
Stream s m t =>
a -> ParsecT s u m a -> ParsecT s u m a
option (Text -> Many Inline
str Text
"–") (Text -> Many Inline
str Text
"—" Many Inline
-> LP m Tok -> ParsecT TokStream LaTeXState m (Many Inline)
forall a b.
a
-> ParsecT TokStream LaTeXState m b
-> ParsecT TokStream LaTeXState m a
forall (f :: * -> *) a b. Functor f => a -> f b -> f a
<$ Char -> LP m Tok
forall (m :: * -> *). PandocMonad m => Char -> LP m Tok
symbol Char
'-'))
Text
"'" -> LP m Tok
eatOneToken LP m Tok
-> ParsecT TokStream LaTeXState m (Many Inline)
-> ParsecT TokStream LaTeXState m (Many Inline)
forall a b.
ParsecT TokStream LaTeXState m a
-> ParsecT TokStream LaTeXState m b
-> ParsecT TokStream LaTeXState m b
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*>
Many Inline
-> ParsecT TokStream LaTeXState m (Many Inline)
-> ParsecT TokStream LaTeXState m (Many Inline)
forall s (m :: * -> *) t a u.
Stream s m t =>
a -> ParsecT s u m a -> ParsecT s u m a
option (Text -> Many Inline
str Text
"’") (Text -> Many Inline
str Text
"”" Many Inline
-> LP m Tok -> ParsecT TokStream LaTeXState m (Many Inline)
forall a b.
a
-> ParsecT TokStream LaTeXState m b
-> ParsecT TokStream LaTeXState m a
forall (f :: * -> *) a b. Functor f => a -> f b -> f a
<$ (Bool -> ParsecT TokStream LaTeXState m ()
forall (f :: * -> *). Alternative f => Bool -> f ()
guard Bool
ligatures ParsecT TokStream LaTeXState m () -> LP m Tok -> LP m Tok
forall a b.
ParsecT TokStream LaTeXState m a
-> ParsecT TokStream LaTeXState m b
-> ParsecT TokStream LaTeXState m b
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> Char -> LP m Tok
forall (m :: * -> *). PandocMonad m => Char -> LP m Tok
symbol Char
'\''))
Text
"~" -> Text -> Many Inline
str Text
"\160" Many Inline
-> LP m Tok -> ParsecT TokStream LaTeXState m (Many Inline)
forall a b.
a
-> ParsecT TokStream LaTeXState m b
-> ParsecT TokStream LaTeXState m a
forall (f :: * -> *) a b. Functor f => a -> f b -> f a
<$ LP m Tok
eatOneToken
Text
"`" | Bool
ligatures
-> ParsecT TokStream LaTeXState m (Many Inline)
forall (m :: * -> *). PandocMonad m => LP m (Many Inline)
doubleQuote ParsecT TokStream LaTeXState m (Many Inline)
-> ParsecT TokStream LaTeXState m (Many Inline)
-> ParsecT TokStream LaTeXState m (Many Inline)
forall a.
ParsecT TokStream LaTeXState m a
-> ParsecT TokStream LaTeXState m a
-> ParsecT TokStream LaTeXState m a
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> ParsecT TokStream LaTeXState m (Many Inline)
forall (m :: * -> *). PandocMonad m => LP m (Many Inline)
singleQuote ParsecT TokStream LaTeXState m (Many Inline)
-> ParsecT TokStream LaTeXState m (Many Inline)
-> ParsecT TokStream LaTeXState m (Many Inline)
forall a.
ParsecT TokStream LaTeXState m a
-> ParsecT TokStream LaTeXState m a
-> ParsecT TokStream LaTeXState m a
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> (Text -> Many Inline
str Text
"‘" Many Inline
-> LP m Tok -> ParsecT TokStream LaTeXState m (Many Inline)
forall a b.
a
-> ParsecT TokStream LaTeXState m b
-> ParsecT TokStream LaTeXState m a
forall (f :: * -> *) a b. Functor f => a -> f b -> f a
<$ Char -> LP m Tok
forall (m :: * -> *). PandocMonad m => Char -> LP m Tok
symbol Char
'`')
| Bool
otherwise
-> Text -> Many Inline
str Text
"‘" Many Inline
-> LP m Tok -> ParsecT TokStream LaTeXState m (Many Inline)
forall a b.
a
-> ParsecT TokStream LaTeXState m b
-> ParsecT TokStream LaTeXState m a
forall (f :: * -> *) a b. Functor f => a -> f b -> f a
<$ Char -> LP m Tok
forall (m :: * -> *). PandocMonad m => Char -> LP m Tok
symbol Char
'`'
Text
"\"" | Bool
ligatures
-> ParsecT TokStream LaTeXState m (Many Inline)
forall (m :: * -> *). PandocMonad m => LP m (Many Inline)
doubleQuote ParsecT TokStream LaTeXState m (Many Inline)
-> ParsecT TokStream LaTeXState m (Many Inline)
-> ParsecT TokStream LaTeXState m (Many Inline)
forall a.
ParsecT TokStream LaTeXState m a
-> ParsecT TokStream LaTeXState m a
-> ParsecT TokStream LaTeXState m a
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> ParsecT TokStream LaTeXState m (Many Inline)
forall (m :: * -> *). PandocMonad m => LP m (Many Inline)
singleQuote ParsecT TokStream LaTeXState m (Many Inline)
-> ParsecT TokStream LaTeXState m (Many Inline)
-> ParsecT TokStream LaTeXState m (Many Inline)
forall a.
ParsecT TokStream LaTeXState m a
-> ParsecT TokStream LaTeXState m a
-> ParsecT TokStream LaTeXState m a
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> ParsecT TokStream LaTeXState m (Many Inline)
symbolAsString
Text
"“" -> ParsecT TokStream LaTeXState m (Many Inline)
forall (m :: * -> *). PandocMonad m => LP m (Many Inline)
doubleQuote ParsecT TokStream LaTeXState m (Many Inline)
-> ParsecT TokStream LaTeXState m (Many Inline)
-> ParsecT TokStream LaTeXState m (Many Inline)
forall a.
ParsecT TokStream LaTeXState m a
-> ParsecT TokStream LaTeXState m a
-> ParsecT TokStream LaTeXState m a
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> ParsecT TokStream LaTeXState m (Many Inline)
symbolAsString
Text
"‘" -> ParsecT TokStream LaTeXState m (Many Inline)
forall (m :: * -> *). PandocMonad m => LP m (Many Inline)
singleQuote ParsecT TokStream LaTeXState m (Many Inline)
-> ParsecT TokStream LaTeXState m (Many Inline)
-> ParsecT TokStream LaTeXState m (Many Inline)
forall a.
ParsecT TokStream LaTeXState m a
-> ParsecT TokStream LaTeXState m a
-> ParsecT TokStream LaTeXState m a
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> ParsecT TokStream LaTeXState m (Many Inline)
symbolAsString
Text
"$" -> ParsecT TokStream LaTeXState m (Many Inline)
forall (m :: * -> *). PandocMonad m => LP m (Many Inline)
dollarsMath ParsecT TokStream LaTeXState m (Many Inline)
-> ParsecT TokStream LaTeXState m (Many Inline)
-> ParsecT TokStream LaTeXState m (Many Inline)
forall a.
ParsecT TokStream LaTeXState m a
-> ParsecT TokStream LaTeXState m a
-> ParsecT TokStream LaTeXState m a
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> ParsecT TokStream LaTeXState m (Many Inline)
unescapedSymbolAsString
Text
"|" -> (Extension -> ParsecT TokStream LaTeXState m ()
forall s (m :: * -> *) a st.
(Stream s m a, HasReaderOptions st) =>
Extension -> ParsecT s st m ()
guardEnabled Extension
Ext_literate_haskell ParsecT TokStream LaTeXState m () -> LP m Tok -> LP m Tok
forall a b.
ParsecT TokStream LaTeXState m a
-> ParsecT TokStream LaTeXState m b
-> ParsecT TokStream LaTeXState m b
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*>
LP m Tok
eatOneToken LP m Tok
-> ParsecT TokStream LaTeXState m (Many Inline)
-> ParsecT TokStream LaTeXState m (Many Inline)
forall a b.
ParsecT TokStream LaTeXState m a
-> ParsecT TokStream LaTeXState m b
-> ParsecT TokStream LaTeXState m b
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> ParsecT TokStream LaTeXState m (Many Inline)
forall (m :: * -> *). PandocMonad m => LP m (Many Inline)
doLHSverb) ParsecT TokStream LaTeXState m (Many Inline)
-> ParsecT TokStream LaTeXState m (Many Inline)
-> ParsecT TokStream LaTeXState m (Many Inline)
forall a.
ParsecT TokStream LaTeXState m a
-> ParsecT TokStream LaTeXState m a
-> ParsecT TokStream LaTeXState m a
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> ParsecT TokStream LaTeXState m (Many Inline)
symbolAsString
Text
"{" -> ParsecT TokStream LaTeXState m (Many Inline)
forall (m :: * -> *). PandocMonad m => LP m (Many Inline)
inlineGroup
Text
"#" -> ParsecT TokStream LaTeXState m (Many Inline)
unescapedSymbolAsString
Text
"&" -> ParsecT TokStream LaTeXState m (Many Inline)
unescapedSymbolAsString
Text
"_" -> ParsecT TokStream LaTeXState m (Many Inline)
unescapedSymbolAsString
Text
"^" -> ParsecT TokStream LaTeXState m (Many Inline)
unescapedSymbolAsString
Text
"\\" -> ParsecT TokStream LaTeXState m (Many Inline)
forall a. ParsecT TokStream LaTeXState m a
forall (m :: * -> *) a. MonadPlus m => m a
mzero
Text
"}" -> ParsecT TokStream LaTeXState m (Many Inline)
forall a. ParsecT TokStream LaTeXState m a
forall (m :: * -> *) a. MonadPlus m => m a
mzero
Text
_ -> ParsecT TokStream LaTeXState m (Many Inline)
symbolAsString
CtrlSeq Text
_ -> (Text -> Many Inline)
-> ParsecT TokStream LaTeXState m (Many Inline)
forall (m :: * -> *) a.
(PandocMonad m, Monoid a) =>
(Text -> a) -> LP m a
macroDef (Text -> Text -> Many Inline
rawInline Text
"latex")
ParsecT TokStream LaTeXState m (Many Inline)
-> ParsecT TokStream LaTeXState m (Many Inline)
-> ParsecT TokStream LaTeXState m (Many Inline)
forall a.
ParsecT TokStream LaTeXState m a
-> ParsecT TokStream LaTeXState m a
-> ParsecT TokStream LaTeXState m a
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> ParsecT TokStream LaTeXState m (Many Inline)
forall (m :: * -> *). PandocMonad m => LP m (Many Inline)
inlineGroup
ParsecT TokStream LaTeXState m (Many Inline)
-> ParsecT TokStream LaTeXState m (Many Inline)
-> ParsecT TokStream LaTeXState m (Many Inline)
forall a.
ParsecT TokStream LaTeXState m a
-> ParsecT TokStream LaTeXState m a
-> ParsecT TokStream LaTeXState m a
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> ParsecT TokStream LaTeXState m (Many Inline)
forall (m :: * -> *). PandocMonad m => LP m (Many Inline)
inlineCommand'
ParsecT TokStream LaTeXState m (Many Inline)
-> ParsecT TokStream LaTeXState m (Many Inline)
-> ParsecT TokStream LaTeXState m (Many Inline)
forall a.
ParsecT TokStream LaTeXState m a
-> ParsecT TokStream LaTeXState m a
-> ParsecT TokStream LaTeXState m a
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> ParsecT TokStream LaTeXState m (Many Inline)
forall (m :: * -> *). PandocMonad m => LP m (Many Inline)
inlineEnvironment
TokType
Esc1 -> Text -> Many Inline
str (Text -> Many Inline) -> (Char -> Text) -> Char -> Many Inline
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Char -> Text
T.singleton (Char -> Many Inline)
-> ParsecT TokStream LaTeXState m Char
-> ParsecT TokStream LaTeXState m (Many Inline)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ParsecT TokStream LaTeXState m Char
forall (m :: * -> *). PandocMonad m => LP m Char
primEscape
TokType
Esc2 -> Text -> Many Inline
str (Text -> Many Inline) -> (Char -> Text) -> Char -> Many Inline
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Char -> Text
T.singleton (Char -> Many Inline)
-> ParsecT TokStream LaTeXState m Char
-> ParsecT TokStream LaTeXState m (Many Inline)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ParsecT TokStream LaTeXState m Char
forall (m :: * -> *). PandocMonad m => LP m Char
primEscape
TokType
_ -> ParsecT TokStream LaTeXState m (Many Inline)
forall a. ParsecT TokStream LaTeXState m a
forall (m :: * -> *) a. MonadPlus m => m a
mzero
inlines :: PandocMonad m => LP m Inlines
inlines :: forall (m :: * -> *). PandocMonad m => LP m (Many Inline)
inlines = [Many Inline] -> Many Inline
forall a. Monoid a => [a] -> a
mconcat ([Many Inline] -> Many Inline)
-> ParsecT TokStream LaTeXState m [Many Inline]
-> ParsecT TokStream LaTeXState m (Many Inline)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ParsecT TokStream LaTeXState m (Many Inline)
-> ParsecT TokStream LaTeXState m [Many Inline]
forall a.
ParsecT TokStream LaTeXState m a
-> ParsecT TokStream LaTeXState m [a]
forall (f :: * -> *) a. Alternative f => f a -> f [a]
many ParsecT TokStream LaTeXState m (Many Inline)
forall (m :: * -> *). PandocMonad m => LP m (Many Inline)
inline
opt :: PandocMonad m => LP m Inlines
opt :: forall (m :: * -> *). PandocMonad m => LP m (Many Inline)
opt = do
toks <- ParsecT TokStream LaTeXState m [Tok]
-> ParsecT TokStream LaTeXState m [Tok]
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try (LP m ()
forall (m :: * -> *). PandocMonad m => LP m ()
sp LP m ()
-> ParsecT TokStream LaTeXState m [Tok]
-> ParsecT TokStream LaTeXState m [Tok]
forall a b.
ParsecT TokStream LaTeXState m a
-> ParsecT TokStream LaTeXState m b
-> ParsecT TokStream LaTeXState m b
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> ParsecT TokStream LaTeXState m [Tok]
forall (m :: * -> *). PandocMonad m => LP m [Tok]
bracketedToks ParsecT TokStream LaTeXState m [Tok]
-> LP m () -> ParsecT TokStream LaTeXState m [Tok]
forall a b.
ParsecT TokStream LaTeXState m a
-> ParsecT TokStream LaTeXState m b
-> ParsecT TokStream LaTeXState m a
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
<* LP m ()
forall (m :: * -> *). PandocMonad m => LP m ()
sp)
st <- getState
parsed <- runParserT (mconcat <$> many inline) st "bracketed option"
(TokStream False toks)
case parsed of
Right Many Inline
result -> Many Inline -> ParsecT TokStream LaTeXState m (Many Inline)
forall a. a -> ParsecT TokStream LaTeXState m a
forall (m :: * -> *) a. Monad m => a -> m a
return Many Inline
result
Left ParseError
e -> PandocError -> ParsecT TokStream LaTeXState m (Many Inline)
forall a. PandocError -> ParsecT TokStream LaTeXState m a
forall e (m :: * -> *) a. MonadError e m => e -> m a
throwError (PandocError -> ParsecT TokStream LaTeXState m (Many Inline))
-> PandocError -> ParsecT TokStream LaTeXState m (Many Inline)
forall a b. (a -> b) -> a -> b
$ Sources -> ParseError -> PandocError
fromParsecError ([Tok] -> Sources
forall a. ToSources a => a -> Sources
toSources [Tok]
toks) ParseError
e
preamble :: PandocMonad m => LP m Blocks
preamble :: forall (m :: * -> *). PandocMonad m => LP m (Many Block)
preamble = [Many Block] -> Many Block
forall a. Monoid a => [a] -> a
mconcat ([Many Block] -> Many Block)
-> ParsecT TokStream LaTeXState m [Many Block]
-> ParsecT TokStream LaTeXState m (Many Block)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ParsecT TokStream LaTeXState m (Many Block)
-> ParsecT TokStream LaTeXState m [Many Block]
forall a.
ParsecT TokStream LaTeXState m a
-> ParsecT TokStream LaTeXState m [a]
forall (f :: * -> *) a. Alternative f => f a -> f [a]
many ParsecT TokStream LaTeXState m (Many Block)
preambleBlock
where preambleBlock :: ParsecT TokStream LaTeXState m (Many Block)
preambleBlock = (Many Block
forall a. Monoid a => a
mempty Many Block
-> ParsecT TokStream LaTeXState m ()
-> ParsecT TokStream LaTeXState m (Many Block)
forall a b.
a
-> ParsecT TokStream LaTeXState m b
-> ParsecT TokStream LaTeXState m a
forall (f :: * -> *) a b. Functor f => a -> f b -> f a
<$ ParsecT TokStream LaTeXState m ()
forall (m :: * -> *). PandocMonad m => LP m ()
spaces1)
ParsecT TokStream LaTeXState m (Many Block)
-> ParsecT TokStream LaTeXState m (Many Block)
-> ParsecT TokStream LaTeXState m (Many Block)
forall a.
ParsecT TokStream LaTeXState m a
-> ParsecT TokStream LaTeXState m a
-> ParsecT TokStream LaTeXState m a
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> (Text -> Many Block) -> ParsecT TokStream LaTeXState m (Many Block)
forall (m :: * -> *) a.
(PandocMonad m, Monoid a) =>
(Text -> a) -> LP m a
macroDef (Text -> Text -> Many Block
rawBlock Text
"latex")
ParsecT TokStream LaTeXState m (Many Block)
-> ParsecT TokStream LaTeXState m (Many Block)
-> ParsecT TokStream LaTeXState m (Many Block)
forall a.
ParsecT TokStream LaTeXState m a
-> ParsecT TokStream LaTeXState m a
-> ParsecT TokStream LaTeXState m a
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> ParsecT TokStream LaTeXState m (Many Block)
forall (m :: * -> *). PandocMonad m => LP m (Many Block)
filecontents
ParsecT TokStream LaTeXState m (Many Block)
-> ParsecT TokStream LaTeXState m (Many Block)
-> ParsecT TokStream LaTeXState m (Many Block)
forall a.
ParsecT TokStream LaTeXState m a
-> ParsecT TokStream LaTeXState m a
-> ParsecT TokStream LaTeXState m a
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> (Many Block
forall a. Monoid a => a
mempty Many Block
-> ParsecT TokStream LaTeXState m (Many Block)
-> ParsecT TokStream LaTeXState m (Many Block)
forall a b.
a
-> ParsecT TokStream LaTeXState m b
-> ParsecT TokStream LaTeXState m a
forall (f :: * -> *) a b. Functor f => a -> f b -> f a
<$ ParsecT TokStream LaTeXState m (Many Block)
forall (m :: * -> *). PandocMonad m => LP m (Many Block)
blockCommand)
ParsecT TokStream LaTeXState m (Many Block)
-> ParsecT TokStream LaTeXState m (Many Block)
-> ParsecT TokStream LaTeXState m (Many Block)
forall a.
ParsecT TokStream LaTeXState m a
-> ParsecT TokStream LaTeXState m a
-> ParsecT TokStream LaTeXState m a
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> (Many Block
forall a. Monoid a => a
mempty Many Block
-> ParsecT TokStream LaTeXState m [Tok]
-> ParsecT TokStream LaTeXState m (Many Block)
forall a b.
a
-> ParsecT TokStream LaTeXState m b
-> ParsecT TokStream LaTeXState m a
forall (f :: * -> *) a b. Functor f => a -> f b -> f a
<$ ParsecT TokStream LaTeXState m [Tok]
forall (m :: * -> *). PandocMonad m => LP m [Tok]
braced)
ParsecT TokStream LaTeXState m (Many Block)
-> ParsecT TokStream LaTeXState m (Many Block)
-> ParsecT TokStream LaTeXState m (Many Block)
forall a.
ParsecT TokStream LaTeXState m a
-> ParsecT TokStream LaTeXState m a
-> ParsecT TokStream LaTeXState m a
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> (do ParsecT TokStream LaTeXState m ()
-> ParsecT TokStream LaTeXState m ()
forall s (m :: * -> *) t a u.
(Stream s m t, Show a) =>
ParsecT s u m a -> ParsecT s u m ()
notFollowedBy (Text -> ParsecT TokStream LaTeXState m ()
forall (m :: * -> *). PandocMonad m => Text -> LP m ()
begin_ Text
"document")
LP m Tok
forall (m :: * -> *). PandocMonad m => LP m Tok
anyTok
Many Block -> ParsecT TokStream LaTeXState m (Many Block)
forall a. a -> ParsecT TokStream LaTeXState m a
forall (m :: * -> *) a. Monad m => a -> m a
return Many Block
forall a. Monoid a => a
mempty)
rule :: PandocMonad m => LP m Blocks
rule :: forall (m :: * -> *). PandocMonad m => LP m (Many Block)
rule = do
LP m ()
forall (m :: * -> *). PandocMonad m => LP m ()
skipopts
width <- (Char -> Bool) -> Text -> Text
T.takeWhile (\Char
c -> Char -> Bool
isDigit Char
c Bool -> Bool -> Bool
|| Char
c Char -> Char -> Bool
forall a. Eq a => a -> a -> Bool
== Char
'.') (Text -> Text) -> (Many Inline -> Text) -> Many Inline -> Text
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Many Inline -> Text
forall a. Walkable Inline a => a -> Text
stringify (Many Inline -> Text)
-> ParsecT TokStream LaTeXState m (Many Inline)
-> ParsecT TokStream LaTeXState m Text
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ParsecT TokStream LaTeXState m (Many Inline)
forall (m :: * -> *). PandocMonad m => LP m (Many Inline)
tok
_thickness <- tok
case safeRead width of
Just (Double
0 :: Double) -> Many Block -> ParsecT TokStream LaTeXState m (Many Block)
forall a. a -> ParsecT TokStream LaTeXState m a
forall (m :: * -> *) a. Monad m => a -> m a
return Many Block
forall a. Monoid a => a
mempty
Maybe Double
_ -> Many Block -> ParsecT TokStream LaTeXState m (Many Block)
forall a. a -> ParsecT TokStream LaTeXState m a
forall (m :: * -> *) a. Monad m => a -> m a
return Many Block
horizontalRule
paragraph :: PandocMonad m => LP m Blocks
paragraph :: forall (m :: * -> *). PandocMonad m => LP m (Many Block)
paragraph = do
x <- Many Inline -> Many Inline
trimInlines (Many Inline -> Many Inline)
-> ([Many Inline] -> Many Inline) -> [Many Inline] -> Many Inline
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [Many Inline] -> Many Inline
forall a. Monoid a => [a] -> a
mconcat ([Many Inline] -> Many Inline)
-> ParsecT TokStream LaTeXState m [Many Inline]
-> ParsecT TokStream LaTeXState m (Many Inline)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ParsecT TokStream LaTeXState m (Many Inline)
-> ParsecT TokStream LaTeXState m [Many Inline]
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m [a]
many1 ParsecT TokStream LaTeXState m (Many Inline)
forall (m :: * -> *). PandocMonad m => LP m (Many Inline)
inline
if x == mempty
then return mempty
else return $ para x
rawBlockOr :: PandocMonad m => Text -> LP m Blocks -> LP m Blocks
rawBlockOr :: forall (m :: * -> *).
PandocMonad m =>
Text -> LP m (Many Block) -> LP m (Many Block)
rawBlockOr Text
name LP m (Many Block)
fallback = do
parseRaw <- Extension -> Extensions -> Bool
extensionEnabled Extension
Ext_raw_tex (Extensions -> Bool)
-> ParsecT TokStream LaTeXState m Extensions
-> ParsecT TokStream LaTeXState m Bool
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (ReaderOptions -> Extensions)
-> ParsecT TokStream LaTeXState m Extensions
forall st s (m :: * -> *) t b.
(HasReaderOptions st, Stream s m t) =>
(ReaderOptions -> b) -> ParsecT s st m b
forall s (m :: * -> *) t b.
Stream s m t =>
(ReaderOptions -> b) -> ParsecT s LaTeXState m b
getOption ReaderOptions -> Extensions
readerExtensions
if parseRaw
then rawBlock "latex" <$> getRawCommand name ("\\" <> name)
else fallback
doSubfile :: PandocMonad m => LP m Blocks
doSubfile :: forall (m :: * -> *). PandocMonad m => LP m (Many Block)
doSubfile = do
ParsecT TokStream LaTeXState m (Many Inline)
-> ParsecT TokStream LaTeXState m ()
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m ()
skipMany ParsecT TokStream LaTeXState m (Many Inline)
forall (m :: * -> *). PandocMonad m => LP m (Many Inline)
opt
f <- Text -> [Char]
T.unpack (Text -> [Char])
-> ParsecT TokStream LaTeXState m Text
-> ParsecT TokStream LaTeXState m [Char]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ParsecT TokStream LaTeXState m Text
forall (m :: * -> *). PandocMonad m => LP m Text
bracedFilename
oldToks <- getInput
setInput $ TokStream False []
insertIncluded (ensureExtension (/= "") ".tex" f)
bs <- blocks
eof
setInput oldToks
return bs
include :: (PandocMonad m, Monoid a) => Text -> LP m a
include :: forall (m :: * -> *) a. (PandocMonad m, Monoid a) => Text -> LP m a
include Text
name = do
let isAllowed :: [Char] -> Bool
isAllowed =
case Text
name of
Text
"include" -> ([Char] -> [Char] -> Bool
forall a. Eq a => a -> a -> Bool
== [Char]
".tex")
Text
"input" -> ([Char] -> [Char] -> Bool
forall a. Eq a => a -> a -> Bool
/= [Char]
"")
Text
_ -> Bool -> [Char] -> Bool
forall a b. a -> b -> a
const Bool
False
ParsecT TokStream LaTeXState m (Many Inline)
-> ParsecT TokStream LaTeXState m ()
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m ()
skipMany ParsecT TokStream LaTeXState m (Many Inline)
forall (m :: * -> *). PandocMonad m => LP m (Many Inline)
opt
fs <- (Text -> [Char]) -> [Text] -> [[Char]]
forall a b. (a -> b) -> [a] -> [b]
map (Text -> [Char]
T.unpack (Text -> [Char]) -> (Text -> Text) -> Text -> [Char]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Text -> Text
removeDoubleQuotes (Text -> Text) -> (Text -> Text) -> Text -> Text
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Text -> Text
T.strip) ([Text] -> [[Char]]) -> ([Tok] -> [Text]) -> [Tok] -> [[Char]]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. HasCallStack => Text -> Text -> [Text]
Text -> Text -> [Text]
T.splitOn Text
"," (Text -> [Text]) -> ([Tok] -> Text) -> [Tok] -> [Text]
forall b c a. (b -> c) -> (a -> b) -> a -> c
.
[Tok] -> Text
untokenize ([Tok] -> Text) -> ([Tok] -> [Tok]) -> [Tok] -> Text
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Tok -> Bool) -> [Tok] -> [Tok]
forall a. (a -> Bool) -> [a] -> [a]
filter (Bool -> Bool
not (Bool -> Bool) -> (Tok -> Bool) -> Tok -> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Tok -> Bool
isComment) ([Tok] -> [[Char]])
-> ParsecT TokStream LaTeXState m [Tok]
-> ParsecT TokStream LaTeXState m [[Char]]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ParsecT TokStream LaTeXState m [Tok]
forall (m :: * -> *). PandocMonad m => LP m [Tok]
braced
mapM_ (insertIncluded . ensureExtension isAllowed ".tex") fs
return mempty
usepackage :: (PandocMonad m, Monoid a) => LP m a
usepackage :: forall (m :: * -> *) a. (PandocMonad m, Monoid a) => LP m a
usepackage = do
ParsecT TokStream LaTeXState m (Many Inline)
-> ParsecT TokStream LaTeXState m ()
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m ()
skipMany ParsecT TokStream LaTeXState m (Many Inline)
forall (m :: * -> *). PandocMonad m => LP m (Many Inline)
opt
fs <- (Text -> [Char]) -> [Text] -> [[Char]]
forall a b. (a -> b) -> [a] -> [b]
map (Text -> [Char]
T.unpack (Text -> [Char]) -> (Text -> Text) -> Text -> [Char]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Text -> Text
removeDoubleQuotes (Text -> Text) -> (Text -> Text) -> Text -> Text
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Text -> Text
T.strip) ([Text] -> [[Char]]) -> ([Tok] -> [Text]) -> [Tok] -> [[Char]]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. HasCallStack => Text -> Text -> [Text]
Text -> Text -> [Text]
T.splitOn Text
"," (Text -> [Text]) -> ([Tok] -> Text) -> [Tok] -> [Text]
forall b c a. (b -> c) -> (a -> b) -> a -> c
.
[Tok] -> Text
untokenize ([Tok] -> Text) -> ([Tok] -> [Tok]) -> [Tok] -> Text
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Tok -> Bool) -> [Tok] -> [Tok]
forall a. (a -> Bool) -> [a] -> [a]
filter (Bool -> Bool
not (Bool -> Bool) -> (Tok -> Bool) -> Tok -> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Tok -> Bool
isComment) ([Tok] -> [[Char]])
-> ParsecT TokStream LaTeXState m [Tok]
-> ParsecT TokStream LaTeXState m [[Char]]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ParsecT TokStream LaTeXState m [Tok]
forall (m :: * -> *). PandocMonad m => LP m [Tok]
braced
let parsePackage [Char]
f = do
TokStream _ ts <- [Char] -> LP m TokStream
forall (m :: * -> *). PandocMonad m => [Char] -> LP m TokStream
getIncludedToks (([Char] -> Bool) -> [Char] -> [Char] -> [Char]
ensureExtension ([Char] -> [Char] -> Bool
forall a. Eq a => a -> a -> Bool
== [Char]
".sty") [Char]
".sty" [Char]
f)
parseFromToks (do _ <- blocks
eof <|>
do pos <- getPosition
report $ CouldNotParseIncludeFile (T.pack f) pos)
ts
mapM_ parsePackage fs
return mempty
readFileFromTexinputs :: PandocMonad m => FilePath -> LP m (Maybe Text)
readFileFromTexinputs :: forall (m :: * -> *). PandocMonad m => [Char] -> LP m (Maybe Text)
readFileFromTexinputs [Char]
fp = do
fileContentsMap <- LaTeXState -> Map Text Text
sFileContents (LaTeXState -> Map Text Text)
-> ParsecT TokStream LaTeXState m LaTeXState
-> ParsecT TokStream LaTeXState m (Map Text Text)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ParsecT TokStream LaTeXState m LaTeXState
forall (m :: * -> *) s u. Monad m => ParsecT s u m u
getState
case M.lookup (T.pack fp) fileContentsMap of
Just Text
t -> Maybe Text -> ParsecT TokStream LaTeXState m (Maybe Text)
forall a. a -> ParsecT TokStream LaTeXState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (Text -> Maybe Text
forall a. a -> Maybe a
Just Text
t)
Maybe Text
Nothing -> do
dirs <- (Text -> [Char]) -> [Text] -> [[Char]]
forall a b. (a -> b) -> [a] -> [b]
map (\Text
t -> if Text -> Bool
T.null Text
t
then [Char]
"."
else Text -> [Char]
T.unpack Text
t)
([Text] -> [[Char]])
-> (Maybe Text -> [Text]) -> Maybe Text -> [[Char]]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Char -> Bool) -> Text -> [Text]
T.split (Char -> Char -> Bool
forall a. Eq a => a -> a -> Bool
==Char
':') (Text -> [Text]) -> (Maybe Text -> Text) -> Maybe Text -> [Text]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Text -> Maybe Text -> Text
forall a. a -> Maybe a -> a
fromMaybe Text
""
(Maybe Text -> [[Char]])
-> ParsecT TokStream LaTeXState m (Maybe Text)
-> ParsecT TokStream LaTeXState m [[Char]]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Text -> ParsecT TokStream LaTeXState m (Maybe Text)
forall (m :: * -> *). PandocMonad m => Text -> m (Maybe Text)
lookupEnv Text
"TEXINPUTS"
readFileFromDirs dirs fp
ensureExtension :: (FilePath -> Bool) -> FilePath -> FilePath -> FilePath
ensureExtension :: ([Char] -> Bool) -> [Char] -> [Char] -> [Char]
ensureExtension [Char] -> Bool
isAllowed [Char]
defaultExt [Char]
fp =
let ext :: [Char]
ext = [Char] -> [Char]
takeExtension [Char]
fp
in if [Char] -> Bool
isAllowed [Char]
ext
then [Char]
fp
else [Char] -> [Char] -> [Char]
addExtension [Char]
fp [Char]
defaultExt
getIncludedToks :: PandocMonad m
=> FilePath
-> LP m TokStream
getIncludedToks :: forall (m :: * -> *). PandocMonad m => [Char] -> LP m TokStream
getIncludedToks [Char]
f = do
pos <- ParsecT TokStream LaTeXState m SourcePos
forall (m :: * -> *) s u. Monad m => ParsecT s u m SourcePos
getPosition
containers <- getIncludeFiles <$> getState
when (T.pack f `elem` containers) $
throwError $ PandocParseError $ T.pack $ "Include file loop at " ++ show pos
updateState $ addIncludeFile $ T.pack f
mbcontents <- readFileFromTexinputs f
contents <- case mbcontents of
Just Text
s -> Text -> ParsecT TokStream LaTeXState m Text
forall a. a -> ParsecT TokStream LaTeXState m a
forall (m :: * -> *) a. Monad m => a -> m a
return Text
s
Maybe Text
Nothing -> do
LogMessage -> ParsecT TokStream LaTeXState m ()
forall (m :: * -> *). PandocMonad m => LogMessage -> m ()
report (LogMessage -> ParsecT TokStream LaTeXState m ())
-> LogMessage -> ParsecT TokStream LaTeXState m ()
forall a b. (a -> b) -> a -> b
$ Text -> SourcePos -> LogMessage
CouldNotLoadIncludeFile ([Char] -> Text
T.pack [Char]
f) SourcePos
pos
Text -> ParsecT TokStream LaTeXState m Text
forall a. a -> ParsecT TokStream LaTeXState m a
forall (m :: * -> *) a. Monad m => a -> m a
return Text
""
updateState dropLatestIncludeFile
return $ TokStream False $ tokenize (initialPos f) contents
insertIncluded :: PandocMonad m
=> FilePath
-> LP m ()
insertIncluded :: forall (m :: * -> *). PandocMonad m => [Char] -> LP m ()
insertIncluded [Char]
f = do
contents <- [Char] -> LP m TokStream
forall (m :: * -> *). PandocMonad m => [Char] -> LP m TokStream
getIncludedToks [Char]
f
ts <- getInput
setInput $ contents <> ts
authors :: PandocMonad m => LP m ()
authors :: forall (m :: * -> *). PandocMonad m => LP m ()
authors = ParsecT TokStream LaTeXState m ()
-> ParsecT TokStream LaTeXState m ()
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try (ParsecT TokStream LaTeXState m ()
-> ParsecT TokStream LaTeXState m ())
-> ParsecT TokStream LaTeXState m ()
-> ParsecT TokStream LaTeXState m ()
forall a b. (a -> b) -> a -> b
$ do
LP m Tok
forall (m :: * -> *). PandocMonad m => LP m Tok
bgroup
let oneAuthor :: ParsecT TokStream LaTeXState m (Many Inline)
oneAuthor = [Block] -> Many Inline
blocksToInlines' ([Block] -> Many Inline)
-> ([Many Block] -> [Block]) -> [Many Block] -> Many Inline
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Many Block -> [Block]
forall a. Many a -> [a]
B.toList (Many Block -> [Block])
-> ([Many Block] -> Many Block) -> [Many Block] -> [Block]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [Many Block] -> Many Block
forall a. Monoid a => [a] -> a
mconcat ([Many Block] -> Many Inline)
-> ParsecT TokStream LaTeXState m [Many Block]
-> ParsecT TokStream LaTeXState m (Many Inline)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ParsecT TokStream LaTeXState m (Many Block)
-> ParsecT TokStream LaTeXState m [Many Block]
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m [a]
many1 ParsecT TokStream LaTeXState m (Many Block)
forall (m :: * -> *). PandocMonad m => LP m (Many Block)
block
auths <- ParsecT TokStream LaTeXState m (Many Inline)
-> LP m Tok -> ParsecT TokStream LaTeXState m [Many Inline]
forall s (m :: * -> *) t u a end.
Stream s m t =>
ParsecT s u m a -> ParsecT s u m end -> ParsecT s u m [a]
sepBy ParsecT TokStream LaTeXState m (Many Inline)
oneAuthor (Text -> LP m Tok
forall (m :: * -> *). PandocMonad m => Text -> LP m Tok
controlSeq Text
"and")
egroup
addMeta "author" (map trimInlines auths)
looseItem :: PandocMonad m => LP m Blocks
looseItem :: forall (m :: * -> *). PandocMonad m => LP m (Many Block)
looseItem = do
inListItem <- LaTeXState -> Bool
sInListItem (LaTeXState -> Bool)
-> ParsecT TokStream LaTeXState m LaTeXState
-> ParsecT TokStream LaTeXState m Bool
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ParsecT TokStream LaTeXState m LaTeXState
forall (m :: * -> *) s u. Monad m => ParsecT s u m u
getState
guard $ not inListItem
skipopts
return mempty
epigraph :: PandocMonad m => LP m Blocks
epigraph :: forall (m :: * -> *). PandocMonad m => LP m (Many Block)
epigraph = do
p1 <- LP m (Many Block) -> LP m (Many Block)
forall (m :: * -> *) a.
(PandocMonad m, Monoid a) =>
LP m a -> LP m a
grouped LP m (Many Block)
forall (m :: * -> *). PandocMonad m => LP m (Many Block)
block
p2 <- grouped block
return $ divWith ("", ["epigraph"], []) (p1 <> p2)
section :: PandocMonad m => Attr -> Int -> LP m Blocks
section :: forall (m :: * -> *).
PandocMonad m =>
Attr -> Int -> LP m (Many Block)
section (Text
ident, [Text]
classes, [(Text, Text)]
kvs) Int
lvl = do
LP m ()
forall (m :: * -> *). PandocMonad m => LP m ()
skipopts
contents <- LP m (Many Inline) -> LP m (Many Inline)
forall (m :: * -> *) a.
(PandocMonad m, Monoid a) =>
LP m a -> LP m a
grouped LP m (Many Inline)
forall (m :: * -> *). PandocMonad m => LP m (Many Inline)
inline
lab <- option ident $
try (spaces >> controlSeq "label"
>> spaces >> untokenize <$> braced)
when (lvl == 0) $
updateState $ \LaTeXState
st -> LaTeXState
st{ sHasChapters = True }
unless ("unnumbered" `elem` classes) $ do
hn <- sLastHeaderNum <$> getState
hasChapters <- sHasChapters <$> getState
let lvl' = Int
lvl Int -> Int -> Int
forall a. Num a => a -> a -> a
+ if Bool
hasChapters then Int
1 else Int
0
let num = Int -> DottedNum -> DottedNum
incrementDottedNum Int
lvl' DottedNum
hn
updateState $ \LaTeXState
st -> LaTeXState
st{ sLastHeaderNum = num
, sLabels = M.insert lab
[Str (renderDottedNum num)]
(sLabels st) }
attr' <- registerHeader (lab, classes, kvs) contents
return $ headerWith attr' lvl contents
blockCommand :: PandocMonad m => LP m Blocks
blockCommand :: forall (m :: * -> *). PandocMonad m => LP m (Many Block)
blockCommand = ParsecT TokStream LaTeXState m (Many Block)
-> ParsecT TokStream LaTeXState m (Many Block)
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try (ParsecT TokStream LaTeXState m (Many Block)
-> ParsecT TokStream LaTeXState m (Many Block))
-> ParsecT TokStream LaTeXState m (Many Block)
-> ParsecT TokStream LaTeXState m (Many Block)
forall a b. (a -> b) -> a -> b
$ do
Tok _ (CtrlSeq name) txt <- LP m Tok
forall (m :: * -> *). PandocMonad m => LP m Tok
anyControlSeq
guard $ name /= "begin" && name /= "end" && name /= "and"
star <- option "" ("*" <$ symbol '*' <* sp)
let name' = Text
name Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
star
let names = [Text] -> [Text]
forall a. Ord a => [a] -> [a]
nubOrd [Text
name', Text
name]
let rawDefiniteBlock = do
Bool -> ParsecT TokStream LaTeXState m ()
forall (f :: * -> *). Alternative f => Bool -> f ()
guard (Bool -> ParsecT TokStream LaTeXState m ())
-> Bool -> ParsecT TokStream LaTeXState m ()
forall a b. (a -> b) -> a -> b
$ Text -> Bool
isBlockCommand Text
name
rawcontents <- Text -> Text -> ParsecT TokStream LaTeXState m Text
forall (m :: * -> *). PandocMonad m => Text -> Text -> LP m Text
getRawCommand Text
name (Text
txt Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
star)
(guardEnabled Ext_raw_tex >> return (rawBlock "latex" rawcontents))
<|> ignore rawcontents
let startCommand = ParsecT TokStream LaTeXState m ()
-> ParsecT TokStream LaTeXState m ()
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try (ParsecT TokStream LaTeXState m ()
-> ParsecT TokStream LaTeXState m ())
-> ParsecT TokStream LaTeXState m ()
-> ParsecT TokStream LaTeXState m ()
forall a b. (a -> b) -> a -> b
$ do
Tok _ (CtrlSeq n) _ <- LP m Tok
forall (m :: * -> *). PandocMonad m => LP m Tok
anyControlSeq
guard $ "start" `T.isPrefixOf` n
let rawMaybeBlock = ParsecT TokStream LaTeXState m (Many Block)
-> ParsecT TokStream LaTeXState m (Many Block)
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try (ParsecT TokStream LaTeXState m (Many Block)
-> ParsecT TokStream LaTeXState m (Many Block))
-> ParsecT TokStream LaTeXState m (Many Block)
-> ParsecT TokStream LaTeXState m (Many Block)
forall a b. (a -> b) -> a -> b
$ do
Bool -> ParsecT TokStream LaTeXState m ()
forall (f :: * -> *). Alternative f => Bool -> f ()
guard (Bool -> ParsecT TokStream LaTeXState m ())
-> Bool -> ParsecT TokStream LaTeXState m ()
forall a b. (a -> b) -> a -> b
$ Bool -> Bool
not (Bool -> Bool) -> Bool -> Bool
forall a b. (a -> b) -> a -> b
$ Text -> Bool
isInlineCommand Text
name
rawcontents <- Text -> Text -> ParsecT TokStream LaTeXState m Text
forall (m :: * -> *). PandocMonad m => Text -> Text -> LP m Text
getRawCommand Text
name (Text
txt Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
star)
curr <- (guardEnabled Ext_raw_tex >>
return (rawBlock "latex" rawcontents))
<|> ignore rawcontents
rest <- many $ notFollowedBy startCommand *> blockCommand
lookAhead $ blankline <|> startCommand
return $ curr <> mconcat rest
let raw = ParsecT TokStream LaTeXState m (Many Block)
rawDefiniteBlock ParsecT TokStream LaTeXState m (Many Block)
-> ParsecT TokStream LaTeXState m (Many Block)
-> ParsecT TokStream LaTeXState m (Many Block)
forall a.
ParsecT TokStream LaTeXState m a
-> ParsecT TokStream LaTeXState m a
-> ParsecT TokStream LaTeXState m a
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> ParsecT TokStream LaTeXState m (Many Block)
rawMaybeBlock
lookupListDefault raw names blockCommands
closing :: PandocMonad m => LP m Blocks
closing :: forall (m :: * -> *). PandocMonad m => LP m (Many Block)
closing = do
contents <- LP m (Many Inline)
forall (m :: * -> *). PandocMonad m => LP m (Many Inline)
tok
st <- getState
let extractInlines (MetaBlocks [Plain [Inline]
ys]) = [Inline]
ys
extractInlines (MetaBlocks [Para [Inline]
ys ]) = [Inline]
ys
extractInlines MetaValue
_ = []
let sigs = case Text -> Meta -> Maybe MetaValue
lookupMeta Text
"author" (LaTeXState -> Meta
sMeta LaTeXState
st) of
Just (MetaList [MetaValue]
xs) ->
Many Inline -> Many Block
para (Many Inline -> Many Block) -> Many Inline -> Many Block
forall a b. (a -> b) -> a -> b
$ Many Inline -> Many Inline
trimInlines (Many Inline -> Many Inline) -> Many Inline -> Many Inline
forall a b. (a -> b) -> a -> b
$ [Inline] -> Many Inline
forall a. [a] -> Many a
fromList ([Inline] -> Many Inline) -> [Inline] -> Many Inline
forall a b. (a -> b) -> a -> b
$
[Inline] -> [[Inline]] -> [Inline]
forall a. [a] -> [[a]] -> [a]
intercalate [Inline
LineBreak] ([[Inline]] -> [Inline]) -> [[Inline]] -> [Inline]
forall a b. (a -> b) -> a -> b
$ (MetaValue -> [Inline]) -> [MetaValue] -> [[Inline]]
forall a b. (a -> b) -> [a] -> [b]
map MetaValue -> [Inline]
extractInlines [MetaValue]
xs
Maybe MetaValue
_ -> Many Block
forall a. Monoid a => a
mempty
return $ para (trimInlines contents) <> sigs
parbox :: PandocMonad m => LP m Blocks
parbox :: forall (m :: * -> *). PandocMonad m => LP m (Many Block)
parbox = ParsecT TokStream LaTeXState m (Many Block)
-> ParsecT TokStream LaTeXState m (Many Block)
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try (ParsecT TokStream LaTeXState m (Many Block)
-> ParsecT TokStream LaTeXState m (Many Block))
-> ParsecT TokStream LaTeXState m (Many Block)
-> ParsecT TokStream LaTeXState m (Many Block)
forall a b. (a -> b) -> a -> b
$ do
LP m ()
forall (m :: * -> *). PandocMonad m => LP m ()
skipopts
LP m [Tok]
forall (m :: * -> *). PandocMonad m => LP m [Tok]
braced
oldInTableCell <- LaTeXState -> Bool
sInTableCell (LaTeXState -> Bool)
-> ParsecT TokStream LaTeXState m LaTeXState
-> ParsecT TokStream LaTeXState m Bool
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ParsecT TokStream LaTeXState m LaTeXState
forall (m :: * -> *) s u. Monad m => ParsecT s u m u
getState
updateState $ \LaTeXState
st -> LaTeXState
st{ sInTableCell = False }
res <- grouped block
updateState $ \LaTeXState
st -> LaTeXState
st{ sInTableCell = oldInTableCell }
return res
blockCommands :: PandocMonad m => M.Map Text (LP m Blocks)
blockCommands :: forall (m :: * -> *). PandocMonad m => Map Text (LP m (Many Block))
blockCommands = [(Text, LP m (Many Block))] -> Map Text (LP m (Many Block))
forall k a. Ord k => [(k, a)] -> Map k a
M.fromList
[ (Text
"par", Many Block
forall a. Monoid a => a
mempty Many Block
-> ParsecT TokStream LaTeXState m () -> LP m (Many Block)
forall a b.
a
-> ParsecT TokStream LaTeXState m b
-> ParsecT TokStream LaTeXState m a
forall (f :: * -> *) a b. Functor f => a -> f b -> f a
<$ ParsecT TokStream LaTeXState m ()
forall (m :: * -> *). PandocMonad m => LP m ()
skipopts)
, (Text
"parbox", LP m (Many Block)
forall (m :: * -> *). PandocMonad m => LP m (Many Block)
parbox)
, (Text
"title", Many Block
forall a. Monoid a => a
mempty Many Block
-> ParsecT TokStream LaTeXState m () -> LP m (Many Block)
forall a b.
a
-> ParsecT TokStream LaTeXState m b
-> ParsecT TokStream LaTeXState m a
forall (f :: * -> *) a b. Functor f => a -> f b -> f a
<$ (ParsecT TokStream LaTeXState m ()
forall (m :: * -> *). PandocMonad m => LP m ()
skipopts ParsecT TokStream LaTeXState m ()
-> ParsecT TokStream LaTeXState m ()
-> ParsecT TokStream LaTeXState m ()
forall a b.
ParsecT TokStream LaTeXState m a
-> ParsecT TokStream LaTeXState m b
-> ParsecT TokStream LaTeXState m b
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*>
(LP m (Many Inline) -> LP m (Many Inline)
forall (m :: * -> *) a.
(PandocMonad m, Monoid a) =>
LP m a -> LP m a
grouped LP m (Many Inline)
forall (m :: * -> *). PandocMonad m => LP m (Many Inline)
inline LP m (Many Inline)
-> (Many Inline -> ParsecT TokStream LaTeXState m ())
-> ParsecT TokStream LaTeXState m ()
forall a b.
ParsecT TokStream LaTeXState m a
-> (a -> ParsecT TokStream LaTeXState m b)
-> ParsecT TokStream LaTeXState m b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= Text -> Many Inline -> ParsecT TokStream LaTeXState m ()
forall (m :: * -> *) a.
(PandocMonad m, ToMetaValue a) =>
Text -> a -> LP m ()
addMeta Text
"title")
ParsecT TokStream LaTeXState m ()
-> ParsecT TokStream LaTeXState m ()
-> ParsecT TokStream LaTeXState m ()
forall a.
ParsecT TokStream LaTeXState m a
-> ParsecT TokStream LaTeXState m a
-> ParsecT TokStream LaTeXState m a
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> (LP m (Many Block) -> LP m (Many Block)
forall (m :: * -> *) a.
(PandocMonad m, Monoid a) =>
LP m a -> LP m a
grouped LP m (Many Block)
forall (m :: * -> *). PandocMonad m => LP m (Many Block)
block LP m (Many Block)
-> (Many Block -> ParsecT TokStream LaTeXState m ())
-> ParsecT TokStream LaTeXState m ()
forall a b.
ParsecT TokStream LaTeXState m a
-> (a -> ParsecT TokStream LaTeXState m b)
-> ParsecT TokStream LaTeXState m b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= Text -> Many Block -> ParsecT TokStream LaTeXState m ()
forall (m :: * -> *) a.
(PandocMonad m, ToMetaValue a) =>
Text -> a -> LP m ()
addMeta Text
"title")))
, (Text
"subtitle", Many Block
forall a. Monoid a => a
mempty Many Block
-> ParsecT TokStream LaTeXState m () -> LP m (Many Block)
forall a b.
a
-> ParsecT TokStream LaTeXState m b
-> ParsecT TokStream LaTeXState m a
forall (f :: * -> *) a b. Functor f => a -> f b -> f a
<$ (ParsecT TokStream LaTeXState m ()
forall (m :: * -> *). PandocMonad m => LP m ()
skipopts ParsecT TokStream LaTeXState m ()
-> LP m (Many Inline) -> LP m (Many Inline)
forall a b.
ParsecT TokStream LaTeXState m a
-> ParsecT TokStream LaTeXState m b
-> ParsecT TokStream LaTeXState m b
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> LP m (Many Inline)
forall (m :: * -> *). PandocMonad m => LP m (Many Inline)
tok LP m (Many Inline)
-> (Many Inline -> ParsecT TokStream LaTeXState m ())
-> ParsecT TokStream LaTeXState m ()
forall a b.
ParsecT TokStream LaTeXState m a
-> (a -> ParsecT TokStream LaTeXState m b)
-> ParsecT TokStream LaTeXState m b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= Text -> Many Inline -> ParsecT TokStream LaTeXState m ()
forall (m :: * -> *) a.
(PandocMonad m, ToMetaValue a) =>
Text -> a -> LP m ()
addMeta Text
"subtitle"))
, (Text
"author", Many Block
forall a. Monoid a => a
mempty Many Block
-> ParsecT TokStream LaTeXState m () -> LP m (Many Block)
forall a b.
a
-> ParsecT TokStream LaTeXState m b
-> ParsecT TokStream LaTeXState m a
forall (f :: * -> *) a b. Functor f => a -> f b -> f a
<$ (ParsecT TokStream LaTeXState m ()
forall (m :: * -> *). PandocMonad m => LP m ()
skipopts ParsecT TokStream LaTeXState m ()
-> ParsecT TokStream LaTeXState m ()
-> ParsecT TokStream LaTeXState m ()
forall a b.
ParsecT TokStream LaTeXState m a
-> ParsecT TokStream LaTeXState m b
-> ParsecT TokStream LaTeXState m b
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> ParsecT TokStream LaTeXState m ()
forall (m :: * -> *). PandocMonad m => LP m ()
authors))
, (Text
"address", Many Block
forall a. Monoid a => a
mempty Many Block
-> ParsecT TokStream LaTeXState m () -> LP m (Many Block)
forall a b.
a
-> ParsecT TokStream LaTeXState m b
-> ParsecT TokStream LaTeXState m a
forall (f :: * -> *) a b. Functor f => a -> f b -> f a
<$ (ParsecT TokStream LaTeXState m ()
forall (m :: * -> *). PandocMonad m => LP m ()
skipopts ParsecT TokStream LaTeXState m ()
-> LP m (Many Inline) -> LP m (Many Inline)
forall a b.
ParsecT TokStream LaTeXState m a
-> ParsecT TokStream LaTeXState m b
-> ParsecT TokStream LaTeXState m b
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> LP m (Many Inline)
forall (m :: * -> *). PandocMonad m => LP m (Many Inline)
tok LP m (Many Inline)
-> (Many Inline -> ParsecT TokStream LaTeXState m ())
-> ParsecT TokStream LaTeXState m ()
forall a b.
ParsecT TokStream LaTeXState m a
-> (a -> ParsecT TokStream LaTeXState m b)
-> ParsecT TokStream LaTeXState m b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= Text -> Many Inline -> ParsecT TokStream LaTeXState m ()
forall (m :: * -> *) a.
(PandocMonad m, ToMetaValue a) =>
Text -> a -> LP m ()
addMeta Text
"address"))
, (Text
"signature", Many Block
forall a. Monoid a => a
mempty Many Block
-> ParsecT TokStream LaTeXState m () -> LP m (Many Block)
forall a b.
a
-> ParsecT TokStream LaTeXState m b
-> ParsecT TokStream LaTeXState m a
forall (f :: * -> *) a b. Functor f => a -> f b -> f a
<$ (ParsecT TokStream LaTeXState m ()
forall (m :: * -> *). PandocMonad m => LP m ()
skipopts ParsecT TokStream LaTeXState m ()
-> ParsecT TokStream LaTeXState m ()
-> ParsecT TokStream LaTeXState m ()
forall a b.
ParsecT TokStream LaTeXState m a
-> ParsecT TokStream LaTeXState m b
-> ParsecT TokStream LaTeXState m b
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> ParsecT TokStream LaTeXState m ()
forall (m :: * -> *). PandocMonad m => LP m ()
authors))
, (Text
"date", Many Block
forall a. Monoid a => a
mempty Many Block
-> ParsecT TokStream LaTeXState m () -> LP m (Many Block)
forall a b.
a
-> ParsecT TokStream LaTeXState m b
-> ParsecT TokStream LaTeXState m a
forall (f :: * -> *) a b. Functor f => a -> f b -> f a
<$ (ParsecT TokStream LaTeXState m ()
forall (m :: * -> *). PandocMonad m => LP m ()
skipopts ParsecT TokStream LaTeXState m ()
-> LP m (Many Inline) -> LP m (Many Inline)
forall a b.
ParsecT TokStream LaTeXState m a
-> ParsecT TokStream LaTeXState m b
-> ParsecT TokStream LaTeXState m b
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> LP m (Many Inline)
forall (m :: * -> *). PandocMonad m => LP m (Many Inline)
tok LP m (Many Inline)
-> (Many Inline -> ParsecT TokStream LaTeXState m ())
-> ParsecT TokStream LaTeXState m ()
forall a b.
ParsecT TokStream LaTeXState m a
-> (a -> ParsecT TokStream LaTeXState m b)
-> ParsecT TokStream LaTeXState m b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= Text -> Many Inline -> ParsecT TokStream LaTeXState m ()
forall (m :: * -> *) a.
(PandocMonad m, ToMetaValue a) =>
Text -> a -> LP m ()
addMeta Text
"date"))
, (Text
"newtheorem", LP m (Many Inline) -> LP m (Many Block)
forall (m :: * -> *).
PandocMonad m =>
LP m (Many Inline) -> LP m (Many Block)
newtheorem LP m (Many Inline)
forall (m :: * -> *). PandocMonad m => LP m (Many Inline)
inline)
, (Text
"theoremstyle", LP m (Many Block)
forall (m :: * -> *). PandocMonad m => LP m (Many Block)
theoremstyle)
, (Text
"extratitle", Many Block
forall a. Monoid a => a
mempty Many Block
-> ParsecT TokStream LaTeXState m () -> LP m (Many Block)
forall a b.
a
-> ParsecT TokStream LaTeXState m b
-> ParsecT TokStream LaTeXState m a
forall (f :: * -> *) a b. Functor f => a -> f b -> f a
<$ (ParsecT TokStream LaTeXState m ()
forall (m :: * -> *). PandocMonad m => LP m ()
skipopts ParsecT TokStream LaTeXState m ()
-> LP m (Many Inline) -> LP m (Many Inline)
forall a b.
ParsecT TokStream LaTeXState m a
-> ParsecT TokStream LaTeXState m b
-> ParsecT TokStream LaTeXState m b
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> LP m (Many Inline)
forall (m :: * -> *). PandocMonad m => LP m (Many Inline)
tok LP m (Many Inline)
-> (Many Inline -> ParsecT TokStream LaTeXState m ())
-> ParsecT TokStream LaTeXState m ()
forall a b.
ParsecT TokStream LaTeXState m a
-> (a -> ParsecT TokStream LaTeXState m b)
-> ParsecT TokStream LaTeXState m b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= Text -> Many Inline -> ParsecT TokStream LaTeXState m ()
forall (m :: * -> *) a.
(PandocMonad m, ToMetaValue a) =>
Text -> a -> LP m ()
addMeta Text
"extratitle"))
, (Text
"frontispiece", Many Block
forall a. Monoid a => a
mempty Many Block
-> ParsecT TokStream LaTeXState m () -> LP m (Many Block)
forall a b.
a
-> ParsecT TokStream LaTeXState m b
-> ParsecT TokStream LaTeXState m a
forall (f :: * -> *) a b. Functor f => a -> f b -> f a
<$ (ParsecT TokStream LaTeXState m ()
forall (m :: * -> *). PandocMonad m => LP m ()
skipopts ParsecT TokStream LaTeXState m ()
-> LP m (Many Inline) -> LP m (Many Inline)
forall a b.
ParsecT TokStream LaTeXState m a
-> ParsecT TokStream LaTeXState m b
-> ParsecT TokStream LaTeXState m b
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> LP m (Many Inline)
forall (m :: * -> *). PandocMonad m => LP m (Many Inline)
tok LP m (Many Inline)
-> (Many Inline -> ParsecT TokStream LaTeXState m ())
-> ParsecT TokStream LaTeXState m ()
forall a b.
ParsecT TokStream LaTeXState m a
-> (a -> ParsecT TokStream LaTeXState m b)
-> ParsecT TokStream LaTeXState m b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= Text -> Many Inline -> ParsecT TokStream LaTeXState m ()
forall (m :: * -> *) a.
(PandocMonad m, ToMetaValue a) =>
Text -> a -> LP m ()
addMeta Text
"frontispiece"))
, (Text
"titlehead", Many Block
forall a. Monoid a => a
mempty Many Block
-> ParsecT TokStream LaTeXState m () -> LP m (Many Block)
forall a b.
a
-> ParsecT TokStream LaTeXState m b
-> ParsecT TokStream LaTeXState m a
forall (f :: * -> *) a b. Functor f => a -> f b -> f a
<$ (ParsecT TokStream LaTeXState m ()
forall (m :: * -> *). PandocMonad m => LP m ()
skipopts ParsecT TokStream LaTeXState m ()
-> LP m (Many Inline) -> LP m (Many Inline)
forall a b.
ParsecT TokStream LaTeXState m a
-> ParsecT TokStream LaTeXState m b
-> ParsecT TokStream LaTeXState m b
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> LP m (Many Inline)
forall (m :: * -> *). PandocMonad m => LP m (Many Inline)
tok LP m (Many Inline)
-> (Many Inline -> ParsecT TokStream LaTeXState m ())
-> ParsecT TokStream LaTeXState m ()
forall a b.
ParsecT TokStream LaTeXState m a
-> (a -> ParsecT TokStream LaTeXState m b)
-> ParsecT TokStream LaTeXState m b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= Text -> Many Inline -> ParsecT TokStream LaTeXState m ()
forall (m :: * -> *) a.
(PandocMonad m, ToMetaValue a) =>
Text -> a -> LP m ()
addMeta Text
"titlehead"))
, (Text
"subject", Many Block
forall a. Monoid a => a
mempty Many Block
-> ParsecT TokStream LaTeXState m () -> LP m (Many Block)
forall a b.
a
-> ParsecT TokStream LaTeXState m b
-> ParsecT TokStream LaTeXState m a
forall (f :: * -> *) a b. Functor f => a -> f b -> f a
<$ (ParsecT TokStream LaTeXState m ()
forall (m :: * -> *). PandocMonad m => LP m ()
skipopts ParsecT TokStream LaTeXState m ()
-> LP m (Many Inline) -> LP m (Many Inline)
forall a b.
ParsecT TokStream LaTeXState m a
-> ParsecT TokStream LaTeXState m b
-> ParsecT TokStream LaTeXState m b
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> LP m (Many Inline)
forall (m :: * -> *). PandocMonad m => LP m (Many Inline)
tok LP m (Many Inline)
-> (Many Inline -> ParsecT TokStream LaTeXState m ())
-> ParsecT TokStream LaTeXState m ()
forall a b.
ParsecT TokStream LaTeXState m a
-> (a -> ParsecT TokStream LaTeXState m b)
-> ParsecT TokStream LaTeXState m b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= Text -> Many Inline -> ParsecT TokStream LaTeXState m ()
forall (m :: * -> *) a.
(PandocMonad m, ToMetaValue a) =>
Text -> a -> LP m ()
addMeta Text
"subject"))
, (Text
"publishers", Many Block
forall a. Monoid a => a
mempty Many Block
-> ParsecT TokStream LaTeXState m () -> LP m (Many Block)
forall a b.
a
-> ParsecT TokStream LaTeXState m b
-> ParsecT TokStream LaTeXState m a
forall (f :: * -> *) a b. Functor f => a -> f b -> f a
<$ (ParsecT TokStream LaTeXState m ()
forall (m :: * -> *). PandocMonad m => LP m ()
skipopts ParsecT TokStream LaTeXState m ()
-> LP m (Many Inline) -> LP m (Many Inline)
forall a b.
ParsecT TokStream LaTeXState m a
-> ParsecT TokStream LaTeXState m b
-> ParsecT TokStream LaTeXState m b
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> LP m (Many Inline)
forall (m :: * -> *). PandocMonad m => LP m (Many Inline)
tok LP m (Many Inline)
-> (Many Inline -> ParsecT TokStream LaTeXState m ())
-> ParsecT TokStream LaTeXState m ()
forall a b.
ParsecT TokStream LaTeXState m a
-> (a -> ParsecT TokStream LaTeXState m b)
-> ParsecT TokStream LaTeXState m b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= Text -> Many Inline -> ParsecT TokStream LaTeXState m ()
forall (m :: * -> *) a.
(PandocMonad m, ToMetaValue a) =>
Text -> a -> LP m ()
addMeta Text
"publishers"))
, (Text
"uppertitleback", Many Block
forall a. Monoid a => a
mempty Many Block
-> ParsecT TokStream LaTeXState m () -> LP m (Many Block)
forall a b.
a
-> ParsecT TokStream LaTeXState m b
-> ParsecT TokStream LaTeXState m a
forall (f :: * -> *) a b. Functor f => a -> f b -> f a
<$ (ParsecT TokStream LaTeXState m ()
forall (m :: * -> *). PandocMonad m => LP m ()
skipopts ParsecT TokStream LaTeXState m ()
-> LP m (Many Inline) -> LP m (Many Inline)
forall a b.
ParsecT TokStream LaTeXState m a
-> ParsecT TokStream LaTeXState m b
-> ParsecT TokStream LaTeXState m b
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> LP m (Many Inline)
forall (m :: * -> *). PandocMonad m => LP m (Many Inline)
tok LP m (Many Inline)
-> (Many Inline -> ParsecT TokStream LaTeXState m ())
-> ParsecT TokStream LaTeXState m ()
forall a b.
ParsecT TokStream LaTeXState m a
-> (a -> ParsecT TokStream LaTeXState m b)
-> ParsecT TokStream LaTeXState m b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= Text -> Many Inline -> ParsecT TokStream LaTeXState m ()
forall (m :: * -> *) a.
(PandocMonad m, ToMetaValue a) =>
Text -> a -> LP m ()
addMeta Text
"uppertitleback"))
, (Text
"lowertitleback", Many Block
forall a. Monoid a => a
mempty Many Block
-> ParsecT TokStream LaTeXState m () -> LP m (Many Block)
forall a b.
a
-> ParsecT TokStream LaTeXState m b
-> ParsecT TokStream LaTeXState m a
forall (f :: * -> *) a b. Functor f => a -> f b -> f a
<$ (ParsecT TokStream LaTeXState m ()
forall (m :: * -> *). PandocMonad m => LP m ()
skipopts ParsecT TokStream LaTeXState m ()
-> LP m (Many Inline) -> LP m (Many Inline)
forall a b.
ParsecT TokStream LaTeXState m a
-> ParsecT TokStream LaTeXState m b
-> ParsecT TokStream LaTeXState m b
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> LP m (Many Inline)
forall (m :: * -> *). PandocMonad m => LP m (Many Inline)
tok LP m (Many Inline)
-> (Many Inline -> ParsecT TokStream LaTeXState m ())
-> ParsecT TokStream LaTeXState m ()
forall a b.
ParsecT TokStream LaTeXState m a
-> (a -> ParsecT TokStream LaTeXState m b)
-> ParsecT TokStream LaTeXState m b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= Text -> Many Inline -> ParsecT TokStream LaTeXState m ()
forall (m :: * -> *) a.
(PandocMonad m, ToMetaValue a) =>
Text -> a -> LP m ()
addMeta Text
"lowertitleback"))
, (Text
"dedication", Many Block
forall a. Monoid a => a
mempty Many Block
-> ParsecT TokStream LaTeXState m () -> LP m (Many Block)
forall a b.
a
-> ParsecT TokStream LaTeXState m b
-> ParsecT TokStream LaTeXState m a
forall (f :: * -> *) a b. Functor f => a -> f b -> f a
<$ (ParsecT TokStream LaTeXState m ()
forall (m :: * -> *). PandocMonad m => LP m ()
skipopts ParsecT TokStream LaTeXState m ()
-> LP m (Many Inline) -> LP m (Many Inline)
forall a b.
ParsecT TokStream LaTeXState m a
-> ParsecT TokStream LaTeXState m b
-> ParsecT TokStream LaTeXState m b
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> LP m (Many Inline)
forall (m :: * -> *). PandocMonad m => LP m (Many Inline)
tok LP m (Many Inline)
-> (Many Inline -> ParsecT TokStream LaTeXState m ())
-> ParsecT TokStream LaTeXState m ()
forall a b.
ParsecT TokStream LaTeXState m a
-> (a -> ParsecT TokStream LaTeXState m b)
-> ParsecT TokStream LaTeXState m b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= Text -> Many Inline -> ParsecT TokStream LaTeXState m ()
forall (m :: * -> *) a.
(PandocMonad m, ToMetaValue a) =>
Text -> a -> LP m ()
addMeta Text
"dedication"))
, (Text
"part", Attr -> Int -> LP m (Many Block)
forall (m :: * -> *).
PandocMonad m =>
Attr -> Int -> LP m (Many Block)
section Attr
nullAttr (-Int
1))
, (Text
"part*", Attr -> Int -> LP m (Many Block)
forall (m :: * -> *).
PandocMonad m =>
Attr -> Int -> LP m (Many Block)
section (Text
"",[Text
"unnumbered"],[]) (-Int
1))
, (Text
"chapter", Attr -> Int -> LP m (Many Block)
forall (m :: * -> *).
PandocMonad m =>
Attr -> Int -> LP m (Many Block)
section Attr
nullAttr Int
0)
, (Text
"chapter*", Attr -> Int -> LP m (Many Block)
forall (m :: * -> *).
PandocMonad m =>
Attr -> Int -> LP m (Many Block)
section (Text
"",[Text
"unnumbered"],[]) Int
0)
, (Text
"section", Attr -> Int -> LP m (Many Block)
forall (m :: * -> *).
PandocMonad m =>
Attr -> Int -> LP m (Many Block)
section Attr
nullAttr Int
1)
, (Text
"section*", Attr -> Int -> LP m (Many Block)
forall (m :: * -> *).
PandocMonad m =>
Attr -> Int -> LP m (Many Block)
section (Text
"",[Text
"unnumbered"],[]) Int
1)
, (Text
"subsection", Attr -> Int -> LP m (Many Block)
forall (m :: * -> *).
PandocMonad m =>
Attr -> Int -> LP m (Many Block)
section Attr
nullAttr Int
2)
, (Text
"subsection*", Attr -> Int -> LP m (Many Block)
forall (m :: * -> *).
PandocMonad m =>
Attr -> Int -> LP m (Many Block)
section (Text
"",[Text
"unnumbered"],[]) Int
2)
, (Text
"subsubsection", Attr -> Int -> LP m (Many Block)
forall (m :: * -> *).
PandocMonad m =>
Attr -> Int -> LP m (Many Block)
section Attr
nullAttr Int
3)
, (Text
"subsubsection*", Attr -> Int -> LP m (Many Block)
forall (m :: * -> *).
PandocMonad m =>
Attr -> Int -> LP m (Many Block)
section (Text
"",[Text
"unnumbered"],[]) Int
3)
, (Text
"paragraph", Attr -> Int -> LP m (Many Block)
forall (m :: * -> *).
PandocMonad m =>
Attr -> Int -> LP m (Many Block)
section Attr
nullAttr Int
4)
, (Text
"paragraph*", Attr -> Int -> LP m (Many Block)
forall (m :: * -> *).
PandocMonad m =>
Attr -> Int -> LP m (Many Block)
section (Text
"",[Text
"unnumbered"],[]) Int
4)
, (Text
"subparagraph", Attr -> Int -> LP m (Many Block)
forall (m :: * -> *).
PandocMonad m =>
Attr -> Int -> LP m (Many Block)
section Attr
nullAttr Int
5)
, (Text
"subparagraph*", Attr -> Int -> LP m (Many Block)
forall (m :: * -> *).
PandocMonad m =>
Attr -> Int -> LP m (Many Block)
section (Text
"",[Text
"unnumbered"],[]) Int
5)
, (Text
"minisec", Attr -> Int -> LP m (Many Block)
forall (m :: * -> *).
PandocMonad m =>
Attr -> Int -> LP m (Many Block)
section (Text
"",[Text
"unnumbered",Text
"unlisted"],[]) Int
6)
, (Text
"frametitle", Attr -> Int -> LP m (Many Block)
forall (m :: * -> *).
PandocMonad m =>
Attr -> Int -> LP m (Many Block)
section Attr
nullAttr Int
3)
, (Text
"framesubtitle", Attr -> Int -> LP m (Many Block)
forall (m :: * -> *).
PandocMonad m =>
Attr -> Int -> LP m (Many Block)
section Attr
nullAttr Int
4)
, (Text
"opening", Many Inline -> Many Block
para (Many Inline -> Many Block)
-> (Many Inline -> Many Inline) -> Many Inline -> Many Block
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Many Inline -> Many Inline
trimInlines (Many Inline -> Many Block)
-> LP m (Many Inline) -> LP m (Many Block)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (ParsecT TokStream LaTeXState m ()
forall (m :: * -> *). PandocMonad m => LP m ()
skipopts ParsecT TokStream LaTeXState m ()
-> LP m (Many Inline) -> LP m (Many Inline)
forall a b.
ParsecT TokStream LaTeXState m a
-> ParsecT TokStream LaTeXState m b
-> ParsecT TokStream LaTeXState m b
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> LP m (Many Inline)
forall (m :: * -> *). PandocMonad m => LP m (Many Inline)
tok))
, (Text
"closing", ParsecT TokStream LaTeXState m ()
forall (m :: * -> *). PandocMonad m => LP m ()
skipopts ParsecT TokStream LaTeXState m ()
-> LP m (Many Block) -> LP m (Many Block)
forall a b.
ParsecT TokStream LaTeXState m a
-> ParsecT TokStream LaTeXState m b
-> ParsecT TokStream LaTeXState m b
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> LP m (Many Block)
forall (m :: * -> *). PandocMonad m => LP m (Many Block)
closing)
, (Text
"plainbreak", LP m [Tok]
forall (m :: * -> *). PandocMonad m => LP m [Tok]
braced LP m [Tok] -> LP m (Many Block) -> LP m (Many Block)
forall a b.
ParsecT TokStream LaTeXState m a
-> ParsecT TokStream LaTeXState m b
-> ParsecT TokStream LaTeXState m b
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> Many Block -> LP m (Many Block)
forall a. a -> ParsecT TokStream LaTeXState m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure Many Block
horizontalRule)
, (Text
"plainbreak*", LP m [Tok]
forall (m :: * -> *). PandocMonad m => LP m [Tok]
braced LP m [Tok] -> LP m (Many Block) -> LP m (Many Block)
forall a b.
ParsecT TokStream LaTeXState m a
-> ParsecT TokStream LaTeXState m b
-> ParsecT TokStream LaTeXState m b
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> Many Block -> LP m (Many Block)
forall a. a -> ParsecT TokStream LaTeXState m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure Many Block
horizontalRule)
, (Text
"fancybreak", LP m [Tok]
forall (m :: * -> *). PandocMonad m => LP m [Tok]
braced LP m [Tok] -> LP m (Many Block) -> LP m (Many Block)
forall a b.
ParsecT TokStream LaTeXState m a
-> ParsecT TokStream LaTeXState m b
-> ParsecT TokStream LaTeXState m b
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> Many Block -> LP m (Many Block)
forall a. a -> ParsecT TokStream LaTeXState m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure Many Block
horizontalRule)
, (Text
"fancybreak*", LP m [Tok]
forall (m :: * -> *). PandocMonad m => LP m [Tok]
braced LP m [Tok] -> LP m (Many Block) -> LP m (Many Block)
forall a b.
ParsecT TokStream LaTeXState m a
-> ParsecT TokStream LaTeXState m b
-> ParsecT TokStream LaTeXState m b
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> Many Block -> LP m (Many Block)
forall a. a -> ParsecT TokStream LaTeXState m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure Many Block
horizontalRule)
, (Text
"plainfancybreak", LP m [Tok]
forall (m :: * -> *). PandocMonad m => LP m [Tok]
braced LP m [Tok] -> LP m [Tok] -> LP m [Tok]
forall a b.
ParsecT TokStream LaTeXState m a
-> ParsecT TokStream LaTeXState m b
-> ParsecT TokStream LaTeXState m b
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> LP m [Tok]
forall (m :: * -> *). PandocMonad m => LP m [Tok]
braced LP m [Tok] -> LP m [Tok] -> LP m [Tok]
forall a b.
ParsecT TokStream LaTeXState m a
-> ParsecT TokStream LaTeXState m b
-> ParsecT TokStream LaTeXState m b
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> LP m [Tok]
forall (m :: * -> *). PandocMonad m => LP m [Tok]
braced LP m [Tok] -> LP m (Many Block) -> LP m (Many Block)
forall a b.
ParsecT TokStream LaTeXState m a
-> ParsecT TokStream LaTeXState m b
-> ParsecT TokStream LaTeXState m b
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> Many Block -> LP m (Many Block)
forall a. a -> ParsecT TokStream LaTeXState m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure Many Block
horizontalRule)
, (Text
"plainfancybreak*", LP m [Tok]
forall (m :: * -> *). PandocMonad m => LP m [Tok]
braced LP m [Tok] -> LP m [Tok] -> LP m [Tok]
forall a b.
ParsecT TokStream LaTeXState m a
-> ParsecT TokStream LaTeXState m b
-> ParsecT TokStream LaTeXState m b
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> LP m [Tok]
forall (m :: * -> *). PandocMonad m => LP m [Tok]
braced LP m [Tok] -> LP m [Tok] -> LP m [Tok]
forall a b.
ParsecT TokStream LaTeXState m a
-> ParsecT TokStream LaTeXState m b
-> ParsecT TokStream LaTeXState m b
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> LP m [Tok]
forall (m :: * -> *). PandocMonad m => LP m [Tok]
braced LP m [Tok] -> LP m (Many Block) -> LP m (Many Block)
forall a b.
ParsecT TokStream LaTeXState m a
-> ParsecT TokStream LaTeXState m b
-> ParsecT TokStream LaTeXState m b
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> Many Block -> LP m (Many Block)
forall a. a -> ParsecT TokStream LaTeXState m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure Many Block
horizontalRule)
, (Text
"pfbreak", Many Block -> LP m (Many Block)
forall a. a -> ParsecT TokStream LaTeXState m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure Many Block
horizontalRule)
, (Text
"pfbreak*", Many Block -> LP m (Many Block)
forall a. a -> ParsecT TokStream LaTeXState m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure Many Block
horizontalRule)
, (Text
"hrule", Many Block -> LP m (Many Block)
forall a. a -> ParsecT TokStream LaTeXState m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure Many Block
horizontalRule)
, (Text
"strut", Many Block -> LP m (Many Block)
forall a. a -> ParsecT TokStream LaTeXState m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure Many Block
forall a. Monoid a => a
mempty)
, (Text
"rule", LP m (Many Block)
forall (m :: * -> *). PandocMonad m => LP m (Many Block)
rule)
, (Text
"item", LP m (Many Block)
forall (m :: * -> *). PandocMonad m => LP m (Many Block)
looseItem)
, (Text
"documentclass", ParsecT TokStream LaTeXState m ()
forall (m :: * -> *). PandocMonad m => LP m ()
skipopts ParsecT TokStream LaTeXState m () -> LP m [Tok] -> LP m [Tok]
forall a b.
ParsecT TokStream LaTeXState m a
-> ParsecT TokStream LaTeXState m b
-> ParsecT TokStream LaTeXState m b
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> LP m [Tok]
forall (m :: * -> *). PandocMonad m => LP m [Tok]
braced LP m [Tok] -> LP m (Many Block) -> LP m (Many Block)
forall a b.
ParsecT TokStream LaTeXState m a
-> ParsecT TokStream LaTeXState m b
-> ParsecT TokStream LaTeXState m b
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> LP m (Many Block)
forall (m :: * -> *). PandocMonad m => LP m (Many Block)
preamble)
, (Text
"centerline", Many Inline -> Many Block
para (Many Inline -> Many Block)
-> (Many Inline -> Many Inline) -> Many Inline -> Many Block
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Many Inline -> Many Inline
trimInlines (Many Inline -> Many Block)
-> LP m (Many Inline) -> LP m (Many Block)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (ParsecT TokStream LaTeXState m ()
forall (m :: * -> *). PandocMonad m => LP m ()
skipopts ParsecT TokStream LaTeXState m ()
-> LP m (Many Inline) -> LP m (Many Inline)
forall a b.
ParsecT TokStream LaTeXState m a
-> ParsecT TokStream LaTeXState m b
-> ParsecT TokStream LaTeXState m b
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> LP m (Many Inline)
forall (m :: * -> *). PandocMonad m => LP m (Many Inline)
tok))
, (Text
"caption", Many Block
forall a. Monoid a => a
mempty Many Block
-> ParsecT TokStream LaTeXState m () -> LP m (Many Block)
forall a b.
a
-> ParsecT TokStream LaTeXState m b
-> ParsecT TokStream LaTeXState m a
forall (f :: * -> *) a b. Functor f => a -> f b -> f a
<$ LP m (Many Inline) -> ParsecT TokStream LaTeXState m ()
forall (m :: * -> *).
PandocMonad m =>
LP m (Many Inline) -> LP m ()
setCaption LP m (Many Inline)
forall (m :: * -> *). PandocMonad m => LP m (Many Inline)
inline)
, (Text
"bibliography", Many Block
forall a. Monoid a => a
mempty Many Block
-> ParsecT TokStream LaTeXState m () -> LP m (Many Block)
forall a b.
a
-> ParsecT TokStream LaTeXState m b
-> ParsecT TokStream LaTeXState m a
forall (f :: * -> *) a b. Functor f => a -> f b -> f a
<$ (ParsecT TokStream LaTeXState m ()
forall (m :: * -> *). PandocMonad m => LP m ()
skipopts ParsecT TokStream LaTeXState m () -> LP m [Tok] -> LP m [Tok]
forall a b.
ParsecT TokStream LaTeXState m a
-> ParsecT TokStream LaTeXState m b
-> ParsecT TokStream LaTeXState m b
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> LP m [Tok]
forall (m :: * -> *). PandocMonad m => LP m [Tok]
braced LP m [Tok]
-> ([Tok] -> ParsecT TokStream LaTeXState m ())
-> ParsecT TokStream LaTeXState m ()
forall a b.
ParsecT TokStream LaTeXState m a
-> (a -> ParsecT TokStream LaTeXState m b)
-> ParsecT TokStream LaTeXState m b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>=
Text -> [Many Inline] -> ParsecT TokStream LaTeXState m ()
forall (m :: * -> *) a.
(PandocMonad m, ToMetaValue a) =>
Text -> a -> LP m ()
addMeta Text
"bibliography" ([Many Inline] -> ParsecT TokStream LaTeXState m ())
-> ([Tok] -> [Many Inline])
-> [Tok]
-> ParsecT TokStream LaTeXState m ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Text -> [Many Inline]
splitBibs (Text -> [Many Inline])
-> ([Tok] -> Text) -> [Tok] -> [Many Inline]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [Tok] -> Text
untokenize))
, (Text
"addbibresource", Many Block
forall a. Monoid a => a
mempty Many Block
-> ParsecT TokStream LaTeXState m () -> LP m (Many Block)
forall a b.
a
-> ParsecT TokStream LaTeXState m b
-> ParsecT TokStream LaTeXState m a
forall (f :: * -> *) a b. Functor f => a -> f b -> f a
<$ (ParsecT TokStream LaTeXState m ()
forall (m :: * -> *). PandocMonad m => LP m ()
skipopts ParsecT TokStream LaTeXState m () -> LP m [Tok] -> LP m [Tok]
forall a b.
ParsecT TokStream LaTeXState m a
-> ParsecT TokStream LaTeXState m b
-> ParsecT TokStream LaTeXState m b
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> LP m [Tok]
forall (m :: * -> *). PandocMonad m => LP m [Tok]
braced LP m [Tok]
-> ([Tok] -> ParsecT TokStream LaTeXState m ())
-> ParsecT TokStream LaTeXState m ()
forall a b.
ParsecT TokStream LaTeXState m a
-> (a -> ParsecT TokStream LaTeXState m b)
-> ParsecT TokStream LaTeXState m b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>=
Text -> [Many Inline] -> ParsecT TokStream LaTeXState m ()
forall (m :: * -> *) a.
(PandocMonad m, ToMetaValue a) =>
Text -> a -> LP m ()
addMeta Text
"bibliography" ([Many Inline] -> ParsecT TokStream LaTeXState m ())
-> ([Tok] -> [Many Inline])
-> [Tok]
-> ParsecT TokStream LaTeXState m ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Text -> [Many Inline]
splitBibs (Text -> [Many Inline])
-> ([Tok] -> Text) -> [Tok] -> [Many Inline]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [Tok] -> Text
untokenize))
, (Text
"endinput", Many Block
forall a. Monoid a => a
mempty Many Block
-> ParsecT TokStream LaTeXState m () -> LP m (Many Block)
forall a b.
a
-> ParsecT TokStream LaTeXState m b
-> ParsecT TokStream LaTeXState m a
forall (f :: * -> *) a b. Functor f => a -> f b -> f a
<$ ParsecT TokStream LaTeXState m ()
forall (m :: * -> *). PandocMonad m => LP m ()
skipSameFileToks)
, (Text
"lstinputlisting", LP m (Many Block)
forall (m :: * -> *). PandocMonad m => LP m (Many Block)
inputListing)
, (Text
"inputminted", LP m (Many Block)
forall (m :: * -> *). PandocMonad m => LP m (Many Block)
inputMinted)
, (Text
"graphicspath", LP m (Many Block)
forall (m :: * -> *). PandocMonad m => LP m (Many Block)
graphicsPath)
, (Text
"setdefaultlanguage", LP m (Many Block)
forall (m :: * -> *). PandocMonad m => LP m (Many Block)
setDefaultLanguage)
, (Text
"setmainlanguage", LP m (Many Block)
forall (m :: * -> *). PandocMonad m => LP m (Many Block)
setDefaultLanguage)
, (Text
"hypertarget", LP m (Many Block)
forall (m :: * -> *). PandocMonad m => LP m (Many Block)
hypertargetBlock)
, (Text
"textcolor", Text -> LP m (Many Block)
forall (m :: * -> *). PandocMonad m => Text -> LP m (Many Block)
coloredBlock Text
"color")
, (Text
"colorbox", Text -> LP m (Many Block)
forall (m :: * -> *). PandocMonad m => Text -> LP m (Many Block)
coloredBlock Text
"background-color")
, (Text
"blockquote", Bool -> Maybe Text -> LP m (Many Block)
forall (m :: * -> *).
PandocMonad m =>
Bool -> Maybe Text -> LP m (Many Block)
blockquote Bool
False Maybe Text
forall a. Maybe a
Nothing)
, (Text
"blockcquote", Bool -> Maybe Text -> LP m (Many Block)
forall (m :: * -> *).
PandocMonad m =>
Bool -> Maybe Text -> LP m (Many Block)
blockquote Bool
True Maybe Text
forall a. Maybe a
Nothing)
, (Text
"foreignblockquote", LP m [Tok]
forall (m :: * -> *). PandocMonad m => LP m [Tok]
braced LP m [Tok] -> ([Tok] -> LP m (Many Block)) -> LP m (Many Block)
forall a b.
ParsecT TokStream LaTeXState m a
-> (a -> ParsecT TokStream LaTeXState m b)
-> ParsecT TokStream LaTeXState m b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= Bool -> Maybe Text -> LP m (Many Block)
forall (m :: * -> *).
PandocMonad m =>
Bool -> Maybe Text -> LP m (Many Block)
blockquote Bool
False (Maybe Text -> LP m (Many Block))
-> ([Tok] -> Maybe Text) -> [Tok] -> LP m (Many Block)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Text -> Maybe Text
forall a. a -> Maybe a
Just (Text -> Maybe Text) -> ([Tok] -> Text) -> [Tok] -> Maybe Text
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [Tok] -> Text
untokenize)
, (Text
"foreignblockcquote", LP m [Tok]
forall (m :: * -> *). PandocMonad m => LP m [Tok]
braced LP m [Tok] -> ([Tok] -> LP m (Many Block)) -> LP m (Many Block)
forall a b.
ParsecT TokStream LaTeXState m a
-> (a -> ParsecT TokStream LaTeXState m b)
-> ParsecT TokStream LaTeXState m b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= Bool -> Maybe Text -> LP m (Many Block)
forall (m :: * -> *).
PandocMonad m =>
Bool -> Maybe Text -> LP m (Many Block)
blockquote Bool
True (Maybe Text -> LP m (Many Block))
-> ([Tok] -> Maybe Text) -> [Tok] -> LP m (Many Block)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Text -> Maybe Text
forall a. a -> Maybe a
Just (Text -> Maybe Text) -> ([Tok] -> Text) -> [Tok] -> Maybe Text
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [Tok] -> Text
untokenize)
, (Text
"hyphenblockquote", LP m [Tok]
forall (m :: * -> *). PandocMonad m => LP m [Tok]
braced LP m [Tok] -> ([Tok] -> LP m (Many Block)) -> LP m (Many Block)
forall a b.
ParsecT TokStream LaTeXState m a
-> (a -> ParsecT TokStream LaTeXState m b)
-> ParsecT TokStream LaTeXState m b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= Bool -> Maybe Text -> LP m (Many Block)
forall (m :: * -> *).
PandocMonad m =>
Bool -> Maybe Text -> LP m (Many Block)
blockquote Bool
False (Maybe Text -> LP m (Many Block))
-> ([Tok] -> Maybe Text) -> [Tok] -> LP m (Many Block)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Text -> Maybe Text
forall a. a -> Maybe a
Just (Text -> Maybe Text) -> ([Tok] -> Text) -> [Tok] -> Maybe Text
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [Tok] -> Text
untokenize)
, (Text
"hyphenblockcquote", LP m [Tok]
forall (m :: * -> *). PandocMonad m => LP m [Tok]
braced LP m [Tok] -> ([Tok] -> LP m (Many Block)) -> LP m (Many Block)
forall a b.
ParsecT TokStream LaTeXState m a
-> (a -> ParsecT TokStream LaTeXState m b)
-> ParsecT TokStream LaTeXState m b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= Bool -> Maybe Text -> LP m (Many Block)
forall (m :: * -> *).
PandocMonad m =>
Bool -> Maybe Text -> LP m (Many Block)
blockquote Bool
True (Maybe Text -> LP m (Many Block))
-> ([Tok] -> Maybe Text) -> [Tok] -> LP m (Many Block)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Text -> Maybe Text
forall a. a -> Maybe a
Just (Text -> Maybe Text) -> ([Tok] -> Text) -> [Tok] -> Maybe Text
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [Tok] -> Text
untokenize)
, (Text
"include", Text -> LP m (Many Block) -> LP m (Many Block)
forall (m :: * -> *).
PandocMonad m =>
Text -> LP m (Many Block) -> LP m (Many Block)
rawBlockOr Text
"include" (LP m (Many Block) -> LP m (Many Block))
-> LP m (Many Block) -> LP m (Many Block)
forall a b. (a -> b) -> a -> b
$ Text -> LP m (Many Block)
forall (m :: * -> *) a. (PandocMonad m, Monoid a) => Text -> LP m a
include Text
"include")
, (Text
"input", Text -> LP m (Many Block) -> LP m (Many Block)
forall (m :: * -> *).
PandocMonad m =>
Text -> LP m (Many Block) -> LP m (Many Block)
rawBlockOr Text
"input" (LP m (Many Block) -> LP m (Many Block))
-> LP m (Many Block) -> LP m (Many Block)
forall a b. (a -> b) -> a -> b
$ Text -> LP m (Many Block)
forall (m :: * -> *) a. (PandocMonad m, Monoid a) => Text -> LP m a
include Text
"input")
, (Text
"subfile", Text -> LP m (Many Block) -> LP m (Many Block)
forall (m :: * -> *).
PandocMonad m =>
Text -> LP m (Many Block) -> LP m (Many Block)
rawBlockOr Text
"subfile" LP m (Many Block)
forall (m :: * -> *). PandocMonad m => LP m (Many Block)
doSubfile)
, (Text
"usepackage", Text -> LP m (Many Block) -> LP m (Many Block)
forall (m :: * -> *).
PandocMonad m =>
Text -> LP m (Many Block) -> LP m (Many Block)
rawBlockOr Text
"usepackage" LP m (Many Block)
forall (m :: * -> *) a. (PandocMonad m, Monoid a) => LP m a
usepackage)
, (Text
"PackageError", Many Block
forall a. Monoid a => a
mempty Many Block -> LP m [Tok] -> LP m (Many Block)
forall a b.
a
-> ParsecT TokStream LaTeXState m b
-> ParsecT TokStream LaTeXState m a
forall (f :: * -> *) a b. Functor f => a -> f b -> f a
<$ (LP m [Tok]
forall (m :: * -> *). PandocMonad m => LP m [Tok]
braced LP m [Tok] -> LP m [Tok] -> LP m [Tok]
forall a b.
ParsecT TokStream LaTeXState m a
-> ParsecT TokStream LaTeXState m b
-> ParsecT TokStream LaTeXState m b
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> LP m [Tok]
forall (m :: * -> *). PandocMonad m => LP m [Tok]
braced LP m [Tok] -> LP m [Tok] -> LP m [Tok]
forall a b.
ParsecT TokStream LaTeXState m a
-> ParsecT TokStream LaTeXState m b
-> ParsecT TokStream LaTeXState m b
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> LP m [Tok]
forall (m :: * -> *). PandocMonad m => LP m [Tok]
braced))
, (Text
"epigraph", LP m (Many Block)
forall (m :: * -> *). PandocMonad m => LP m (Many Block)
epigraph)
, (Text
"raggedright", Many Block -> LP m (Many Block)
forall a. a -> ParsecT TokStream LaTeXState m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure Many Block
forall a. Monoid a => a
mempty)
, (Text
"newtoggle", LP m [Tok]
forall (m :: * -> *). PandocMonad m => LP m [Tok]
braced LP m [Tok] -> ([Tok] -> LP m (Many Block)) -> LP m (Many Block)
forall a b.
ParsecT TokStream LaTeXState m a
-> (a -> ParsecT TokStream LaTeXState m b)
-> ParsecT TokStream LaTeXState m b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= [Tok] -> LP m (Many Block)
forall a (m :: * -> *).
(Monoid a, PandocMonad m) =>
[Tok] -> LP m a
newToggle)
, (Text
"toggletrue", LP m [Tok]
forall (m :: * -> *). PandocMonad m => LP m [Tok]
braced LP m [Tok] -> ([Tok] -> LP m (Many Block)) -> LP m (Many Block)
forall a b.
ParsecT TokStream LaTeXState m a
-> (a -> ParsecT TokStream LaTeXState m b)
-> ParsecT TokStream LaTeXState m b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= Bool -> [Tok] -> LP m (Many Block)
forall a (m :: * -> *).
(Monoid a, PandocMonad m) =>
Bool -> [Tok] -> LP m a
setToggle Bool
True)
, (Text
"togglefalse", LP m [Tok]
forall (m :: * -> *). PandocMonad m => LP m [Tok]
braced LP m [Tok] -> ([Tok] -> LP m (Many Block)) -> LP m (Many Block)
forall a b.
ParsecT TokStream LaTeXState m a
-> (a -> ParsecT TokStream LaTeXState m b)
-> ParsecT TokStream LaTeXState m b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= Bool -> [Tok] -> LP m (Many Block)
forall a (m :: * -> *).
(Monoid a, PandocMonad m) =>
Bool -> [Tok] -> LP m a
setToggle Bool
False)
, (Text
"iftoggle", LP m (Many Block) -> LP m (Many Block)
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try (LP m (Many Block) -> LP m (Many Block))
-> LP m (Many Block) -> LP m (Many Block)
forall a b. (a -> b) -> a -> b
$ ParsecT TokStream LaTeXState m ()
forall (m :: * -> *). PandocMonad m => LP m ()
ifToggle ParsecT TokStream LaTeXState m ()
-> LP m (Many Block) -> LP m (Many Block)
forall a b.
ParsecT TokStream LaTeXState m a
-> ParsecT TokStream LaTeXState m b
-> ParsecT TokStream LaTeXState m b
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> LP m (Many Block)
forall (m :: * -> *). PandocMonad m => LP m (Many Block)
block)
]
skipSameFileToks :: PandocMonad m => LP m ()
skipSameFileToks :: forall (m :: * -> *). PandocMonad m => LP m ()
skipSameFileToks = do
pos <- ParsecT TokStream LaTeXState m SourcePos
forall (m :: * -> *) s u. Monad m => ParsecT s u m SourcePos
getPosition
skipMany $ infile (sourceName pos)
environments :: PandocMonad m => M.Map Text (LP m Blocks)
environments :: forall (m :: * -> *). PandocMonad m => Map Text (LP m (Many Block))
environments = Map Text (LP m (Many Block))
-> Map Text (LP m (Many Block)) -> Map Text (LP m (Many Block))
forall k a. Ord k => Map k a -> Map k a -> Map k a
M.union (LP m (Many Block)
-> LP m (Many Inline) -> Map Text (LP m (Many Block))
forall (m :: * -> *).
PandocMonad m =>
LP m (Many Block)
-> LP m (Many Inline) -> Map Text (LP m (Many Block))
tableEnvironments LP m (Many Block)
forall (m :: * -> *). PandocMonad m => LP m (Many Block)
block LP m (Many Inline)
forall (m :: * -> *). PandocMonad m => LP m (Many Inline)
inline) (Map Text (LP m (Many Block)) -> Map Text (LP m (Many Block)))
-> Map Text (LP m (Many Block)) -> Map Text (LP m (Many Block))
forall a b. (a -> b) -> a -> b
$
[(Text, LP m (Many Block))] -> Map Text (LP m (Many Block))
forall k a. Ord k => [(k, a)] -> Map k a
M.fromList
[ (Text
"document", Text -> LP m (Many Block) -> LP m (Many Block)
forall (m :: * -> *) a. PandocMonad m => Text -> LP m a -> LP m a
env Text
"document" LP m (Many Block)
forall (m :: * -> *). PandocMonad m => LP m (Many Block)
blocks LP m (Many Block)
-> ParsecT TokStream LaTeXState m () -> LP m (Many Block)
forall a b.
ParsecT TokStream LaTeXState m a
-> ParsecT TokStream LaTeXState m b
-> ParsecT TokStream LaTeXState m a
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
<* ParsecT TokStream LaTeXState m Tok
-> ParsecT TokStream LaTeXState m ()
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m ()
skipMany ParsecT TokStream LaTeXState m Tok
forall (m :: * -> *). PandocMonad m => LP m Tok
anyTok)
, (Text
"abstract", Many Block
forall a. Monoid a => a
mempty Many Block
-> ParsecT TokStream LaTeXState m () -> LP m (Many Block)
forall a b.
a
-> ParsecT TokStream LaTeXState m b
-> ParsecT TokStream LaTeXState m a
forall (f :: * -> *) a b. Functor f => a -> f b -> f a
<$ (Text -> LP m (Many Block) -> LP m (Many Block)
forall (m :: * -> *) a. PandocMonad m => Text -> LP m a -> LP m a
env Text
"abstract" LP m (Many Block)
forall (m :: * -> *). PandocMonad m => LP m (Many Block)
blocks LP m (Many Block)
-> (Many Block -> ParsecT TokStream LaTeXState m ())
-> ParsecT TokStream LaTeXState m ()
forall a b.
ParsecT TokStream LaTeXState m a
-> (a -> ParsecT TokStream LaTeXState m b)
-> ParsecT TokStream LaTeXState m b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= Text -> Many Block -> ParsecT TokStream LaTeXState m ()
forall (m :: * -> *) a.
(PandocMonad m, ToMetaValue a) =>
Text -> a -> LP m ()
addMeta Text
"abstract"))
, (Text
"sloppypar", Text -> LP m (Many Block) -> LP m (Many Block)
forall (m :: * -> *) a. PandocMonad m => Text -> LP m a -> LP m a
env Text
"sloppypar" LP m (Many Block)
forall (m :: * -> *). PandocMonad m => LP m (Many Block)
blocks)
, (Text
"letter", Text -> LP m (Many Block) -> LP m (Many Block)
forall (m :: * -> *) a. PandocMonad m => Text -> LP m a -> LP m a
env Text
"letter" LP m (Many Block)
forall (m :: * -> *). PandocMonad m => LP m (Many Block)
letterContents)
, (Text
"minipage", Attr -> Many Block -> Many Block
divWith (Text
"",[Text
"minipage"],[]) (Many Block -> Many Block)
-> LP m (Many Block) -> LP m (Many Block)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$>
Text -> LP m (Many Block) -> LP m (Many Block)
forall (m :: * -> *) a. PandocMonad m => Text -> LP m a -> LP m a
env Text
"minipage" (ParsecT TokStream LaTeXState m ()
forall (m :: * -> *). PandocMonad m => LP m ()
skipopts ParsecT TokStream LaTeXState m ()
-> ParsecT TokStream LaTeXState m ()
-> ParsecT TokStream LaTeXState m ()
forall a b.
ParsecT TokStream LaTeXState m a
-> ParsecT TokStream LaTeXState m b
-> ParsecT TokStream LaTeXState m b
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> ParsecT TokStream LaTeXState m ()
forall (m :: * -> *). PandocMonad m => LP m ()
spaces ParsecT TokStream LaTeXState m ()
-> ParsecT TokStream LaTeXState m (Maybe [Tok])
-> ParsecT TokStream LaTeXState m (Maybe [Tok])
forall a b.
ParsecT TokStream LaTeXState m a
-> ParsecT TokStream LaTeXState m b
-> ParsecT TokStream LaTeXState m b
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> ParsecT TokStream LaTeXState m [Tok]
-> ParsecT TokStream LaTeXState m (Maybe [Tok])
forall (f :: * -> *) a. Alternative f => f a -> f (Maybe a)
optional ParsecT TokStream LaTeXState m [Tok]
forall (m :: * -> *). PandocMonad m => LP m [Tok]
braced ParsecT TokStream LaTeXState m (Maybe [Tok])
-> ParsecT TokStream LaTeXState m ()
-> ParsecT TokStream LaTeXState m ()
forall a b.
ParsecT TokStream LaTeXState m a
-> ParsecT TokStream LaTeXState m b
-> ParsecT TokStream LaTeXState m b
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> ParsecT TokStream LaTeXState m ()
forall (m :: * -> *). PandocMonad m => LP m ()
spaces ParsecT TokStream LaTeXState m ()
-> LP m (Many Block) -> LP m (Many Block)
forall a b.
ParsecT TokStream LaTeXState m a
-> ParsecT TokStream LaTeXState m b
-> ParsecT TokStream LaTeXState m b
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> LP m (Many Block)
forall (m :: * -> *). PandocMonad m => LP m (Many Block)
blocks))
, (Text
"figure", Text -> LP m (Many Block) -> LP m (Many Block)
forall (m :: * -> *) a. PandocMonad m => Text -> LP m a -> LP m a
env Text
"figure" LP m (Many Block)
forall (m :: * -> *). PandocMonad m => LP m (Many Block)
figure')
, (Text
"figure*", Text -> LP m (Many Block) -> LP m (Many Block)
forall (m :: * -> *) a. PandocMonad m => Text -> LP m a -> LP m a
env Text
"figure*" LP m (Many Block)
forall (m :: * -> *). PandocMonad m => LP m (Many Block)
figure')
, (Text
"subfigure", Text -> LP m (Many Block) -> LP m (Many Block)
forall (m :: * -> *) a. PandocMonad m => Text -> LP m a -> LP m a
env Text
"subfigure" (LP m (Many Block) -> LP m (Many Block))
-> LP m (Many Block) -> LP m (Many Block)
forall a b. (a -> b) -> a -> b
$ ParsecT TokStream LaTeXState m ()
forall (m :: * -> *). PandocMonad m => LP m ()
skipopts ParsecT TokStream LaTeXState m ()
-> LP m (Many Inline) -> LP m (Many Inline)
forall a b.
ParsecT TokStream LaTeXState m a
-> ParsecT TokStream LaTeXState m b
-> ParsecT TokStream LaTeXState m b
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> LP m (Many Inline)
forall (m :: * -> *). PandocMonad m => LP m (Many Inline)
tok LP m (Many Inline) -> LP m (Many Block) -> LP m (Many Block)
forall a b.
ParsecT TokStream LaTeXState m a
-> ParsecT TokStream LaTeXState m b
-> ParsecT TokStream LaTeXState m b
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> LP m (Many Block)
forall (m :: * -> *). PandocMonad m => LP m (Many Block)
figure')
, (Text
"center", Attr -> Many Block -> Many Block
divWith (Text
"", [Text
"center"], []) (Many Block -> Many Block)
-> LP m (Many Block) -> LP m (Many Block)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Text -> LP m (Many Block) -> LP m (Many Block)
forall (m :: * -> *) a. PandocMonad m => Text -> LP m a -> LP m a
env Text
"center" LP m (Many Block)
forall (m :: * -> *). PandocMonad m => LP m (Many Block)
blocks)
, (Text
"quote", Many Block -> Many Block
blockQuote (Many Block -> Many Block)
-> LP m (Many Block) -> LP m (Many Block)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Text -> LP m (Many Block) -> LP m (Many Block)
forall (m :: * -> *) a. PandocMonad m => Text -> LP m a -> LP m a
env Text
"quote" LP m (Many Block)
forall (m :: * -> *). PandocMonad m => LP m (Many Block)
blocks)
, (Text
"quotation", Many Block -> Many Block
blockQuote (Many Block -> Many Block)
-> LP m (Many Block) -> LP m (Many Block)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Text -> LP m (Many Block) -> LP m (Many Block)
forall (m :: * -> *) a. PandocMonad m => Text -> LP m a -> LP m a
env Text
"quotation" LP m (Many Block)
forall (m :: * -> *). PandocMonad m => LP m (Many Block)
blocks)
, (Text
"verse", Many Block -> Many Block
blockQuote (Many Block -> Many Block)
-> LP m (Many Block) -> LP m (Many Block)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Text -> LP m (Many Block) -> LP m (Many Block)
forall (m :: * -> *) a. PandocMonad m => Text -> LP m a -> LP m a
env Text
"verse" LP m (Many Block)
forall (m :: * -> *). PandocMonad m => LP m (Many Block)
blocks)
, (Text
"itemize", [Many Block] -> Many Block
bulletList ([Many Block] -> Many Block)
-> ParsecT TokStream LaTeXState m [Many Block] -> LP m (Many Block)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Text
-> ParsecT TokStream LaTeXState m [Many Block]
-> ParsecT TokStream LaTeXState m [Many Block]
forall (m :: * -> *) a. PandocMonad m => Text -> LP m a -> LP m a
listenv Text
"itemize" (LP m (Many Block) -> ParsecT TokStream LaTeXState m [Many Block]
forall a.
ParsecT TokStream LaTeXState m a
-> ParsecT TokStream LaTeXState m [a]
forall (f :: * -> *) a. Alternative f => f a -> f [a]
many LP m (Many Block)
forall (m :: * -> *). PandocMonad m => LP m (Many Block)
item))
, (Text
"description", [(Many Inline, [Many Block])] -> Many Block
definitionList ([(Many Inline, [Many Block])] -> Many Block)
-> ParsecT TokStream LaTeXState m [(Many Inline, [Many Block])]
-> LP m (Many Block)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Text
-> ParsecT TokStream LaTeXState m [(Many Inline, [Many Block])]
-> ParsecT TokStream LaTeXState m [(Many Inline, [Many Block])]
forall (m :: * -> *) a. PandocMonad m => Text -> LP m a -> LP m a
listenv Text
"description" (ParsecT TokStream LaTeXState m (Many Inline, [Many Block])
-> ParsecT TokStream LaTeXState m [(Many Inline, [Many Block])]
forall a.
ParsecT TokStream LaTeXState m a
-> ParsecT TokStream LaTeXState m [a]
forall (f :: * -> *) a. Alternative f => f a -> f [a]
many ParsecT TokStream LaTeXState m (Many Inline, [Many Block])
forall (m :: * -> *).
PandocMonad m =>
LP m (Many Inline, [Many Block])
descItem))
, (Text
"enumerate", LP m (Many Block)
forall (m :: * -> *). PandocMonad m => LP m (Many Block)
orderedList')
, (Text
"alltt", Many Block -> Many Block
alltt (Many Block -> Many Block)
-> LP m (Many Block) -> LP m (Many Block)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Text -> LP m (Many Block) -> LP m (Many Block)
forall (m :: * -> *) a. PandocMonad m => Text -> LP m a -> LP m a
env Text
"alltt" LP m (Many Block)
forall (m :: * -> *). PandocMonad m => LP m (Many Block)
blocks)
, (Text
"code", Extension -> ParsecT TokStream LaTeXState m ()
forall s (m :: * -> *) a st.
(Stream s m a, HasReaderOptions st) =>
Extension -> ParsecT s st m ()
guardEnabled Extension
Ext_literate_haskell ParsecT TokStream LaTeXState m ()
-> LP m (Many Block) -> LP m (Many Block)
forall a b.
ParsecT TokStream LaTeXState m a
-> ParsecT TokStream LaTeXState m b
-> ParsecT TokStream LaTeXState m b
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*>
(Attr -> Text -> Many Block
codeBlockWith (Text
"",[Text
"haskell",Text
"literate"],[]) (Text -> Many Block)
-> ParsecT TokStream LaTeXState m Text -> LP m (Many Block)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Text -> ParsecT TokStream LaTeXState m Text
forall (m :: * -> *). PandocMonad m => Text -> LP m Text
verbEnv Text
"code"))
, (Text
"comment", Many Block
forall a. Monoid a => a
mempty Many Block
-> ParsecT TokStream LaTeXState m Text -> LP m (Many Block)
forall a b.
a
-> ParsecT TokStream LaTeXState m b
-> ParsecT TokStream LaTeXState m a
forall (f :: * -> *) a b. Functor f => a -> f b -> f a
<$ Text -> ParsecT TokStream LaTeXState m Text
forall (m :: * -> *). PandocMonad m => Text -> LP m Text
verbEnv Text
"comment")
, (Text
"verbatim", Text -> Many Block
codeBlock (Text -> Many Block)
-> ParsecT TokStream LaTeXState m Text -> LP m (Many Block)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Text -> ParsecT TokStream LaTeXState m Text
forall (m :: * -> *). PandocMonad m => Text -> LP m Text
verbEnv Text
"verbatim")
, (Text
"Verbatim", Text -> LP m (Many Block)
forall (m :: * -> *). PandocMonad m => Text -> LP m (Many Block)
fancyverbEnv Text
"Verbatim")
, (Text
"BVerbatim", Text -> LP m (Many Block)
forall (m :: * -> *). PandocMonad m => Text -> LP m (Many Block)
fancyverbEnv Text
"BVerbatim")
, (Text
"lstlisting", do attr <- [(Text, Text)] -> Attr
parseListingsOptions ([(Text, Text)] -> Attr)
-> ParsecT TokStream LaTeXState m [(Text, Text)]
-> ParsecT TokStream LaTeXState m Attr
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> [(Text, Text)]
-> ParsecT TokStream LaTeXState m [(Text, Text)]
-> ParsecT TokStream LaTeXState m [(Text, Text)]
forall s (m :: * -> *) t a u.
Stream s m t =>
a -> ParsecT s u m a -> ParsecT s u m a
option [] ParsecT TokStream LaTeXState m [(Text, Text)]
forall (m :: * -> *). PandocMonad m => LP m [(Text, Text)]
keyvals
codeBlockWith attr <$> verbEnv "lstlisting")
, (Text
"minted", LP m (Many Block)
forall (m :: * -> *). PandocMonad m => LP m (Many Block)
minted)
, (Text
"obeylines", LP m (Many Block)
forall (m :: * -> *). PandocMonad m => LP m (Many Block)
obeylines)
, (Text
"tikzpicture", Text -> LP m (Many Block)
forall (m :: * -> *). PandocMonad m => Text -> LP m (Many Block)
rawVerbEnv Text
"tikzpicture")
, (Text
"tikzcd", Text -> LP m (Many Block)
forall (m :: * -> *). PandocMonad m => Text -> LP m (Many Block)
rawVerbEnv Text
"tikzcd")
, (Text
"lilypond", Text -> LP m (Many Block)
forall (m :: * -> *). PandocMonad m => Text -> LP m (Many Block)
rawVerbEnv Text
"lilypond")
, (Text
"ly", Text -> LP m (Many Block)
forall (m :: * -> *). PandocMonad m => Text -> LP m (Many Block)
rawVerbEnv Text
"ly")
, (Text
"proof", LP m (Many Block) -> LP m (Many Inline) -> LP m (Many Block)
forall (m :: * -> *).
PandocMonad m =>
LP m (Many Block) -> LP m (Many Inline) -> LP m (Many Block)
proof LP m (Many Block)
forall (m :: * -> *). PandocMonad m => LP m (Many Block)
blocks LP m (Many Inline)
forall (m :: * -> *). PandocMonad m => LP m (Many Inline)
opt)
, (Text
"CSLReferences", ParsecT TokStream LaTeXState m [Tok]
forall (m :: * -> *). PandocMonad m => LP m [Tok]
braced ParsecT TokStream LaTeXState m [Tok]
-> ParsecT TokStream LaTeXState m [Tok]
-> ParsecT TokStream LaTeXState m [Tok]
forall a b.
ParsecT TokStream LaTeXState m a
-> ParsecT TokStream LaTeXState m b
-> ParsecT TokStream LaTeXState m b
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> ParsecT TokStream LaTeXState m [Tok]
forall (m :: * -> *). PandocMonad m => LP m [Tok]
braced ParsecT TokStream LaTeXState m [Tok]
-> LP m (Many Block) -> LP m (Many Block)
forall a b.
ParsecT TokStream LaTeXState m a
-> ParsecT TokStream LaTeXState m b
-> ParsecT TokStream LaTeXState m b
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> Text -> LP m (Many Block) -> LP m (Many Block)
forall (m :: * -> *) a. PandocMonad m => Text -> LP m a -> LP m a
env Text
"CSLReferences" LP m (Many Block)
forall (m :: * -> *). PandocMonad m => LP m (Many Block)
blocks)
, (Text
"otherlanguage", Text -> LP m (Many Block) -> LP m (Many Block)
forall (m :: * -> *) a. PandocMonad m => Text -> LP m a -> LP m a
env Text
"otherlanguage" LP m (Many Block)
forall (m :: * -> *). PandocMonad m => LP m (Many Block)
otherlanguageEnv)
]
otherlanguageEnv :: PandocMonad m => LP m Blocks
otherlanguageEnv :: forall (m :: * -> *). PandocMonad m => LP m (Many Block)
otherlanguageEnv = do
LP m ()
forall (m :: * -> *). PandocMonad m => LP m ()
skipopts
babelLang <- [Tok] -> Text
untokenize ([Tok] -> Text)
-> ParsecT TokStream LaTeXState m [Tok]
-> ParsecT TokStream LaTeXState m Text
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ParsecT TokStream LaTeXState m [Tok]
forall (m :: * -> *). PandocMonad m => LP m [Tok]
braced
case babelLangToBCP47 babelLang of
Just Lang
lang -> Attr -> Many Block -> Many Block
divWith (Text
"", [], [(Text
"lang", Lang -> Text
renderLang Lang
lang)]) (Many Block -> Many Block)
-> ParsecT TokStream LaTeXState m (Many Block)
-> ParsecT TokStream LaTeXState m (Many Block)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ParsecT TokStream LaTeXState m (Many Block)
forall (m :: * -> *). PandocMonad m => LP m (Many Block)
blocks
Maybe Lang
Nothing -> ParsecT TokStream LaTeXState m (Many Block)
forall (m :: * -> *). PandocMonad m => LP m (Many Block)
blocks
langEnvironment :: PandocMonad m => Text -> LP m Blocks
langEnvironment :: forall (m :: * -> *). PandocMonad m => Text -> LP m (Many Block)
langEnvironment Text
name =
case Text -> Maybe Lang
babelLangToBCP47 Text
name of
Just Lang
lang ->
Text -> LP m (Many Block) -> LP m (Many Block)
forall (m :: * -> *) a. PandocMonad m => Text -> LP m a -> LP m a
env Text
name (Attr -> Many Block -> Many Block
divWith (Text
"", [], [(Text
"lang", Lang -> Text
renderLang Lang
lang)]) (Many Block -> Many Block)
-> LP m (Many Block) -> LP m (Many Block)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> LP m (Many Block)
forall (m :: * -> *). PandocMonad m => LP m (Many Block)
blocks)
Maybe Lang
Nothing -> LP m (Many Block)
forall a. ParsecT TokStream LaTeXState m a
forall (m :: * -> *) a. MonadPlus m => m a
mzero
filecontents :: PandocMonad m => LP m Blocks
filecontents :: forall (m :: * -> *). PandocMonad m => LP m (Many Block)
filecontents = ParsecT TokStream LaTeXState m (Many Block)
-> ParsecT TokStream LaTeXState m (Many Block)
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try (ParsecT TokStream LaTeXState m (Many Block)
-> ParsecT TokStream LaTeXState m (Many Block))
-> ParsecT TokStream LaTeXState m (Many Block)
-> ParsecT TokStream LaTeXState m (Many Block)
forall a b. (a -> b) -> a -> b
$ do
Text -> LP m Tok
forall (m :: * -> *). PandocMonad m => Text -> LP m Tok
controlSeq Text
"begin"
name <- [Tok] -> Text
untokenize ([Tok] -> Text)
-> ParsecT TokStream LaTeXState m [Tok]
-> ParsecT TokStream LaTeXState m Text
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ParsecT TokStream LaTeXState m [Tok]
forall (m :: * -> *). PandocMonad m => LP m [Tok]
braced
guard $ name == "filecontents" || name == "filecontents*"
skipopts
fp <- untokenize <$> braced
txt <- verbEnv name
updateState $ \LaTeXState
st ->
LaTeXState
st{ sFileContents = M.insert fp txt (sFileContents st) }
return mempty
environment :: PandocMonad m => LP m Blocks
environment :: forall (m :: * -> *). PandocMonad m => LP m (Many Block)
environment = ParsecT TokStream LaTeXState m (Many Block)
-> ParsecT TokStream LaTeXState m (Many Block)
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try (ParsecT TokStream LaTeXState m (Many Block)
-> ParsecT TokStream LaTeXState m (Many Block))
-> ParsecT TokStream LaTeXState m (Many Block)
-> ParsecT TokStream LaTeXState m (Many Block)
forall a b. (a -> b) -> a -> b
$ do
Text -> LP m Tok
forall (m :: * -> *). PandocMonad m => Text -> LP m Tok
controlSeq Text
"begin"
name <- [Tok] -> Text
untokenize ([Tok] -> Text)
-> ParsecT TokStream LaTeXState m [Tok]
-> ParsecT TokStream LaTeXState m Text
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ParsecT TokStream LaTeXState m [Tok]
forall (m :: * -> *). PandocMonad m => LP m [Tok]
braced
M.findWithDefault mzero name environments <|>
langEnvironment name <|>
theoremEnvironment blocks opt name <|>
if M.member name (inlineEnvironments
:: M.Map Text (LP PandocPure Inlines))
then mzero
else try (rawEnv name) <|> rawVerbEnv name
rawEnv :: PandocMonad m => Text -> LP m Blocks
rawEnv :: forall (m :: * -> *). PandocMonad m => Text -> LP m (Many Block)
rawEnv Text
name = do
exts <- (ReaderOptions -> Extensions)
-> ParsecT TokStream LaTeXState m Extensions
forall st s (m :: * -> *) t b.
(HasReaderOptions st, Stream s m t) =>
(ReaderOptions -> b) -> ParsecT s st m b
forall s (m :: * -> *) t b.
Stream s m t =>
(ReaderOptions -> b) -> ParsecT s LaTeXState m b
getOption ReaderOptions -> Extensions
readerExtensions
let parseRaw = Extension -> Extensions -> Bool
extensionEnabled Extension
Ext_raw_tex Extensions
exts
rawOptions <- mconcat <$> many rawopt
let beginCommand = Text
"\\begin{" Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
name Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
"}" Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
rawOptions
pos1 <- getPosition
if parseRaw
then do
(_, raw) <- withRaw $ env name blocks
return $ rawBlock "latex"
$ beginCommand <> untokenize raw
else do
bs <- env name blocks
report $ SkippedContent beginCommand pos1
pos2 <- getPosition
report $ SkippedContent ("\\end{" <> name <> "}") pos2
return $ divWith ("",[name],[]) bs
rawVerbEnv :: PandocMonad m => Text -> LP m Blocks
rawVerbEnv :: forall (m :: * -> *). PandocMonad m => Text -> LP m (Many Block)
rawVerbEnv Text
name = do
pos <- ParsecT TokStream LaTeXState m SourcePos
forall (m :: * -> *) s u. Monad m => ParsecT s u m SourcePos
getPosition
(_, raw) <- withRaw $ verbEnv name
let raw' = Text
"\\begin{" Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
name Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
"}" Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> [Tok] -> Text
untokenize [Tok]
raw
exts <- getOption readerExtensions
let parseRaw = Extension -> Extensions -> Bool
extensionEnabled Extension
Ext_raw_tex Extensions
exts
if parseRaw
then return $ rawBlock "latex" raw'
else do
report $ SkippedContent raw' pos
return mempty
fancyverbEnv :: PandocMonad m => Text -> LP m Blocks
fancyverbEnv :: forall (m :: * -> *). PandocMonad m => Text -> LP m (Many Block)
fancyverbEnv Text
name = do
options <- [(Text, Text)]
-> ParsecT TokStream LaTeXState m [(Text, Text)]
-> ParsecT TokStream LaTeXState m [(Text, Text)]
forall s (m :: * -> *) t a u.
Stream s m t =>
a -> ParsecT s u m a -> ParsecT s u m a
option [] ParsecT TokStream LaTeXState m [(Text, Text)]
forall (m :: * -> *). PandocMonad m => LP m [(Text, Text)]
keyvals
let kvs = [ (if Text
k Text -> Text -> Bool
forall a. Eq a => a -> a -> Bool
== Text
"firstnumber"
then Text
"startFrom"
else Text
k, Text
v) | (Text
k,Text
v) <- [(Text, Text)]
options ]
let classes = [ Text
"numberLines" |
Text -> [(Text, Text)] -> Maybe Text
forall a b. Eq a => a -> [(a, b)] -> Maybe b
lookup Text
"numbers" [(Text, Text)]
options Maybe Text -> Maybe Text -> Bool
forall a. Eq a => a -> a -> Bool
== Text -> Maybe Text
forall a. a -> Maybe a
Just Text
"left" ]
let attr = (Text
"",[Text]
classes,[(Text, Text)]
kvs)
codeBlockWith attr <$> verbEnv name
obeylines :: PandocMonad m => LP m Blocks
obeylines :: forall (m :: * -> *). PandocMonad m => LP m (Many Block)
obeylines =
Many Inline -> Many Block
para (Many Inline -> Many Block)
-> (Many Inline -> Many Inline) -> Many Inline -> Many Block
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [Inline] -> Many Inline
forall a. [a] -> Many a
fromList ([Inline] -> Many Inline)
-> (Many Inline -> [Inline]) -> Many Inline -> Many Inline
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [Inline] -> [Inline]
removeLeadingTrailingBreaks ([Inline] -> [Inline])
-> (Many Inline -> [Inline]) -> Many Inline -> [Inline]
forall b c a. (b -> c) -> (a -> b) -> a -> c
.
(Inline -> Inline) -> [Inline] -> [Inline]
forall a b. Walkable a b => (a -> a) -> b -> b
walk Inline -> Inline
softBreakToHard ([Inline] -> [Inline])
-> (Many Inline -> [Inline]) -> Many Inline -> [Inline]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Many Inline -> [Inline]
forall a. Many a -> [a]
toList (Many Inline -> Many Block)
-> ParsecT TokStream LaTeXState m (Many Inline)
-> ParsecT TokStream LaTeXState m (Many Block)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Text
-> ParsecT TokStream LaTeXState m (Many Inline)
-> ParsecT TokStream LaTeXState m (Many Inline)
forall (m :: * -> *) a. PandocMonad m => Text -> LP m a -> LP m a
env Text
"obeylines" ParsecT TokStream LaTeXState m (Many Inline)
forall (m :: * -> *). PandocMonad m => LP m (Many Inline)
inlines
where softBreakToHard :: Inline -> Inline
softBreakToHard Inline
SoftBreak = Inline
LineBreak
softBreakToHard Inline
x = Inline
x
removeLeadingTrailingBreaks :: [Inline] -> [Inline]
removeLeadingTrailingBreaks = [Inline] -> [Inline]
forall a. [a] -> [a]
reverse ([Inline] -> [Inline])
-> ([Inline] -> [Inline]) -> [Inline] -> [Inline]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Inline -> Bool) -> [Inline] -> [Inline]
forall a. (a -> Bool) -> [a] -> [a]
dropWhile Inline -> Bool
isLineBreak ([Inline] -> [Inline])
-> ([Inline] -> [Inline]) -> [Inline] -> [Inline]
forall b c a. (b -> c) -> (a -> b) -> a -> c
.
[Inline] -> [Inline]
forall a. [a] -> [a]
reverse ([Inline] -> [Inline])
-> ([Inline] -> [Inline]) -> [Inline] -> [Inline]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Inline -> Bool) -> [Inline] -> [Inline]
forall a. (a -> Bool) -> [a] -> [a]
dropWhile Inline -> Bool
isLineBreak
isLineBreak :: Inline -> Bool
isLineBreak Inline
LineBreak = Bool
True
isLineBreak Inline
_ = Bool
False
minted :: PandocMonad m => LP m Blocks
minted :: forall (m :: * -> *). PandocMonad m => LP m (Many Block)
minted = do
attr <- LP m Attr
forall (m :: * -> *). PandocMonad m => LP m Attr
mintedAttr
codeBlockWith attr <$> verbEnv "minted"
mintedAttr :: PandocMonad m => LP m Attr
mintedAttr :: forall (m :: * -> *). PandocMonad m => LP m Attr
mintedAttr = do
options <- [(Text, Text)]
-> ParsecT TokStream LaTeXState m [(Text, Text)]
-> ParsecT TokStream LaTeXState m [(Text, Text)]
forall s (m :: * -> *) t a u.
Stream s m t =>
a -> ParsecT s u m a -> ParsecT s u m a
option [] ParsecT TokStream LaTeXState m [(Text, Text)]
forall (m :: * -> *). PandocMonad m => LP m [(Text, Text)]
keyvals
lang <- untokenize <$> braced
let kvs = [ (if Text
k Text -> Text -> Bool
forall a. Eq a => a -> a -> Bool
== Text
"firstnumber"
then Text
"startFrom"
else Text
k, Text
v) | (Text
k,Text
v) <- [(Text, Text)]
options ]
let classes = [ Text
lang | Bool -> Bool
not (Text -> Bool
T.null Text
lang) ] [Text] -> [Text] -> [Text]
forall a. [a] -> [a] -> [a]
++
[ Text
"numberLines" |
Text -> [(Text, Text)] -> Maybe Text
forall a b. Eq a => a -> [(a, b)] -> Maybe b
lookup Text
"linenos" [(Text, Text)]
options Maybe Text -> Maybe Text -> Bool
forall a. Eq a => a -> a -> Bool
== Text -> Maybe Text
forall a. a -> Maybe a
Just Text
"true" ]
return ("",classes,kvs)
inputMinted :: PandocMonad m => LP m Blocks
inputMinted :: forall (m :: * -> *). PandocMonad m => LP m (Many Block)
inputMinted = do
pos <- ParsecT TokStream LaTeXState m SourcePos
forall (m :: * -> *) s u. Monad m => ParsecT s u m SourcePos
getPosition
attr <- mintedAttr
f <- T.filter (/='"') . untokenize <$> braced
mbCode <- readFileFromTexinputs (T.unpack f)
rawcode <- case mbCode of
Just Text
s -> Text -> ParsecT TokStream LaTeXState m Text
forall a. a -> ParsecT TokStream LaTeXState m a
forall (m :: * -> *) a. Monad m => a -> m a
return Text
s
Maybe Text
Nothing -> do
LogMessage -> ParsecT TokStream LaTeXState m ()
forall (m :: * -> *). PandocMonad m => LogMessage -> m ()
report (LogMessage -> ParsecT TokStream LaTeXState m ())
-> LogMessage -> ParsecT TokStream LaTeXState m ()
forall a b. (a -> b) -> a -> b
$ Text -> SourcePos -> LogMessage
CouldNotLoadIncludeFile Text
f SourcePos
pos
Text -> ParsecT TokStream LaTeXState m Text
forall a. a -> ParsecT TokStream LaTeXState m a
forall (m :: * -> *) a. Monad m => a -> m a
return Text
""
return $ B.codeBlockWith attr rawcode
letterContents :: PandocMonad m => LP m Blocks
letterContents :: forall (m :: * -> *). PandocMonad m => LP m (Many Block)
letterContents = do
bs <- LP m (Many Block)
forall (m :: * -> *). PandocMonad m => LP m (Many Block)
blocks
st <- getState
let addr = case Text -> Meta -> Maybe MetaValue
lookupMeta Text
"address" (LaTeXState -> Meta
sMeta LaTeXState
st) of
Just (MetaBlocks [Plain [Inline]
xs]) ->
Many Inline -> Many Block
para (Many Inline -> Many Block) -> Many Inline -> Many Block
forall a b. (a -> b) -> a -> b
$ Many Inline -> Many Inline
trimInlines (Many Inline -> Many Inline) -> Many Inline -> Many Inline
forall a b. (a -> b) -> a -> b
$ [Inline] -> Many Inline
forall a. [a] -> Many a
fromList [Inline]
xs
Maybe MetaValue
_ -> Many Block
forall a. Monoid a => a
mempty
return $ addr <> bs
figure' :: PandocMonad m => LP m Blocks
figure' :: forall (m :: * -> *). PandocMonad m => LP m (Many Block)
figure' = ParsecT TokStream LaTeXState m (Many Block)
-> ParsecT TokStream LaTeXState m (Many Block)
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try (ParsecT TokStream LaTeXState m (Many Block)
-> ParsecT TokStream LaTeXState m (Many Block))
-> ParsecT TokStream LaTeXState m (Many Block)
-> ParsecT TokStream LaTeXState m (Many Block)
forall a b. (a -> b) -> a -> b
$ do
LP m ()
forall (m :: * -> *). PandocMonad m => LP m ()
sp
poshint <- Text
-> ParsecT TokStream LaTeXState m Text
-> ParsecT TokStream LaTeXState m Text
forall s (m :: * -> *) t a u.
Stream s m t =>
a -> ParsecT s u m a -> ParsecT s u m a
option Text
"" (ParsecT TokStream LaTeXState m Text
-> ParsecT TokStream LaTeXState m Text)
-> ParsecT TokStream LaTeXState m Text
-> ParsecT TokStream LaTeXState m Text
forall a b. (a -> b) -> a -> b
$ [Tok] -> Text
untokenize ([Tok] -> Text)
-> ParsecT TokStream LaTeXState m [Tok]
-> ParsecT TokStream LaTeXState m Text
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ParsecT TokStream LaTeXState m [Tok]
forall (m :: * -> *). PandocMonad m => LP m [Tok]
bracketedToks
sp
resetCaption
innerContent <- many $ try (Left <$> label) <|> (Right <$> block)
let content = (Block -> Block) -> Many Block -> Many Block
forall a b. Walkable a b => (a -> a) -> b -> b
walk Block -> Block
go (Many Block -> Many Block) -> Many Block -> Many Block
forall a b. (a -> b) -> a -> b
$ [Many Block] -> Many Block
forall a. Monoid a => [a] -> a
mconcat ([Many Block] -> Many Block) -> [Many Block] -> Many Block
forall a b. (a -> b) -> a -> b
$ ([()], [Many Block]) -> [Many Block]
forall a b. (a, b) -> b
snd (([()], [Many Block]) -> [Many Block])
-> ([()], [Many Block]) -> [Many Block]
forall a b. (a -> b) -> a -> b
$ [Either () (Many Block)] -> ([()], [Many Block])
forall a b. [Either a b] -> ([a], [b])
partitionEithers [Either () (Many Block)]
innerContent
st <- getState
let caption' = Caption -> Maybe Caption -> Caption
forall a. a -> Maybe a -> a
fromMaybe Caption
B.emptyCaption (Maybe Caption -> Caption) -> Maybe Caption -> Caption
forall a b. (a -> b) -> a -> b
$ LaTeXState -> Maybe Caption
sCaption LaTeXState
st
let mblabel = LaTeXState -> Maybe Text
sLastLabel LaTeXState
st
let kvs = [(Text
"latex-placement", Text
poshint) | Bool -> Bool
not (Text -> Bool
T.null Text
poshint)]
let ident = Text -> Maybe Text -> Text
forall a. a -> Maybe a -> a
fromMaybe Text
"" Maybe Text
mblabel
let attr = (Text
ident, [], [(Text, Text)]
kvs)
case mblabel of
Maybe Text
Nothing -> () -> LP m ()
forall a. a -> ParsecT TokStream LaTeXState m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure ()
Just Text
lab -> do
num <- (LaTeXState -> DottedNum) -> LP m DottedNum
forall (m :: * -> *).
Monad m =>
(LaTeXState -> DottedNum) -> LP m DottedNum
getNextNumber LaTeXState -> DottedNum
sLastFigureNum
setState
st { sLastFigureNum = num
, sLabels = M.insert lab [Str (renderDottedNum num)] (sLabels st)
}
return $ B.figureWith attr caption' content
where
go :: Block -> Block
go (Para [Image Attr
attr [Str Text
"image"] (Text, Text)
target]) = [Inline] -> Block
Plain [Attr -> [Inline] -> (Text, Text) -> Inline
Image Attr
attr [] (Text, Text)
target]
go Block
x = Block
x
coloredBlock :: PandocMonad m => Text -> LP m Blocks
coloredBlock :: forall (m :: * -> *). PandocMonad m => Text -> LP m (Many Block)
coloredBlock Text
stylename = ParsecT TokStream LaTeXState m (Many Block)
-> ParsecT TokStream LaTeXState m (Many Block)
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try (ParsecT TokStream LaTeXState m (Many Block)
-> ParsecT TokStream LaTeXState m (Many Block))
-> ParsecT TokStream LaTeXState m (Many Block)
-> ParsecT TokStream LaTeXState m (Many Block)
forall a b. (a -> b) -> a -> b
$ do
LP m ()
forall (m :: * -> *). PandocMonad m => LP m ()
skipopts
color <- LP m [Tok]
forall (m :: * -> *). PandocMonad m => LP m [Tok]
braced
notFollowedBy (grouped inline)
let constructor = Attr -> Many Block -> Many Block
divWith (Text
"",[],[(Text
"style",Text
stylename Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
": " Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> [Tok] -> Text
untokenize [Tok]
color)])
constructor <$> grouped block
graphicsPath :: PandocMonad m => LP m Blocks
graphicsPath :: forall (m :: * -> *). PandocMonad m => LP m (Many Block)
graphicsPath = do
ps <- ([Tok] -> [Char]) -> [[Tok]] -> [[Char]]
forall a b. (a -> b) -> [a] -> [b]
map (Text -> [Char]
T.unpack (Text -> [Char]) -> ([Tok] -> Text) -> [Tok] -> [Char]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [Tok] -> Text
untokenize) ([[Tok]] -> [[Char]])
-> ParsecT TokStream LaTeXState m [[Tok]]
-> ParsecT TokStream LaTeXState m [[Char]]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$>
(LP m Tok
forall (m :: * -> *). PandocMonad m => LP m Tok
bgroup LP m Tok
-> ParsecT TokStream LaTeXState m ()
-> ParsecT TokStream LaTeXState m ()
forall a b.
ParsecT TokStream LaTeXState m a
-> ParsecT TokStream LaTeXState m b
-> ParsecT TokStream LaTeXState m b
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> ParsecT TokStream LaTeXState m ()
forall (m :: * -> *). PandocMonad m => LP m ()
spaces ParsecT TokStream LaTeXState m ()
-> ParsecT TokStream LaTeXState m [[Tok]]
-> ParsecT TokStream LaTeXState m [[Tok]]
forall a b.
ParsecT TokStream LaTeXState m a
-> ParsecT TokStream LaTeXState m b
-> ParsecT TokStream LaTeXState m b
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> ParsecT TokStream LaTeXState m [Tok]
-> LP m Tok -> ParsecT TokStream LaTeXState m [[Tok]]
forall s (m :: * -> *) t u a end.
Stream s m t =>
ParsecT s u m a -> ParsecT s u m end -> ParsecT s u m [a]
manyTill (ParsecT TokStream LaTeXState m [Tok]
forall (m :: * -> *). PandocMonad m => LP m [Tok]
braced ParsecT TokStream LaTeXState m [Tok]
-> ParsecT TokStream LaTeXState m ()
-> ParsecT TokStream LaTeXState m [Tok]
forall a b.
ParsecT TokStream LaTeXState m a
-> ParsecT TokStream LaTeXState m b
-> ParsecT TokStream LaTeXState m a
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
<* ParsecT TokStream LaTeXState m ()
forall (m :: * -> *). PandocMonad m => LP m ()
spaces) LP m Tok
forall (m :: * -> *). PandocMonad m => LP m Tok
egroup)
getResourcePath >>= setResourcePath . (<> ps)
return mempty
splitBibs :: Text -> [Inlines]
splitBibs :: Text -> [Many Inline]
splitBibs = (Text -> Many Inline) -> [Text] -> [Many Inline]
forall a b. (a -> b) -> [a] -> [b]
map (Text -> Many Inline
str (Text -> Many Inline) -> (Text -> Text) -> Text -> Many Inline
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [Char] -> Text
T.pack ([Char] -> Text) -> (Text -> [Char]) -> Text -> Text
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ([Char] -> [Char] -> [Char]) -> [Char] -> [Char] -> [Char]
forall a b c. (a -> b -> c) -> b -> a -> c
flip [Char] -> [Char] -> [Char]
replaceExtension [Char]
"bib" ([Char] -> [Char]) -> (Text -> [Char]) -> Text -> [Char]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Text -> [Char]
T.unpack (Text -> [Char]) -> (Text -> Text) -> Text -> [Char]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Text -> Text
trim) ([Text] -> [Many Inline])
-> (Text -> [Text]) -> Text -> [Many Inline]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Char -> Bool) -> Text -> [Text]
splitTextBy (Char -> Char -> Bool
forall a. Eq a => a -> a -> Bool
==Char
',')
alltt :: Blocks -> Blocks
alltt :: Many Block -> Many Block
alltt = (Inline -> Inline) -> Many Block -> Many Block
forall a b. Walkable a b => (a -> a) -> b -> b
walk Inline -> Inline
strToCode
where strToCode :: Inline -> Inline
strToCode (Str Text
s) = Attr -> Text -> Inline
Code Attr
nullAttr Text
s
strToCode Inline
Space = Format -> Text -> Inline
RawInline (Text -> Format
Format Text
"latex") Text
"\\ "
strToCode Inline
SoftBreak = Inline
LineBreak
strToCode Inline
x = Inline
x
parseListingsOptions :: [(Text, Text)] -> Attr
parseListingsOptions :: [(Text, Text)] -> Attr
parseListingsOptions [(Text, Text)]
options =
let kvs :: [(Text, Text)]
kvs = [ (if Text
k Text -> Text -> Bool
forall a. Eq a => a -> a -> Bool
== Text
"firstnumber"
then Text
"startFrom"
else Text
k, Text
v) | (Text
k,Text
v) <- [(Text, Text)]
options ]
classes :: [Text]
classes = [ Text
"numberLines" |
Text -> [(Text, Text)] -> Maybe Text
forall a b. Eq a => a -> [(a, b)] -> Maybe b
lookup Text
"numbers" [(Text, Text)]
options Maybe Text -> Maybe Text -> Bool
forall a. Eq a => a -> a -> Bool
== Text -> Maybe Text
forall a. a -> Maybe a
Just Text
"left" ]
[Text] -> [Text] -> [Text]
forall a. [a] -> [a] -> [a]
++ Maybe Text -> [Text]
forall a. Maybe a -> [a]
maybeToList ([(Text, Text)] -> Maybe Text
listingsLanguage [(Text, Text)]
options)
in (Text -> Maybe Text -> Text
forall a. a -> Maybe a -> a
fromMaybe Text
"" (Text -> [(Text, Text)] -> Maybe Text
forall a b. Eq a => a -> [(a, b)] -> Maybe b
lookup Text
"label" [(Text, Text)]
options), [Text]
classes, [(Text, Text)]
kvs)
inputListing :: PandocMonad m => LP m Blocks
inputListing :: forall (m :: * -> *). PandocMonad m => LP m (Many Block)
inputListing = do
pos <- ParsecT TokStream LaTeXState m SourcePos
forall (m :: * -> *) s u. Monad m => ParsecT s u m SourcePos
getPosition
options <- option [] keyvals
f <- T.filter (/='"') . untokenize <$> braced
mbCode <- readFileFromTexinputs (T.unpack f)
codeLines <- case mbCode of
Just Text
s -> [Text] -> ParsecT TokStream LaTeXState m [Text]
forall a. a -> ParsecT TokStream LaTeXState m a
forall (m :: * -> *) a. Monad m => a -> m a
return ([Text] -> ParsecT TokStream LaTeXState m [Text])
-> [Text] -> ParsecT TokStream LaTeXState m [Text]
forall a b. (a -> b) -> a -> b
$ Text -> [Text]
T.lines Text
s
Maybe Text
Nothing -> do
LogMessage -> ParsecT TokStream LaTeXState m ()
forall (m :: * -> *). PandocMonad m => LogMessage -> m ()
report (LogMessage -> ParsecT TokStream LaTeXState m ())
-> LogMessage -> ParsecT TokStream LaTeXState m ()
forall a b. (a -> b) -> a -> b
$ Text -> SourcePos -> LogMessage
CouldNotLoadIncludeFile Text
f SourcePos
pos
[Text] -> ParsecT TokStream LaTeXState m [Text]
forall a. a -> ParsecT TokStream LaTeXState m a
forall (m :: * -> *) a. Monad m => a -> m a
return []
let (ident,classes,kvs) = parseListingsOptions options
let classes' =
(case [(Text, Text)] -> Maybe Text
listingsLanguage [(Text, Text)]
options of
Maybe Text
Nothing -> (Int -> [Text] -> [Text]
forall a. Int -> [a] -> [a]
take Int
1 (SyntaxMap -> Text -> [Text]
languagesByExtension SyntaxMap
defaultSyntaxMap
([Char] -> Text
T.pack ([Char] -> Text) -> [Char] -> Text
forall a b. (a -> b) -> a -> b
$ [Char] -> [Char]
takeExtension ([Char] -> [Char]) -> [Char] -> [Char]
forall a b. (a -> b) -> a -> b
$ Text -> [Char]
T.unpack Text
f)) [Text] -> [Text] -> [Text]
forall a. Semigroup a => a -> a -> a
<>)
Just Text
_ -> [Text] -> [Text]
forall a. a -> a
id) [Text]
classes
let firstline = Int -> Maybe Int -> Int
forall a. a -> Maybe a -> a
fromMaybe Int
1 (Maybe Int -> Int) -> Maybe Int -> Int
forall a b. (a -> b) -> a -> b
$ Text -> [(Text, Text)] -> Maybe Text
forall a b. Eq a => a -> [(a, b)] -> Maybe b
lookup Text
"firstline" [(Text, Text)]
options Maybe Text -> (Text -> Maybe Int) -> Maybe Int
forall a b. Maybe a -> (a -> Maybe b) -> Maybe b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= Text -> Maybe Int
forall (m :: * -> *) a. (MonadPlus m, Read a) => Text -> m a
safeRead
let lastline = Int -> Maybe Int -> Int
forall a. a -> Maybe a -> a
fromMaybe ([Text] -> Int
forall a. [a] -> Int
forall (t :: * -> *) a. Foldable t => t a -> Int
length [Text]
codeLines) (Maybe Int -> Int) -> Maybe Int -> Int
forall a b. (a -> b) -> a -> b
$
Text -> [(Text, Text)] -> Maybe Text
forall a b. Eq a => a -> [(a, b)] -> Maybe b
lookup Text
"lastline" [(Text, Text)]
options Maybe Text -> (Text -> Maybe Int) -> Maybe Int
forall a b. Maybe a -> (a -> Maybe b) -> Maybe b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= Text -> Maybe Int
forall (m :: * -> *) a. (MonadPlus m, Read a) => Text -> m a
safeRead
let codeContents = Text -> [Text] -> Text
T.intercalate Text
"\n" ([Text] -> Text) -> [Text] -> Text
forall a b. (a -> b) -> a -> b
$ Int -> [Text] -> [Text]
forall a. Int -> [a] -> [a]
take (Int
1 Int -> Int -> Int
forall a. Num a => a -> a -> a
+ Int
lastline Int -> Int -> Int
forall a. Num a => a -> a -> a
- Int
firstline) ([Text] -> [Text]) -> [Text] -> [Text]
forall a b. (a -> b) -> a -> b
$
Int -> [Text] -> [Text]
forall a. Int -> [a] -> [a]
drop (Int
firstline Int -> Int -> Int
forall a. Num a => a -> a -> a
- Int
1) [Text]
codeLines
return $ codeBlockWith (ident,classes',kvs) codeContents
item :: PandocMonad m => LP m Blocks
item :: forall (m :: * -> *). PandocMonad m => LP m (Many Block)
item = ParsecT TokStream LaTeXState m (Many Block)
-> ParsecT TokStream LaTeXState m ()
forall (f :: * -> *) a. Functor f => f a -> f ()
void ParsecT TokStream LaTeXState m (Many Block)
forall (m :: * -> *). PandocMonad m => LP m (Many Block)
blocks ParsecT TokStream LaTeXState m ()
-> ParsecT TokStream LaTeXState m Tok
-> ParsecT TokStream LaTeXState m Tok
forall a b.
ParsecT TokStream LaTeXState m a
-> ParsecT TokStream LaTeXState m b
-> ParsecT TokStream LaTeXState m b
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> Text -> ParsecT TokStream LaTeXState m Tok
forall (m :: * -> *). PandocMonad m => Text -> LP m Tok
controlSeq Text
"item" ParsecT TokStream LaTeXState m Tok
-> ParsecT TokStream LaTeXState m ()
-> ParsecT TokStream LaTeXState m ()
forall a b.
ParsecT TokStream LaTeXState m a
-> ParsecT TokStream LaTeXState m b
-> ParsecT TokStream LaTeXState m b
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> ParsecT TokStream LaTeXState m ()
forall (m :: * -> *). PandocMonad m => LP m ()
skipopts ParsecT TokStream LaTeXState m ()
-> ParsecT TokStream LaTeXState m (Many Block)
-> ParsecT TokStream LaTeXState m (Many Block)
forall a b.
ParsecT TokStream LaTeXState m a
-> ParsecT TokStream LaTeXState m b
-> ParsecT TokStream LaTeXState m b
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> ParsecT TokStream LaTeXState m (Many Block)
forall (m :: * -> *). PandocMonad m => LP m (Many Block)
blocks
descItem :: PandocMonad m => LP m (Inlines, [Blocks])
descItem :: forall (m :: * -> *).
PandocMonad m =>
LP m (Many Inline, [Many Block])
descItem = do
ParsecT TokStream LaTeXState m ()
-> ParsecT TokStream LaTeXState m (Maybe ())
forall (f :: * -> *) a. Alternative f => f a -> f (Maybe a)
optional ParsecT TokStream LaTeXState m ()
forall (m :: * -> *). PandocMonad m => LP m ()
spaces1
Text -> LP m Tok
forall (m :: * -> *). PandocMonad m => Text -> LP m Tok
controlSeq Text
"item"
ParsecT TokStream LaTeXState m ()
forall (m :: * -> *). PandocMonad m => LP m ()
sp
ils <- LP m (Many Inline)
forall (m :: * -> *). PandocMonad m => LP m (Many Inline)
opt
bs <- blocks
return (ils, [bs])
listenv :: PandocMonad m => Text -> LP m a -> LP m a
listenv :: forall (m :: * -> *) a. PandocMonad m => Text -> LP m a -> LP m a
listenv Text
name LP m a
p = LP m a -> LP m a
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try (LP m a -> LP m a) -> LP m a -> LP m a
forall a b. (a -> b) -> a -> b
$ do
oldInListItem <- LaTeXState -> Bool
sInListItem (LaTeXState -> Bool)
-> ParsecT TokStream LaTeXState m LaTeXState
-> ParsecT TokStream LaTeXState m Bool
forall a b.
(a -> b)
-> ParsecT TokStream LaTeXState m a
-> ParsecT TokStream LaTeXState m b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
`fmap` ParsecT TokStream LaTeXState m LaTeXState
forall (m :: * -> *) s u. Monad m => ParsecT s u m u
getState
updateState $ \LaTeXState
st -> LaTeXState
st{ sInListItem = True }
res <- env name p
updateState $ \LaTeXState
st -> LaTeXState
st{ sInListItem = oldInListItem }
return res
orderedList' :: PandocMonad m => LP m Blocks
orderedList' :: forall (m :: * -> *). PandocMonad m => LP m (Many Block)
orderedList' = ParsecT TokStream LaTeXState m (Many Block)
-> ParsecT TokStream LaTeXState m (Many Block)
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try (ParsecT TokStream LaTeXState m (Many Block)
-> ParsecT TokStream LaTeXState m (Many Block))
-> ParsecT TokStream LaTeXState m (Many Block)
-> ParsecT TokStream LaTeXState m (Many Block)
forall a b. (a -> b) -> a -> b
$ do
LP m ()
forall (m :: * -> *). PandocMonad m => LP m ()
spaces
let markerSpec :: ParsecT
TokStream LaTeXState m (Int, ListNumberStyle, ListNumberDelim)
markerSpec = do
Char -> LP m Tok
forall (m :: * -> *). PandocMonad m => Char -> LP m Tok
symbol Char
'['
ts <- [Tok] -> Text
untokenize ([Tok] -> Text)
-> ParsecT TokStream LaTeXState m [Tok]
-> ParsecT TokStream LaTeXState m Text
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> LP m Tok -> LP m Tok -> ParsecT TokStream LaTeXState m [Tok]
forall s (m :: * -> *) t u a end.
Stream s m t =>
ParsecT s u m a -> ParsecT s u m end -> ParsecT s u m [a]
manyTill LP m Tok
forall (m :: * -> *). PandocMonad m => LP m Tok
anyTok (Char -> LP m Tok
forall (m :: * -> *). PandocMonad m => Char -> LP m Tok
symbol Char
']')
case runParser anyOrderedListMarker def "option" ts of
Right (Int, ListNumberStyle, ListNumberDelim)
r -> (Int, ListNumberStyle, ListNumberDelim)
-> ParsecT
TokStream LaTeXState m (Int, ListNumberStyle, ListNumberDelim)
forall a. a -> ParsecT TokStream LaTeXState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (Int, ListNumberStyle, ListNumberDelim)
r
Left ParseError
_ -> do
pos <- ParsecT TokStream LaTeXState m SourcePos
forall (m :: * -> *) s u. Monad m => ParsecT s u m SourcePos
getPosition
report $ SkippedContent ("[" <> ts <> "]") pos
return (1, DefaultStyle, DefaultDelim)
(_, style, delim) <- (Int, ListNumberStyle, ListNumberDelim)
-> ParsecT
TokStream LaTeXState m (Int, ListNumberStyle, ListNumberDelim)
-> ParsecT
TokStream LaTeXState m (Int, ListNumberStyle, ListNumberDelim)
forall s (m :: * -> *) t a u.
Stream s m t =>
a -> ParsecT s u m a -> ParsecT s u m a
option (Int
1, ListNumberStyle
DefaultStyle, ListNumberDelim
DefaultDelim) ParsecT
TokStream LaTeXState m (Int, ListNumberStyle, ListNumberDelim)
markerSpec
spaces
optional $ try $ controlSeq "setlength"
*> grouped (count 1 $ controlSeq "itemindent")
*> braced
spaces
start <- option 1 $ try $ do pos <- getPosition
controlSeq "setcounter"
ctr <- untokenize <$> braced
guard $ "enum" `T.isPrefixOf` ctr
guard $ T.all (`elem` ['i','v']) (T.drop 4 ctr)
sp
num <- untokenize <$> braced
case safeRead num of
Just Int
i -> Int -> ParsecT TokStream LaTeXState m Int
forall a. a -> ParsecT TokStream LaTeXState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (Int
i Int -> Int -> Int
forall a. Num a => a -> a -> a
+ Int
1 :: Int)
Maybe Int
Nothing -> do
LogMessage -> LP m ()
forall (m :: * -> *). PandocMonad m => LogMessage -> m ()
report (LogMessage -> LP m ()) -> LogMessage -> LP m ()
forall a b. (a -> b) -> a -> b
$ Text -> SourcePos -> LogMessage
SkippedContent
(Text
"\\setcounter{" Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
ctr Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<>
Text
"}{" Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
num Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
"}") SourcePos
pos
Int -> ParsecT TokStream LaTeXState m Int
forall a. a -> ParsecT TokStream LaTeXState m a
forall (m :: * -> *) a. Monad m => a -> m a
return Int
1
bs <- listenv "enumerate" (many item)
return $ orderedListWith (start, style, delim) bs
block :: PandocMonad m => LP m Blocks
block :: forall (m :: * -> *). PandocMonad m => LP m (Many Block)
block = do
Tok _ toktype _ <- LP m Tok
forall (m :: * -> *). PandocMonad m => LP m Tok
peekTok
res <- (case toktype of
TokType
Newline -> Many Block
forall a. Monoid a => a
mempty Many Block
-> ParsecT TokStream LaTeXState m ()
-> ParsecT TokStream LaTeXState m (Many Block)
forall a b.
a
-> ParsecT TokStream LaTeXState m b
-> ParsecT TokStream LaTeXState m a
forall (f :: * -> *) a b. Functor f => a -> f b -> f a
<$ ParsecT TokStream LaTeXState m ()
forall (m :: * -> *). PandocMonad m => LP m ()
spaces1
TokType
Spaces -> Many Block
forall a. Monoid a => a
mempty Many Block
-> ParsecT TokStream LaTeXState m ()
-> ParsecT TokStream LaTeXState m (Many Block)
forall a b.
a
-> ParsecT TokStream LaTeXState m b
-> ParsecT TokStream LaTeXState m a
forall (f :: * -> *) a b. Functor f => a -> f b -> f a
<$ ParsecT TokStream LaTeXState m ()
forall (m :: * -> *). PandocMonad m => LP m ()
spaces1
TokType
Comment -> Many Block
forall a. Monoid a => a
mempty Many Block
-> ParsecT TokStream LaTeXState m ()
-> ParsecT TokStream LaTeXState m (Many Block)
forall a b.
a
-> ParsecT TokStream LaTeXState m b
-> ParsecT TokStream LaTeXState m a
forall (f :: * -> *) a b. Functor f => a -> f b -> f a
<$ ParsecT TokStream LaTeXState m ()
forall (m :: * -> *). PandocMonad m => LP m ()
spaces1
TokType
Word -> ParsecT TokStream LaTeXState m (Many Block)
forall (m :: * -> *). PandocMonad m => LP m (Many Block)
paragraph
CtrlSeq Text
"begin" -> ParsecT TokStream LaTeXState m (Many Block)
forall (m :: * -> *). PandocMonad m => LP m (Many Block)
environment
CtrlSeq Text
_ -> (Text -> Many Block) -> ParsecT TokStream LaTeXState m (Many Block)
forall (m :: * -> *) a.
(PandocMonad m, Monoid a) =>
(Text -> a) -> LP m a
macroDef (Text -> Text -> Many Block
rawBlock Text
"latex")
ParsecT TokStream LaTeXState m (Many Block)
-> ParsecT TokStream LaTeXState m (Many Block)
-> ParsecT TokStream LaTeXState m (Many Block)
forall a.
ParsecT TokStream LaTeXState m a
-> ParsecT TokStream LaTeXState m a
-> ParsecT TokStream LaTeXState m a
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> ParsecT TokStream LaTeXState m (Many Block)
forall (m :: * -> *). PandocMonad m => LP m (Many Block)
blockCommand
TokType
_ -> ParsecT TokStream LaTeXState m (Many Block)
forall a. ParsecT TokStream LaTeXState m a
forall (m :: * -> *) a. MonadPlus m => m a
mzero)
<|> paragraph
<|> grouped block
trace (T.take 60 $ tshow $ B.toList res)
return res
blocks :: PandocMonad m => LP m Blocks
blocks :: forall (m :: * -> *). PandocMonad m => LP m (Many Block)
blocks = [Many Block] -> Many Block
forall a. Monoid a => [a] -> a
mconcat ([Many Block] -> Many Block)
-> ParsecT TokStream LaTeXState m [Many Block]
-> ParsecT TokStream LaTeXState m (Many Block)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ParsecT TokStream LaTeXState m (Many Block)
-> ParsecT TokStream LaTeXState m [Many Block]
forall a.
ParsecT TokStream LaTeXState m a
-> ParsecT TokStream LaTeXState m [a]
forall (f :: * -> *) a. Alternative f => f a -> f [a]
many ParsecT TokStream LaTeXState m (Many Block)
forall (m :: * -> *). PandocMonad m => LP m (Many Block)
block