{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE ViewPatterns #-}
module Text.Pandoc.Readers.Textile ( readTextile) where
import Control.Monad (guard, liftM)
import Control.Monad.Except (throwError)
import Data.Char (digitToInt, isUpper)
import Data.List (intersperse, transpose)
import Data.Text (Text)
import qualified Data.Text as T
import Text.HTML.TagSoup (Tag (..), fromAttrib)
import Text.HTML.TagSoup.Match
import Text.Pandoc.Builder (Blocks, Inlines, trimInlines)
import qualified Text.Pandoc.Builder as B
import Text.Pandoc.Class.PandocMonad (PandocMonad (..))
import Text.Pandoc.CSS
import Text.Pandoc.Definition
import Text.Pandoc.Options
import Text.Pandoc.Parsing
import Text.Pandoc.Readers.HTML (htmlTag, isBlockTag, isInlineTag)
import Text.Pandoc.Readers.LaTeX (rawLaTeXBlock, rawLaTeXInline)
import Text.Pandoc.Shared (crFilter, trim, tshow)
readTextile :: PandocMonad m
=> ReaderOptions
-> Text
-> m Pandoc
readTextile :: ReaderOptions -> Text -> m Pandoc
readTextile ReaderOptions
opts Text
s = do
Either PandocError Pandoc
parsed <- ParserT Text ParserState m Pandoc
-> ParserState -> Text -> m (Either PandocError Pandoc)
forall s (m :: * -> *) st a.
(Stream s m Char, ToText s) =>
ParserT s st m a -> st -> s -> m (Either PandocError a)
readWithM ParserT Text ParserState m Pandoc
forall (m :: * -> *).
PandocMonad m =>
ParserT Text ParserState m Pandoc
parseTextile ParserState
forall a. Default a => a
def{ stateOptions :: ReaderOptions
stateOptions = ReaderOptions
opts }
(Text -> Text
crFilter Text
s Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
"\n\n")
case Either PandocError Pandoc
parsed of
Right Pandoc
result -> Pandoc -> m Pandoc
forall (m :: * -> *) a. Monad m => a -> m a
return Pandoc
result
Left PandocError
e -> PandocError -> m Pandoc
forall e (m :: * -> *) a. MonadError e m => e -> m a
throwError PandocError
e
parseTextile :: PandocMonad m => ParserT Text ParserState m Pandoc
parseTextile :: ParserT Text ParserState m Pandoc
parseTextile = do
ParsecT Text ParserState m Char
-> ParsecT Text ParserState m [Char]
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m [a]
many ParsecT Text ParserState m Char
forall s (m :: * -> *) st. Stream s m Char => ParserT s st m Char
blankline
SourcePos
startPos <- ParsecT Text ParserState m SourcePos
forall (m :: * -> *) s u. Monad m => ParsecT s u m SourcePos
getPosition
let firstPassParser :: ParsecT Text ParserState m Text
firstPassParser = ParsecT Text ParserState m Text
forall (m :: * -> *).
PandocMonad m =>
ParserT Text ParserState m Text
noteBlock ParsecT Text ParserState m Text
-> ParsecT Text ParserState m Text
-> ParsecT Text ParserState m Text
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> ParsecT Text ParserState m Text
forall (m :: * -> *) st. Monad m => ParserT Text st m Text
lineClump
ParsecT Text ParserState m Text
-> ParsecT Text ParserState m ()
-> ParsecT Text ParserState m [Text]
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 Text ParserState m Text
firstPassParser ParsecT Text ParserState m ()
forall s (m :: * -> *) t u.
(Stream s m t, Show t) =>
ParsecT s u m ()
eof ParsecT Text ParserState m [Text]
-> ([Text] -> ParsecT Text ParserState m ())
-> ParsecT Text ParserState m ()
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= Text -> ParsecT Text ParserState m ()
forall (m :: * -> *) s u. Monad m => s -> ParsecT s u m ()
setInput (Text -> ParsecT Text ParserState m ())
-> ([Text] -> Text) -> [Text] -> ParsecT Text ParserState m ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [Text] -> Text
T.concat
SourcePos -> ParsecT Text ParserState m ()
forall (m :: * -> *) s u. Monad m => SourcePos -> ParsecT s u m ()
setPosition SourcePos
startPos
ParserState
st' <- ParsecT Text ParserState m ParserState
forall (m :: * -> *) s u. Monad m => ParsecT s u m u
getState
let reversedNotes :: NoteTable
reversedNotes = ParserState -> NoteTable
stateNotes ParserState
st'
(ParserState -> ParserState) -> ParsecT Text ParserState m ()
forall (m :: * -> *) u s. Monad m => (u -> u) -> ParsecT s u m ()
updateState ((ParserState -> ParserState) -> ParsecT Text ParserState m ())
-> (ParserState -> ParserState) -> ParsecT Text ParserState m ()
forall a b. (a -> b) -> a -> b
$ \ParserState
s -> ParserState
s { stateNotes :: NoteTable
stateNotes = NoteTable -> NoteTable
forall a. [a] -> [a]
reverse NoteTable
reversedNotes }
Meta -> [Block] -> Pandoc
Pandoc Meta
nullMeta ([Block] -> Pandoc)
-> (Many Block -> [Block]) -> Many Block -> Pandoc
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Many Block -> [Block]
forall a. Many a -> [a]
B.toList (Many Block -> Pandoc)
-> ParsecT Text ParserState m (Many Block)
-> ParserT Text ParserState m Pandoc
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ParsecT Text ParserState m (Many Block)
forall (m :: * -> *).
PandocMonad m =>
ParserT Text ParserState m (Many Block)
parseBlocks
noteMarker :: PandocMonad m => ParserT Text ParserState m Text
noteMarker :: ParserT Text ParserState m Text
noteMarker = ParsecT Text ParserState m Char -> ParsecT Text ParserState m ()
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m ()
skipMany ParsecT Text ParserState m Char
forall s (m :: * -> *) st. Stream s m Char => ParserT s st m Char
spaceChar ParsecT Text ParserState m ()
-> ParsecT Text ParserState m [Char]
-> ParsecT Text ParserState m [Char]
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> [Char] -> ParsecT Text ParserState m [Char]
forall s (m :: * -> *) u.
Stream s m Char =>
[Char] -> ParsecT s u m [Char]
string [Char]
"fn" ParsecT Text ParserState m [Char]
-> ParserT Text ParserState m Text
-> ParserT Text ParserState m Text
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> [Char] -> Text
T.pack ([Char] -> Text)
-> ParsecT Text ParserState m [Char]
-> ParserT Text ParserState m Text
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ParsecT Text ParserState m Char
-> ParsecT Text ParserState m Char
-> ParsecT Text ParserState m [Char]
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 Text ParserState m Char
forall s (m :: * -> *) st. Stream s m Char => ParserT s st m Char
digit (Char -> ParsecT Text ParserState m Char
forall s (m :: * -> *) u.
Stream s m Char =>
Char -> ParsecT s u m Char
char Char
'.')
noteBlock :: PandocMonad m => ParserT Text ParserState m Text
noteBlock :: ParserT Text ParserState m Text
noteBlock = ParserT Text ParserState m Text -> ParserT Text ParserState m Text
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try (ParserT Text ParserState m Text
-> ParserT Text ParserState m Text)
-> ParserT Text ParserState m Text
-> ParserT Text ParserState m Text
forall a b. (a -> b) -> a -> b
$ do
SourcePos
startPos <- ParsecT Text ParserState m SourcePos
forall (m :: * -> *) s u. Monad m => ParsecT s u m SourcePos
getPosition
Text
ref <- ParserT Text ParserState m Text
forall (m :: * -> *).
PandocMonad m =>
ParserT Text ParserState m Text
noteMarker
ParsecT Text ParserState m Char -> ParsecT Text ParserState m ()
forall s (m :: * -> *) t u a.
Stream s m t =>
ParsecT s u m a -> ParsecT s u m ()
optional ParsecT Text ParserState m Char
forall s (m :: * -> *) st. Stream s m Char => ParserT s st m Char
blankline
Text
contents <- [Text] -> Text
T.unlines ([Text] -> Text)
-> ParsecT Text ParserState m [Text]
-> ParserT Text ParserState m Text
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ParserT Text ParserState m Text
-> ParserT Text ParserState m Text
-> ParsecT Text ParserState m [Text]
forall end s (m :: * -> *) t st a.
(Show end, Stream s m t) =>
ParserT s st m a -> ParserT s st m end -> ParserT s st m [a]
many1Till ParserT Text ParserState m Text
forall (m :: * -> *) st. Monad m => ParserT Text st m Text
anyLine (ParserT Text ParserState m Text
forall s (m :: * -> *) st. Stream s m Char => ParserT s st m Text
blanklines ParserT Text ParserState m Text
-> ParserT Text ParserState m Text
-> ParserT Text ParserState m Text
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> ParserT Text ParserState m Text
forall (m :: * -> *).
PandocMonad m =>
ParserT Text ParserState m Text
noteBlock)
SourcePos
endPos <- ParsecT Text ParserState m SourcePos
forall (m :: * -> *) s u. Monad m => ParsecT s u m SourcePos
getPosition
let newnote :: (Text, Text)
newnote = (Text
ref, Text
contents Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
"\n")
ParserState
st <- ParsecT Text ParserState m ParserState
forall (m :: * -> *) s u. Monad m => ParsecT s u m u
getState
let oldnotes :: NoteTable
oldnotes = ParserState -> NoteTable
stateNotes ParserState
st
(ParserState -> ParserState) -> ParsecT Text ParserState m ()
forall (m :: * -> *) u s. Monad m => (u -> u) -> ParsecT s u m ()
updateState ((ParserState -> ParserState) -> ParsecT Text ParserState m ())
-> (ParserState -> ParserState) -> ParsecT Text ParserState m ()
forall a b. (a -> b) -> a -> b
$ \ParserState
s -> ParserState
s { stateNotes :: NoteTable
stateNotes = (Text, Text)
newnote (Text, Text) -> NoteTable -> NoteTable
forall a. a -> [a] -> [a]
: NoteTable
oldnotes }
Text -> ParserT Text ParserState m Text
forall (m :: * -> *) a. Monad m => a -> m a
return (Text -> ParserT Text ParserState m Text)
-> Text -> ParserT Text ParserState m Text
forall a b. (a -> b) -> a -> b
$ Int -> Text -> Text
T.replicate (SourcePos -> Int
sourceLine SourcePos
endPos Int -> Int -> Int
forall a. Num a => a -> a -> a
- SourcePos -> Int
sourceLine SourcePos
startPos) Text
"\n"
parseBlocks :: PandocMonad m => ParserT Text ParserState m Blocks
parseBlocks :: ParserT Text ParserState m (Many Block)
parseBlocks = [Many Block] -> Many Block
forall a. Monoid a => [a] -> a
mconcat ([Many Block] -> Many Block)
-> ParsecT Text ParserState m [Many Block]
-> ParserT Text ParserState m (Many Block)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ParserT Text ParserState m (Many Block)
-> ParsecT Text ParserState m ()
-> ParsecT Text ParserState m [Many Block]
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 ParserT Text ParserState m (Many Block)
forall (m :: * -> *).
PandocMonad m =>
ParserT Text ParserState m (Many Block)
block ParsecT Text ParserState m ()
forall s (m :: * -> *) t u.
(Stream s m t, Show t) =>
ParsecT s u m ()
eof
blockParsers :: PandocMonad m => [ParserT Text ParserState m Blocks]
blockParsers :: [ParserT Text ParserState m (Many Block)]
blockParsers = [ ParserT Text ParserState m (Many Block)
forall (m :: * -> *).
PandocMonad m =>
ParserT Text ParserState m (Many Block)
codeBlock
, ParserT Text ParserState m (Many Block)
forall (m :: * -> *).
PandocMonad m =>
ParserT Text ParserState m (Many Block)
header
, ParserT Text ParserState m (Many Block)
forall (m :: * -> *).
PandocMonad m =>
ParserT Text ParserState m (Many Block)
blockQuote
, ParserT Text ParserState m (Many Block)
forall (m :: * -> *) st.
PandocMonad m =>
ParserT Text st m (Many Block)
hrule
, ParserT Text ParserState m (Many Block)
forall (m :: * -> *).
PandocMonad m =>
ParserT Text ParserState m (Many Block)
commentBlock
, ParserT Text ParserState m (Many Block)
forall (m :: * -> *).
PandocMonad m =>
ParserT Text ParserState m (Many Block)
anyList
, ParserT Text ParserState m (Many Block)
forall (m :: * -> *).
PandocMonad m =>
ParserT Text ParserState m (Many Block)
rawHtmlBlock
, ParserT Text ParserState m (Many Block)
forall (m :: * -> *).
PandocMonad m =>
ParserT Text ParserState m (Many Block)
rawLaTeXBlock'
, ParserT Text ParserState m (Many Block)
forall (m :: * -> *).
PandocMonad m =>
ParserT Text ParserState m (Many Block)
table
, Text
-> ParserT Text ParserState m (Many Block)
-> ParserT Text ParserState m (Many Block)
forall (m :: * -> *).
PandocMonad m =>
Text
-> ParserT Text ParserState m (Many Block)
-> ParserT Text ParserState m (Many Block)
maybeExplicitBlock Text
"p" ParserT Text ParserState m (Many Block)
forall (m :: * -> *).
PandocMonad m =>
ParserT Text ParserState m (Many Block)
para
, Many Block
forall a. Monoid a => a
mempty Many Block
-> ParsecT Text ParserState m Text
-> ParserT Text ParserState m (Many Block)
forall (f :: * -> *) a b. Functor f => a -> f b -> f a
<$ ParsecT Text ParserState m Text
forall s (m :: * -> *) st. Stream s m Char => ParserT s st m Text
blanklines
]
block :: PandocMonad m => ParserT Text ParserState m Blocks
block :: ParserT Text ParserState m (Many Block)
block = do
Many Block
res <- [ParserT Text ParserState m (Many Block)]
-> ParserT Text ParserState m (Many Block)
forall s (m :: * -> *) t u a.
Stream s m t =>
[ParsecT s u m a] -> ParsecT s u m a
choice [ParserT Text ParserState m (Many Block)]
forall (m :: * -> *).
PandocMonad m =>
[ParserT Text ParserState m (Many Block)]
blockParsers ParserT Text ParserState m (Many Block)
-> [Char] -> ParserT Text ParserState m (Many Block)
forall s u (m :: * -> *) a.
ParsecT s u m a -> [Char] -> ParsecT s u m a
<?> [Char]
"block"
Text -> ParsecT Text ParserState m ()
forall (m :: * -> *). PandocMonad m => Text -> m ()
trace (Int -> Text -> Text
T.take Int
60 (Text -> Text) -> Text -> Text
forall a b. (a -> b) -> a -> b
$ [Block] -> Text
forall a. Show a => a -> Text
tshow ([Block] -> Text) -> [Block] -> Text
forall a b. (a -> b) -> a -> b
$ Many Block -> [Block]
forall a. Many a -> [a]
B.toList Many Block
res)
Many Block -> ParserT Text ParserState m (Many Block)
forall (m :: * -> *) a. Monad m => a -> m a
return Many Block
res
commentBlock :: PandocMonad m => ParserT Text ParserState m Blocks
= ParserT Text ParserState m (Many Block)
-> ParserT Text ParserState m (Many Block)
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try (ParserT Text ParserState m (Many Block)
-> ParserT Text ParserState m (Many Block))
-> ParserT Text ParserState m (Many Block)
-> ParserT Text ParserState m (Many Block)
forall a b. (a -> b) -> a -> b
$ do
[Char] -> ParsecT Text ParserState m [Char]
forall s (m :: * -> *) u.
Stream s m Char =>
[Char] -> ParsecT s u m [Char]
string [Char]
"###."
ParsecT Text ParserState m Text
-> ParsecT Text ParserState m Text
-> ParsecT Text ParserState m [Text]
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 Text ParserState m Text
forall (m :: * -> *) st. Monad m => ParserT Text st m Text
anyLine ParsecT Text ParserState m Text
forall s (m :: * -> *) st. Stream s m Char => ParserT s st m Text
blanklines
Many Block -> ParserT Text ParserState m (Many Block)
forall (m :: * -> *) a. Monad m => a -> m a
return Many Block
forall a. Monoid a => a
mempty
codeBlock :: PandocMonad m => ParserT Text ParserState m Blocks
codeBlock :: ParserT Text ParserState m (Many Block)
codeBlock = ParserT Text ParserState m (Many Block)
forall (m :: * -> *).
PandocMonad m =>
ParserT Text ParserState m (Many Block)
codeBlockTextile ParserT Text ParserState m (Many Block)
-> ParserT Text ParserState m (Many Block)
-> ParserT Text ParserState m (Many Block)
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> ParserT Text ParserState m (Many Block)
forall (m :: * -> *).
PandocMonad m =>
ParserT Text ParserState m (Many Block)
codeBlockHtml
codeBlockTextile :: PandocMonad m => ParserT Text ParserState m Blocks
codeBlockTextile :: ParserT Text ParserState m (Many Block)
codeBlockTextile = ParserT Text ParserState m (Many Block)
-> ParserT Text ParserState m (Many Block)
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try (ParserT Text ParserState m (Many Block)
-> ParserT Text ParserState m (Many Block))
-> ParserT Text ParserState m (Many Block)
-> ParserT Text ParserState m (Many Block)
forall a b. (a -> b) -> a -> b
$ do
[Char] -> ParsecT Text ParserState m [Char]
forall s (m :: * -> *) u.
Stream s m Char =>
[Char] -> ParsecT s u m [Char]
string [Char]
"bc." ParsecT Text ParserState m [Char]
-> ParsecT Text ParserState m [Char]
-> ParsecT Text ParserState m [Char]
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> [Char] -> ParsecT Text ParserState m [Char]
forall s (m :: * -> *) u.
Stream s m Char =>
[Char] -> ParsecT s u m [Char]
string [Char]
"pre."
Bool
extended <- Bool
-> ParsecT Text ParserState m Bool
-> ParsecT Text ParserState m Bool
forall s (m :: * -> *) t a u.
Stream s m t =>
a -> ParsecT s u m a -> ParsecT s u m a
option Bool
False (Bool
True Bool
-> ParsecT Text ParserState m Char
-> ParsecT Text ParserState m Bool
forall (f :: * -> *) a b. Functor f => a -> f b -> f a
<$ Char -> ParsecT Text ParserState m Char
forall s (m :: * -> *) u.
Stream s m Char =>
Char -> ParsecT s u m Char
char Char
'.')
Char -> ParsecT Text ParserState m Char
forall s (m :: * -> *) u.
Stream s m Char =>
Char -> ParsecT s u m Char
char Char
' '
let starts :: [Text]
starts = [Text
"p", Text
"table", Text
"bq", Text
"bc", Text
"pre", Text
"h1", Text
"h2", Text
"h3",
Text
"h4", Text
"h5", Text
"h6", Text
"pre", Text
"###", Text
"notextile"]
let ender :: ParsecT Text ParserState m ()
ender = [ParsecT Text ParserState m ()] -> ParsecT Text ParserState m ()
forall s (m :: * -> *) t u a.
Stream s m t =>
[ParsecT s u m a] -> ParsecT s u m a
choice ([ParsecT Text ParserState m ()] -> ParsecT Text ParserState m ())
-> [ParsecT Text ParserState m ()] -> ParsecT Text ParserState m ()
forall a b. (a -> b) -> a -> b
$ (Text -> ParsecT Text ParserState m ())
-> [Text] -> [ParsecT Text ParserState m ()]
forall a b. (a -> b) -> [a] -> [b]
map Text -> ParsecT Text ParserState m ()
forall (m :: * -> *).
PandocMonad m =>
Text -> ParserT Text ParserState m ()
explicitBlockStart [Text]
starts
[Text]
contents <- if Bool
extended
then do
Text
f <- ParserT Text ParserState m Text
forall (m :: * -> *) st. Monad m => ParserT Text st m Text
anyLine
[Text]
rest <- ParserT Text ParserState m Text
-> ParsecT Text ParserState m [Text]
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m [a]
many (ParsecT Text ParserState m () -> ParsecT Text ParserState m ()
forall s (m :: * -> *) t a u.
(Stream s m t, Show a) =>
ParsecT s u m a -> ParsecT s u m ()
notFollowedBy ParsecT Text ParserState m ()
ender ParsecT Text ParserState m ()
-> ParserT Text ParserState m Text
-> ParserT Text ParserState m Text
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> ParserT Text ParserState m Text
forall (m :: * -> *) st. Monad m => ParserT Text st m Text
anyLine)
[Text] -> ParsecT Text ParserState m [Text]
forall (m :: * -> *) a. Monad m => a -> m a
return (Text
fText -> [Text] -> [Text]
forall a. a -> [a] -> [a]
:[Text]
rest)
else ParserT Text ParserState m Text
-> ParserT Text ParserState m Text
-> ParsecT Text ParserState m [Text]
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 ParserT Text ParserState m Text
forall (m :: * -> *) st. Monad m => ParserT Text st m Text
anyLine ParserT Text ParserState m Text
forall s (m :: * -> *) st. Stream s m Char => ParserT s st m Text
blanklines
Many Block -> ParserT Text ParserState m (Many Block)
forall (m :: * -> *) a. Monad m => a -> m a
return (Many Block -> ParserT Text ParserState m (Many Block))
-> Many Block -> ParserT Text ParserState m (Many Block)
forall a b. (a -> b) -> a -> b
$ Text -> Many Block
B.codeBlock (Text -> Text
trimTrailingNewlines ([Text] -> Text
T.unlines [Text]
contents))
trimTrailingNewlines :: Text -> Text
trimTrailingNewlines :: Text -> Text
trimTrailingNewlines = (Char -> Bool) -> Text -> Text
T.dropWhileEnd (Char -> Char -> Bool
forall a. Eq a => a -> a -> Bool
==Char
'\n')
codeBlockHtml :: PandocMonad m => ParserT Text ParserState m Blocks
codeBlockHtml :: ParserT Text ParserState m (Many Block)
codeBlockHtml = ParserT Text ParserState m (Many Block)
-> ParserT Text ParserState m (Many Block)
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try (ParserT Text ParserState m (Many Block)
-> ParserT Text ParserState m (Many Block))
-> ParserT Text ParserState m (Many Block)
-> ParserT Text ParserState m (Many Block)
forall a b. (a -> b) -> a -> b
$ do
(t :: Tag Text
t@(TagOpen Text
_ NoteTable
attrs),Text
_) <- (Tag Text -> Bool) -> ParserT Text ParserState m (Tag Text, Text)
forall st (m :: * -> *).
(HasReaderOptions st, Monad m) =>
(Tag Text -> Bool) -> ParserT Text st m (Tag Text, Text)
htmlTag ((Text -> Bool) -> (NoteTable -> Bool) -> Tag Text -> Bool
forall str.
(str -> Bool) -> ([Attribute str] -> Bool) -> Tag str -> Bool
tagOpen (Text -> Text -> Bool
forall a. Eq a => a -> a -> Bool
==Text
"pre") (Bool -> NoteTable -> Bool
forall a b. a -> b -> a
const Bool
True))
Text
result' <- [Char] -> Text
T.pack ([Char] -> Text)
-> ParsecT Text ParserState m [Char]
-> ParsecT Text ParserState m Text
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ParsecT Text ParserState m Char
-> ParserT Text ParserState m (Tag Text, Text)
-> ParsecT Text ParserState m [Char]
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 Text ParserState m Char
forall s (m :: * -> *) st. Stream s m Char => ParserT s st m Char
anyChar ((Tag Text -> Bool) -> ParserT Text ParserState m (Tag Text, Text)
forall st (m :: * -> *).
(HasReaderOptions st, Monad m) =>
(Tag Text -> Bool) -> ParserT Text st m (Tag Text, Text)
htmlTag ((Text -> Bool) -> Tag Text -> Bool
forall str. (str -> Bool) -> Tag str -> Bool
tagClose (Text -> Text -> Bool
forall a. Eq a => a -> a -> Bool
==Text
"pre")))
let result'' :: Text
result'' = case Text -> Maybe (Char, Text)
T.uncons Text
result' of
Just (Char
'\n', Text
xs) -> Text
xs
Maybe (Char, Text)
_ -> Text
result'
let result''' :: Text
result''' = case Text -> Maybe (Text, Char)
T.unsnoc Text
result'' of
Just (Text
xs, Char
'\n') -> Text
xs
Maybe (Text, Char)
_ -> Text
result''
let classes :: [Text]
classes = Text -> [Text]
T.words (Text -> [Text]) -> Text -> [Text]
forall a b. (a -> b) -> a -> b
$ Text -> Tag Text -> Text
forall str.
(Show str, Eq str, StringLike str) =>
str -> Tag str -> str
fromAttrib Text
"class" Tag Text
t
let ident :: Text
ident = Text -> Tag Text -> Text
forall str.
(Show str, Eq str, StringLike str) =>
str -> Tag str -> str
fromAttrib Text
"id" Tag Text
t
let kvs :: NoteTable
kvs = [(Text
k,Text
v) | (Text
k,Text
v) <- NoteTable
attrs, Text
k Text -> Text -> Bool
forall a. Eq a => a -> a -> Bool
/= Text
"id" Bool -> Bool -> Bool
&& Text
k Text -> Text -> Bool
forall a. Eq a => a -> a -> Bool
/= Text
"class"]
Many Block -> ParserT Text ParserState m (Many Block)
forall (m :: * -> *) a. Monad m => a -> m a
return (Many Block -> ParserT Text ParserState m (Many Block))
-> Many Block -> ParserT Text ParserState m (Many Block)
forall a b. (a -> b) -> a -> b
$ Attr -> Text -> Many Block
B.codeBlockWith (Text
ident,[Text]
classes,NoteTable
kvs) Text
result'''
header :: PandocMonad m => ParserT Text ParserState m Blocks
= ParserT Text ParserState m (Many Block)
-> ParserT Text ParserState m (Many Block)
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try (ParserT Text ParserState m (Many Block)
-> ParserT Text ParserState m (Many Block))
-> ParserT Text ParserState m (Many Block)
-> ParserT Text ParserState m (Many Block)
forall a b. (a -> b) -> a -> b
$ do
Char -> ParsecT Text ParserState m Char
forall s (m :: * -> *) u.
Stream s m Char =>
Char -> ParsecT s u m Char
char Char
'h'
Int
level <- Char -> Int
digitToInt (Char -> Int)
-> ParsecT Text ParserState m Char
-> ParsecT Text ParserState m Int
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> [Char] -> ParsecT Text ParserState m Char
forall s (m :: * -> *) u.
Stream s m Char =>
[Char] -> ParsecT s u m Char
oneOf [Char]
"123456"
Attr
attr <- ParserT Text ParserState m Attr
forall (m :: * -> *).
PandocMonad m =>
ParserT Text ParserState m Attr
attributes
Char -> ParsecT Text ParserState m Char
forall s (m :: * -> *) u.
Stream s m Char =>
Char -> ParsecT s u m Char
char Char
'.'
ParsecT Text ParserState m Inlines
-> ParsecT Text ParserState m Inlines
forall s (m :: * -> *) t u a.
Stream s m t =>
ParsecT s u m a -> ParsecT s u m a
lookAhead ParsecT Text ParserState m Inlines
forall (m :: * -> *) st. PandocMonad m => ParserT Text st m Inlines
whitespace
Inlines
name <- Inlines -> Inlines
trimInlines (Inlines -> Inlines)
-> ([Inlines] -> Inlines) -> [Inlines] -> Inlines
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [Inlines] -> Inlines
forall a. Monoid a => [a] -> a
mconcat ([Inlines] -> Inlines)
-> ParsecT Text ParserState m [Inlines]
-> ParsecT Text ParserState m Inlines
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ParsecT Text ParserState m Inlines
-> ParsecT Text ParserState m [Inlines]
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m [a]
many ParsecT Text ParserState m Inlines
forall (m :: * -> *).
PandocMonad m =>
ParserT Text ParserState m Inlines
inline
Attr
attr' <- Attr -> Inlines -> ParserT Text ParserState m Attr
forall s (m :: * -> *) a st.
(Stream s m a, HasReaderOptions st, HasLogMessages st,
HasIdentifierList st) =>
Attr -> Inlines -> ParserT s st m Attr
registerHeader Attr
attr Inlines
name
Many Block -> ParserT Text ParserState m (Many Block)
forall (m :: * -> *) a. Monad m => a -> m a
return (Many Block -> ParserT Text ParserState m (Many Block))
-> Many Block -> ParserT Text ParserState m (Many Block)
forall a b. (a -> b) -> a -> b
$ Attr -> Int -> Inlines -> Many Block
B.headerWith Attr
attr' Int
level Inlines
name
blockQuote :: PandocMonad m => ParserT Text ParserState m Blocks
blockQuote :: ParserT Text ParserState m (Many Block)
blockQuote = ParserT Text ParserState m (Many Block)
-> ParserT Text ParserState m (Many Block)
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try (ParserT Text ParserState m (Many Block)
-> ParserT Text ParserState m (Many Block))
-> ParserT Text ParserState m (Many Block)
-> ParserT Text ParserState m (Many Block)
forall a b. (a -> b) -> a -> b
$ do
[Char] -> ParsecT Text ParserState m [Char]
forall s (m :: * -> *) u.
Stream s m Char =>
[Char] -> ParsecT s u m [Char]
string [Char]
"bq" ParsecT Text ParserState m [Char]
-> ParsecT Text ParserState m Attr
-> ParsecT Text ParserState m Attr
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> ParsecT Text ParserState m Attr
forall (m :: * -> *).
PandocMonad m =>
ParserT Text ParserState m Attr
attributes ParsecT Text ParserState m Attr
-> ParsecT Text ParserState m Char
-> ParsecT Text ParserState m Char
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> Char -> ParsecT Text ParserState m Char
forall s (m :: * -> *) u.
Stream s m Char =>
Char -> ParsecT s u m Char
char Char
'.' ParsecT Text ParserState m Char
-> ParsecT Text ParserState m Inlines
-> ParsecT Text ParserState m Inlines
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> ParsecT Text ParserState m Inlines
forall (m :: * -> *) st. PandocMonad m => ParserT Text st m Inlines
whitespace
Many Block -> Many Block
B.blockQuote (Many Block -> Many Block)
-> ParserT Text ParserState m (Many Block)
-> ParserT Text ParserState m (Many Block)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ParserT Text ParserState m (Many Block)
forall (m :: * -> *).
PandocMonad m =>
ParserT Text ParserState m (Many Block)
para
hrule :: PandocMonad m => ParserT Text st m Blocks
hrule :: ParserT Text st m (Many Block)
hrule = ParserT Text st m (Many Block) -> ParserT Text st m (Many Block)
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try (ParserT Text st m (Many Block) -> ParserT Text st m (Many Block))
-> ParserT Text st m (Many Block) -> ParserT Text st m (Many Block)
forall a b. (a -> b) -> a -> b
$ do
ParserT Text st m ()
forall s (m :: * -> *) st. Stream s m Char => ParserT s st m ()
skipSpaces
Char
start <- [Char] -> ParsecT Text st m Char
forall s (m :: * -> *) u.
Stream s m Char =>
[Char] -> ParsecT s u m Char
oneOf [Char]
"-*"
Int -> ParsecT Text st m Char -> ParsecT Text st m [Char]
forall s (m :: * -> *) t u a.
Stream s m t =>
Int -> ParsecT s u m a -> ParsecT s u m [a]
count Int
2 (ParserT Text st m ()
forall s (m :: * -> *) st. Stream s m Char => ParserT s st m ()
skipSpaces ParserT Text st m ()
-> ParsecT Text st m Char -> ParsecT Text st m Char
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> Char -> ParsecT Text st m Char
forall s (m :: * -> *) u.
Stream s m Char =>
Char -> ParsecT s u m Char
char Char
start)
ParsecT Text st m Char -> ParserT Text st m ()
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m ()
skipMany (ParsecT Text st m Char
forall s (m :: * -> *) st. Stream s m Char => ParserT s st m Char
spaceChar ParsecT Text st m Char
-> ParsecT Text st m Char -> ParsecT Text st m Char
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> Char -> ParsecT Text st m Char
forall s (m :: * -> *) u.
Stream s m Char =>
Char -> ParsecT s u m Char
char Char
start)
ParsecT Text st m Char
forall s (m :: * -> *) st. Stream s m Char => ParserT s st m Char
newline
ParsecT Text st m Text -> ParserT Text st m ()
forall s (m :: * -> *) t u a.
Stream s m t =>
ParsecT s u m a -> ParsecT s u m ()
optional ParsecT Text st m Text
forall s (m :: * -> *) st. Stream s m Char => ParserT s st m Text
blanklines
Many Block -> ParserT Text st m (Many Block)
forall (m :: * -> *) a. Monad m => a -> m a
return Many Block
B.horizontalRule
anyList :: PandocMonad m => ParserT Text ParserState m Blocks
anyList :: ParserT Text ParserState m (Many Block)
anyList = ParserT Text ParserState m (Many Block)
-> ParserT Text ParserState m (Many Block)
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try (ParserT Text ParserState m (Many Block)
-> ParserT Text ParserState m (Many Block))
-> ParserT Text ParserState m (Many Block)
-> ParserT Text ParserState m (Many Block)
forall a b. (a -> b) -> a -> b
$ Int -> ParserT Text ParserState m (Many Block)
forall (m :: * -> *).
PandocMonad m =>
Int -> ParserT Text ParserState m (Many Block)
anyListAtDepth Int
1 ParserT Text ParserState m (Many Block)
-> ParsecT Text ParserState m Text
-> ParserT Text ParserState m (Many Block)
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
<* ParsecT Text ParserState m Text
forall s (m :: * -> *) st. Stream s m Char => ParserT s st m Text
blanklines
anyListAtDepth :: PandocMonad m => Int -> ParserT Text ParserState m Blocks
anyListAtDepth :: Int -> ParserT Text ParserState m (Many Block)
anyListAtDepth Int
depth = [ParserT Text ParserState m (Many Block)]
-> ParserT Text ParserState m (Many Block)
forall s (m :: * -> *) t u a.
Stream s m t =>
[ParsecT s u m a] -> ParsecT s u m a
choice [ Int -> ParserT Text ParserState m (Many Block)
forall (m :: * -> *).
PandocMonad m =>
Int -> ParserT Text ParserState m (Many Block)
bulletListAtDepth Int
depth,
Int -> ParserT Text ParserState m (Many Block)
forall (m :: * -> *).
PandocMonad m =>
Int -> ParserT Text ParserState m (Many Block)
orderedListAtDepth Int
depth,
ParserT Text ParserState m (Many Block)
forall (m :: * -> *).
PandocMonad m =>
ParserT Text ParserState m (Many Block)
definitionList ]
bulletListAtDepth :: PandocMonad m => Int -> ParserT Text ParserState m Blocks
bulletListAtDepth :: Int -> ParserT Text ParserState m (Many Block)
bulletListAtDepth Int
depth = ParserT Text ParserState m (Many Block)
-> ParserT Text ParserState m (Many Block)
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try (ParserT Text ParserState m (Many Block)
-> ParserT Text ParserState m (Many Block))
-> ParserT Text ParserState m (Many Block)
-> ParserT Text ParserState m (Many Block)
forall a b. (a -> b) -> a -> b
$ [Many Block] -> Many Block
B.bulletList ([Many Block] -> Many Block)
-> ParsecT Text ParserState m [Many Block]
-> ParserT Text ParserState m (Many Block)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ParserT Text ParserState m (Many Block)
-> ParsecT Text ParserState m [Many Block]
forall s (m :: * -> *) t u a.
Stream s m t =>
ParsecT s u m a -> ParsecT s u m [a]
many1 (Int -> ParserT Text ParserState m (Many Block)
forall (m :: * -> *).
PandocMonad m =>
Int -> ParserT Text ParserState m (Many Block)
bulletListItemAtDepth Int
depth)
bulletListItemAtDepth :: PandocMonad m => Int -> ParserT Text ParserState m Blocks
bulletListItemAtDepth :: Int -> ParserT Text ParserState m (Many Block)
bulletListItemAtDepth = Char -> Int -> ParserT Text ParserState m (Many Block)
forall (m :: * -> *).
PandocMonad m =>
Char -> Int -> ParserT Text ParserState m (Many Block)
genericListItemAtDepth Char
'*'
orderedListAtDepth :: PandocMonad m => Int -> ParserT Text ParserState m Blocks
orderedListAtDepth :: Int -> ParserT Text ParserState m (Many Block)
orderedListAtDepth Int
depth = ParserT Text ParserState m (Many Block)
-> ParserT Text ParserState m (Many Block)
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try (ParserT Text ParserState m (Many Block)
-> ParserT Text ParserState m (Many Block))
-> ParserT Text ParserState m (Many Block)
-> ParserT Text ParserState m (Many Block)
forall a b. (a -> b) -> a -> b
$ do
[Many Block]
items <- ParserT Text ParserState m (Many Block)
-> ParsecT Text ParserState m [Many Block]
forall s (m :: * -> *) t u a.
Stream s m t =>
ParsecT s u m a -> ParsecT s u m [a]
many1 (Int -> ParserT Text ParserState m (Many Block)
forall (m :: * -> *).
PandocMonad m =>
Int -> ParserT Text ParserState m (Many Block)
orderedListItemAtDepth Int
depth)
Many Block -> ParserT Text ParserState m (Many Block)
forall (m :: * -> *) a. Monad m => a -> m a
return (Many Block -> ParserT Text ParserState m (Many Block))
-> Many Block -> ParserT Text ParserState m (Many Block)
forall a b. (a -> b) -> a -> b
$ [Many Block] -> Many Block
B.orderedList [Many Block]
items
orderedListItemAtDepth :: PandocMonad m => Int -> ParserT Text ParserState m Blocks
orderedListItemAtDepth :: Int -> ParserT Text ParserState m (Many Block)
orderedListItemAtDepth = Char -> Int -> ParserT Text ParserState m (Many Block)
forall (m :: * -> *).
PandocMonad m =>
Char -> Int -> ParserT Text ParserState m (Many Block)
genericListItemAtDepth Char
'#'
genericListItemAtDepth :: PandocMonad m => Char -> Int -> ParserT Text ParserState m Blocks
genericListItemAtDepth :: Char -> Int -> ParserT Text ParserState m (Many Block)
genericListItemAtDepth Char
c Int
depth = ParserT Text ParserState m (Many Block)
-> ParserT Text ParserState m (Many Block)
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try (ParserT Text ParserState m (Many Block)
-> ParserT Text ParserState m (Many Block))
-> ParserT Text ParserState m (Many Block)
-> ParserT Text ParserState m (Many Block)
forall a b. (a -> b) -> a -> b
$ do
Int
-> ParsecT Text ParserState m Char
-> ParsecT Text ParserState m [Char]
forall s (m :: * -> *) t u a.
Stream s m t =>
Int -> ParsecT s u m a -> ParsecT s u m [a]
count Int
depth (Char -> ParsecT Text ParserState m Char
forall s (m :: * -> *) u.
Stream s m Char =>
Char -> ParsecT s u m Char
char Char
c) ParsecT Text ParserState m [Char]
-> ParsecT Text ParserState m Attr
-> ParsecT Text ParserState m Attr
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> ParsecT Text ParserState m Attr
forall (m :: * -> *).
PandocMonad m =>
ParserT Text ParserState m Attr
attributes ParsecT Text ParserState m Attr
-> ParsecT Text ParserState m Inlines
-> ParsecT Text ParserState m Inlines
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> ParsecT Text ParserState m Inlines
forall (m :: * -> *) st. PandocMonad m => ParserT Text st m Inlines
whitespace
Many Block
contents <- [Many Block] -> Many Block
forall a. Monoid a => [a] -> a
mconcat ([Many Block] -> Many Block)
-> ParsecT Text ParserState m [Many Block]
-> ParserT Text ParserState m (Many Block)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ParserT Text ParserState m (Many Block)
-> ParsecT Text ParserState m [Many Block]
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m [a]
many ((Inlines -> Many Block
B.plain (Inlines -> Many Block)
-> ([Inlines] -> Inlines) -> [Inlines] -> Many Block
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [Inlines] -> Inlines
forall a. Monoid a => [a] -> a
mconcat ([Inlines] -> Many Block)
-> ParsecT Text ParserState m [Inlines]
-> ParserT Text ParserState m (Many Block)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ParsecT Text ParserState m Inlines
-> ParsecT Text ParserState m [Inlines]
forall s (m :: * -> *) t u a.
Stream s m t =>
ParsecT s u m a -> ParsecT s u m [a]
many1 ParsecT Text ParserState m Inlines
forall (m :: * -> *).
PandocMonad m =>
ParserT Text ParserState m Inlines
inline) ParserT Text ParserState m (Many Block)
-> ParserT Text ParserState m (Many Block)
-> ParserT Text ParserState m (Many Block)
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|>
ParserT Text ParserState m (Many Block)
-> ParserT Text ParserState m (Many Block)
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try (ParsecT Text ParserState m Char
forall s (m :: * -> *) st. Stream s m Char => ParserT s st m Char
newline ParsecT Text ParserState m Char
-> ParserT Text ParserState m (Many Block)
-> ParserT Text ParserState m (Many Block)
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> ParserT Text ParserState m (Many Block)
forall (m :: * -> *).
PandocMonad m =>
ParserT Text ParserState m (Many Block)
codeBlockHtml))
ParsecT Text ParserState m Char
forall s (m :: * -> *) st. Stream s m Char => ParserT s st m Char
newline
Many Block
sublist <- Many Block
-> ParserT Text ParserState m (Many Block)
-> ParserT Text ParserState 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 (Int -> ParserT Text ParserState m (Many Block)
forall (m :: * -> *).
PandocMonad m =>
Int -> ParserT Text ParserState m (Many Block)
anyListAtDepth (Int
depth Int -> Int -> Int
forall a. Num a => a -> a -> a
+ Int
1))
Many Block -> ParserT Text ParserState m (Many Block)
forall (m :: * -> *) a. Monad m => a -> m a
return (Many Block -> ParserT Text ParserState m (Many Block))
-> Many Block -> ParserT Text ParserState m (Many Block)
forall a b. (a -> b) -> a -> b
$ Many Block
contents Many Block -> Many Block -> Many Block
forall a. Semigroup a => a -> a -> a
<> Many Block
sublist
definitionList :: PandocMonad m => ParserT Text ParserState m Blocks
definitionList :: ParserT Text ParserState m (Many Block)
definitionList = ParserT Text ParserState m (Many Block)
-> ParserT Text ParserState m (Many Block)
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try (ParserT Text ParserState m (Many Block)
-> ParserT Text ParserState m (Many Block))
-> ParserT Text ParserState m (Many Block)
-> ParserT Text ParserState m (Many Block)
forall a b. (a -> b) -> a -> b
$ [(Inlines, [Many Block])] -> Many Block
B.definitionList ([(Inlines, [Many Block])] -> Many Block)
-> ParsecT Text ParserState m [(Inlines, [Many Block])]
-> ParserT Text ParserState m (Many Block)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ParsecT Text ParserState m (Inlines, [Many Block])
-> ParsecT Text ParserState m [(Inlines, [Many Block])]
forall s (m :: * -> *) t u a.
Stream s m t =>
ParsecT s u m a -> ParsecT s u m [a]
many1 ParsecT Text ParserState m (Inlines, [Many Block])
forall (m :: * -> *).
PandocMonad m =>
ParserT Text ParserState m (Inlines, [Many Block])
definitionListItem
listStart :: PandocMonad m => ParserT Text ParserState m ()
listStart :: ParserT Text ParserState m ()
listStart = Char -> ParserT Text ParserState m ()
forall (m :: * -> *) st.
PandocMonad m =>
Char -> ParserT Text st m ()
genericListStart Char
'*'
ParserT Text ParserState m ()
-> ParserT Text ParserState m () -> ParserT Text ParserState m ()
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> () ()
-> ParserT Text ParserState m () -> ParserT Text ParserState m ()
forall (f :: * -> *) a b. Functor f => a -> f b -> f a
<$ Char -> ParserT Text ParserState m ()
forall (m :: * -> *) st.
PandocMonad m =>
Char -> ParserT Text st m ()
genericListStart Char
'#'
ParserT Text ParserState m ()
-> ParserT Text ParserState m () -> ParserT Text ParserState m ()
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> () ()
-> ParsecT Text ParserState m Inlines
-> ParserT Text ParserState m ()
forall (f :: * -> *) a b. Functor f => a -> f b -> f a
<$ ParsecT Text ParserState m Inlines
forall (m :: * -> *).
PandocMonad m =>
ParserT Text ParserState m Inlines
definitionListStart
genericListStart :: PandocMonad m => Char -> ParserT Text st m ()
genericListStart :: Char -> ParserT Text st m ()
genericListStart Char
c = () () -> ParsecT Text st m Inlines -> ParserT Text st m ()
forall (f :: * -> *) a b. Functor f => a -> f b -> f a
<$ ParsecT Text st m Inlines -> ParsecT Text st m Inlines
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try (ParsecT Text st m Char -> ParsecT Text st m [Char]
forall s (m :: * -> *) t u a.
Stream s m t =>
ParsecT s u m a -> ParsecT s u m [a]
many1 (Char -> ParsecT Text st m Char
forall s (m :: * -> *) u.
Stream s m Char =>
Char -> ParsecT s u m Char
char Char
c) ParsecT Text st m [Char]
-> ParsecT Text st m Inlines -> ParsecT Text st m Inlines
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> ParsecT Text st m Inlines
forall (m :: * -> *) st. PandocMonad m => ParserT Text st m Inlines
whitespace)
basicDLStart :: PandocMonad m => ParserT Text ParserState m ()
basicDLStart :: ParserT Text ParserState m ()
basicDLStart = do
Char -> ParsecT Text ParserState m Char
forall s (m :: * -> *) u.
Stream s m Char =>
Char -> ParsecT s u m Char
char Char
'-'
ParserT Text ParserState m Inlines
forall (m :: * -> *) st. PandocMonad m => ParserT Text st m Inlines
whitespace
ParsecT Text ParserState m Char -> ParserT Text ParserState m ()
forall s (m :: * -> *) t a u.
(Stream s m t, Show a) =>
ParsecT s u m a -> ParsecT s u m ()
notFollowedBy ParsecT Text ParserState m Char
forall s (m :: * -> *) st. Stream s m Char => ParserT s st m Char
newline
definitionListStart :: PandocMonad m => ParserT Text ParserState m Inlines
definitionListStart :: ParserT Text ParserState m Inlines
definitionListStart = ParserT Text ParserState m Inlines
-> ParserT Text ParserState m Inlines
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try (ParserT Text ParserState m Inlines
-> ParserT Text ParserState m Inlines)
-> ParserT Text ParserState m Inlines
-> ParserT Text ParserState m Inlines
forall a b. (a -> b) -> a -> b
$ do
ParserT Text ParserState m ()
forall (m :: * -> *).
PandocMonad m =>
ParserT Text ParserState m ()
basicDLStart
Inlines -> Inlines
trimInlines (Inlines -> Inlines)
-> ([Inlines] -> Inlines) -> [Inlines] -> Inlines
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [Inlines] -> Inlines
forall a. Monoid a => [a] -> a
mconcat ([Inlines] -> Inlines)
-> ParsecT Text ParserState m [Inlines]
-> ParserT Text ParserState m Inlines
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$>
ParserT Text ParserState m Inlines
-> ParserT Text ParserState m ()
-> ParsecT Text ParserState m [Inlines]
forall end s (m :: * -> *) t st a.
(Show end, Stream s m t) =>
ParserT s st m a -> ParserT s st m end -> ParserT s st m [a]
many1Till ParserT Text ParserState m Inlines
forall (m :: * -> *).
PandocMonad m =>
ParserT Text ParserState m Inlines
inline
( ParserT Text ParserState m () -> ParserT Text ParserState m ()
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try (ParsecT Text ParserState m Char
forall s (m :: * -> *) st. Stream s m Char => ParserT s st m Char
newline ParsecT Text ParserState m Char
-> ParserT Text ParserState m () -> ParserT Text ParserState m ()
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> ParserT Text ParserState m () -> ParserT Text ParserState m ()
forall s (m :: * -> *) t u a.
Stream s m t =>
ParsecT s u m a -> ParsecT s u m a
lookAhead ParserT Text ParserState m ()
forall (m :: * -> *).
PandocMonad m =>
ParserT Text ParserState m ()
basicDLStart)
ParserT Text ParserState m ()
-> ParserT Text ParserState m () -> ParserT Text ParserState m ()
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> ParserT Text ParserState m () -> ParserT Text ParserState m ()
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try (ParserT Text ParserState m () -> ParserT Text ParserState m ()
forall s (m :: * -> *) t u a.
Stream s m t =>
ParsecT s u m a -> ParsecT s u m a
lookAhead (() ()
-> ParsecT Text ParserState m [Char]
-> ParserT Text ParserState m ()
forall (f :: * -> *) a b. Functor f => a -> f b -> f a
<$ [Char] -> ParsecT Text ParserState m [Char]
forall s (m :: * -> *) u.
Stream s m Char =>
[Char] -> ParsecT s u m [Char]
string [Char]
":="))
)
definitionListItem :: PandocMonad m => ParserT Text ParserState m (Inlines, [Blocks])
definitionListItem :: ParserT Text ParserState m (Inlines, [Many Block])
definitionListItem = ParserT Text ParserState m (Inlines, [Many Block])
-> ParserT Text ParserState m (Inlines, [Many Block])
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try (ParserT Text ParserState m (Inlines, [Many Block])
-> ParserT Text ParserState m (Inlines, [Many Block]))
-> ParserT Text ParserState m (Inlines, [Many Block])
-> ParserT Text ParserState m (Inlines, [Many Block])
forall a b. (a -> b) -> a -> b
$ do
Inlines
term <- [Inlines] -> Inlines
forall a. Monoid a => [a] -> a
mconcat ([Inlines] -> Inlines)
-> ([Inlines] -> [Inlines]) -> [Inlines] -> Inlines
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Inlines -> [Inlines] -> [Inlines]
forall a. a -> [a] -> [a]
intersperse Inlines
B.linebreak ([Inlines] -> Inlines)
-> ParsecT Text ParserState m [Inlines]
-> ParsecT Text ParserState m Inlines
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ParsecT Text ParserState m Inlines
-> ParsecT Text ParserState m [Inlines]
forall s (m :: * -> *) t u a.
Stream s m t =>
ParsecT s u m a -> ParsecT s u m [a]
many1 ParsecT Text ParserState m Inlines
forall (m :: * -> *).
PandocMonad m =>
ParserT Text ParserState m Inlines
definitionListStart
[Many Block]
def' <- [Char] -> ParsecT Text ParserState m [Char]
forall s (m :: * -> *) u.
Stream s m Char =>
[Char] -> ParsecT s u m [Char]
string [Char]
":=" ParsecT Text ParserState m [Char]
-> ParsecT Text ParserState m () -> ParsecT Text ParserState m ()
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> ParsecT Text ParserState m Inlines -> ParsecT Text ParserState m ()
forall s (m :: * -> *) t u a.
Stream s m t =>
ParsecT s u m a -> ParsecT s u m ()
optional ParsecT Text ParserState m Inlines
forall (m :: * -> *) st. PandocMonad m => ParserT Text st m Inlines
whitespace ParsecT Text ParserState m ()
-> ParsecT Text ParserState m [Many Block]
-> ParsecT Text ParserState m [Many Block]
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> (ParsecT Text ParserState m [Many Block]
forall (m :: * -> *).
PandocMonad m =>
ParserT Text ParserState m [Many Block]
multilineDef ParsecT Text ParserState m [Many Block]
-> ParsecT Text ParserState m [Many Block]
-> ParsecT Text ParserState m [Many Block]
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> ParsecT Text ParserState m [Many Block]
forall (m :: * -> *).
PandocMonad m =>
ParserT Text ParserState m [Many Block]
inlineDef)
(Inlines, [Many Block])
-> ParserT Text ParserState m (Inlines, [Many Block])
forall (m :: * -> *) a. Monad m => a -> m a
return (Inlines
term, [Many Block]
def')
where inlineDef :: PandocMonad m => ParserT Text ParserState m [Blocks]
inlineDef :: ParserT Text ParserState m [Many Block]
inlineDef = (Inlines -> [Many Block])
-> ParsecT Text ParserState m Inlines
-> ParserT Text ParserState m [Many Block]
forall (m :: * -> *) a1 r. Monad m => (a1 -> r) -> m a1 -> m r
liftM (\Inlines
d -> [Inlines -> Many Block
B.plain Inlines
d])
(ParsecT Text ParserState m Inlines
-> ParserT Text ParserState m [Many Block])
-> ParsecT Text ParserState m Inlines
-> ParserT Text ParserState m [Many Block]
forall a b. (a -> b) -> a -> b
$ ParsecT Text ParserState m Inlines -> ParsecT Text ParserState m ()
forall s (m :: * -> *) t u a.
Stream s m t =>
ParsecT s u m a -> ParsecT s u m ()
optional ParsecT Text ParserState m Inlines
forall (m :: * -> *) st. PandocMonad m => ParserT Text st m Inlines
whitespace ParsecT Text ParserState m ()
-> ParsecT Text ParserState m Inlines
-> ParsecT Text ParserState m Inlines
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> (Inlines -> Inlines
trimInlines (Inlines -> Inlines)
-> ([Inlines] -> Inlines) -> [Inlines] -> Inlines
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [Inlines] -> Inlines
forall a. Monoid a => [a] -> a
mconcat ([Inlines] -> Inlines)
-> ParsecT Text ParserState m [Inlines]
-> ParsecT Text ParserState m Inlines
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ParsecT Text ParserState m Inlines
-> ParsecT Text ParserState m [Inlines]
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m [a]
many ParsecT Text ParserState m Inlines
forall (m :: * -> *).
PandocMonad m =>
ParserT Text ParserState m Inlines
inline) ParsecT Text ParserState m Inlines
-> ParsecT Text ParserState m Char
-> ParsecT Text ParserState m Inlines
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
<* ParsecT Text ParserState m Char
forall s (m :: * -> *) st. Stream s m Char => ParserT s st m Char
newline
multilineDef :: PandocMonad m => ParserT Text ParserState m [Blocks]
multilineDef :: ParserT Text ParserState m [Many Block]
multilineDef = ParserT Text ParserState m [Many Block]
-> ParserT Text ParserState m [Many Block]
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try (ParserT Text ParserState m [Many Block]
-> ParserT Text ParserState m [Many Block])
-> ParserT Text ParserState m [Many Block]
-> ParserT Text ParserState m [Many Block]
forall a b. (a -> b) -> a -> b
$ do
ParsecT Text ParserState m Inlines -> ParsecT Text ParserState m ()
forall s (m :: * -> *) t u a.
Stream s m t =>
ParsecT s u m a -> ParsecT s u m ()
optional ParsecT Text ParserState m Inlines
forall (m :: * -> *) st. PandocMonad m => ParserT Text st m Inlines
whitespace ParsecT Text ParserState m ()
-> ParsecT Text ParserState m Char
-> ParsecT Text ParserState m Char
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> ParsecT Text ParserState m Char
forall s (m :: * -> *) st. Stream s m Char => ParserT s st m Char
newline
Text
s <- [Char] -> Text
T.pack ([Char] -> Text)
-> ParsecT Text ParserState m [Char]
-> ParsecT Text ParserState m Text
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ParsecT Text ParserState m Char
-> ParsecT Text ParserState m Char
-> ParsecT Text ParserState m [Char]
forall end s (m :: * -> *) t st a.
(Show end, Stream s m t) =>
ParserT s st m a -> ParserT s st m end -> ParserT s st m [a]
many1Till ParsecT Text ParserState m Char
forall s (m :: * -> *) st. Stream s m Char => ParserT s st m Char
anyChar (ParsecT Text ParserState m Char -> ParsecT Text ParserState m Char
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try ([Char] -> ParsecT Text ParserState m [Char]
forall s (m :: * -> *) u.
Stream s m Char =>
[Char] -> ParsecT s u m [Char]
string [Char]
"=:" ParsecT Text ParserState m [Char]
-> ParsecT Text ParserState m Char
-> ParsecT Text ParserState m Char
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> ParsecT Text ParserState m Char
forall s (m :: * -> *) st. Stream s m Char => ParserT s st m Char
newline))
Many Block
ds <- ParserT Text ParserState m (Many Block)
-> Text -> ParserT Text ParserState m (Many Block)
forall s (m :: * -> *) u a.
(Stream s m Char, IsString s, HasLastStrPosition u) =>
ParserT s u m a -> Text -> ParserT s u m a
parseFromString' ParserT Text ParserState m (Many Block)
forall (m :: * -> *).
PandocMonad m =>
ParserT Text ParserState m (Many Block)
parseBlocks (Text
s Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
"\n\n")
[Many Block] -> ParserT Text ParserState m [Many Block]
forall (m :: * -> *) a. Monad m => a -> m a
return [Many Block
ds]
rawHtmlBlock :: PandocMonad m => ParserT Text ParserState m Blocks
rawHtmlBlock :: ParserT Text ParserState m (Many Block)
rawHtmlBlock = ParserT Text ParserState m (Many Block)
-> ParserT Text ParserState m (Many Block)
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try (ParserT Text ParserState m (Many Block)
-> ParserT Text ParserState m (Many Block))
-> ParserT Text ParserState m (Many Block)
-> ParserT Text ParserState m (Many Block)
forall a b. (a -> b) -> a -> b
$ do
ParsecT Text ParserState m Char -> ParsecT Text ParserState m ()
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m ()
skipMany ParsecT Text ParserState m Char
forall s (m :: * -> *) st. Stream s m Char => ParserT s st m Char
spaceChar
(Tag Text
_,Text
b) <- (Tag Text -> Bool) -> ParserT Text ParserState m (Tag Text, Text)
forall st (m :: * -> *).
(HasReaderOptions st, Monad m) =>
(Tag Text -> Bool) -> ParserT Text st m (Tag Text, Text)
htmlTag Tag Text -> Bool
isBlockTag
ParsecT Text ParserState m Text -> ParsecT Text ParserState m ()
forall s (m :: * -> *) t u a.
Stream s m t =>
ParsecT s u m a -> ParsecT s u m ()
optional ParsecT Text ParserState m Text
forall s (m :: * -> *) st. Stream s m Char => ParserT s st m Text
blanklines
Many Block -> ParserT Text ParserState m (Many Block)
forall (m :: * -> *) a. Monad m => a -> m a
return (Many Block -> ParserT Text ParserState m (Many Block))
-> Many Block -> ParserT Text ParserState m (Many Block)
forall a b. (a -> b) -> a -> b
$ Text -> Text -> Many Block
B.rawBlock Text
"html" Text
b
rawLaTeXBlock' :: PandocMonad m => ParserT Text ParserState m Blocks
rawLaTeXBlock' :: ParserT Text ParserState m (Many Block)
rawLaTeXBlock' = do
Extension -> ParserT Text ParserState m ()
forall s (m :: * -> *) a st.
(Stream s m a, HasReaderOptions st) =>
Extension -> ParserT s st m ()
guardEnabled Extension
Ext_raw_tex
Text -> Text -> Many Block
B.rawBlock Text
"latex" (Text -> Many Block)
-> ParsecT Text ParserState m Text
-> ParserT Text ParserState m (Many Block)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (ParsecT Text ParserState m Text
forall (m :: * -> *) s.
(PandocMonad m, HasMacros s, HasReaderOptions s) =>
ParserT Text s m Text
rawLaTeXBlock ParsecT Text ParserState m Text
-> ParserT Text ParserState m () -> ParsecT Text ParserState m Text
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
<* ParserT Text ParserState m ()
forall s (m :: * -> *) st. Stream s m Char => ParserT s st m ()
spaces)
para :: PandocMonad m => ParserT Text ParserState m Blocks
para :: ParserT Text ParserState m (Many Block)
para = Inlines -> Many Block
B.para (Inlines -> Many Block)
-> ([Inlines] -> Inlines) -> [Inlines] -> Many Block
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Inlines -> Inlines
trimInlines (Inlines -> Inlines)
-> ([Inlines] -> Inlines) -> [Inlines] -> Inlines
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [Inlines] -> Inlines
forall a. Monoid a => [a] -> a
mconcat ([Inlines] -> Many Block)
-> ParsecT Text ParserState m [Inlines]
-> ParserT Text ParserState m (Many Block)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ParsecT Text ParserState m Inlines
-> ParsecT Text ParserState m [Inlines]
forall s (m :: * -> *) t u a.
Stream s m t =>
ParsecT s u m a -> ParsecT s u m [a]
many1 ParsecT Text ParserState m Inlines
forall (m :: * -> *).
PandocMonad m =>
ParserT Text ParserState m Inlines
inline
toAlignment :: Char -> Alignment
toAlignment :: Char -> Alignment
toAlignment Char
'<' = Alignment
AlignLeft
toAlignment Char
'>' = Alignment
AlignRight
toAlignment Char
'=' = Alignment
AlignCenter
toAlignment Char
_ = Alignment
AlignDefault
cellAttributes :: PandocMonad m => ParserT Text ParserState m (Bool, Alignment)
cellAttributes :: ParserT Text ParserState m (Bool, Alignment)
cellAttributes = ParserT Text ParserState m (Bool, Alignment)
-> ParserT Text ParserState m (Bool, Alignment)
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try (ParserT Text ParserState m (Bool, Alignment)
-> ParserT Text ParserState m (Bool, Alignment))
-> ParserT Text ParserState m (Bool, Alignment)
-> ParserT Text ParserState m (Bool, Alignment)
forall a b. (a -> b) -> a -> b
$ do
Bool
isHeader <- Bool
-> ParsecT Text ParserState m Bool
-> ParsecT Text ParserState m Bool
forall s (m :: * -> *) t a u.
Stream s m t =>
a -> ParsecT s u m a -> ParsecT s u m a
option Bool
False (Bool
True Bool
-> ParsecT Text ParserState m Char
-> ParsecT Text ParserState m Bool
forall (f :: * -> *) a b. Functor f => a -> f b -> f a
<$ Char -> ParsecT Text ParserState m Char
forall s (m :: * -> *) u.
Stream s m Char =>
Char -> ParsecT s u m Char
char Char
'_')
ParsecT Text ParserState m [Char] -> ParsecT Text ParserState m ()
forall s (m :: * -> *) t u a.
Stream s m t =>
ParsecT s u m a -> ParsecT s u m ()
optional (ParsecT Text ParserState m [Char]
-> ParsecT Text ParserState m ())
-> ParsecT Text ParserState m [Char]
-> ParsecT Text ParserState m ()
forall a b. (a -> b) -> a -> b
$ ParsecT Text ParserState m [Char]
-> ParsecT Text ParserState m [Char]
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try (ParsecT Text ParserState m [Char]
-> ParsecT Text ParserState m [Char])
-> ParsecT Text ParserState m [Char]
-> ParsecT Text ParserState m [Char]
forall a b. (a -> b) -> a -> b
$ [Char] -> ParsecT Text ParserState m Char
forall s (m :: * -> *) u.
Stream s m Char =>
[Char] -> ParsecT s u m Char
oneOf [Char]
"/\\" ParsecT Text ParserState m Char
-> ParsecT Text ParserState m [Char]
-> ParsecT Text ParserState m [Char]
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> ParsecT Text ParserState m Char
-> ParsecT Text ParserState m [Char]
forall s (m :: * -> *) t u a.
Stream s m t =>
ParsecT s u m a -> ParsecT s u m [a]
many1 ParsecT Text ParserState m Char
forall s (m :: * -> *) st. Stream s m Char => ParserT s st m Char
digit
Alignment
alignment <- Alignment
-> ParsecT Text ParserState m Alignment
-> ParsecT Text ParserState m Alignment
forall s (m :: * -> *) t a u.
Stream s m t =>
a -> ParsecT s u m a -> ParsecT s u m a
option Alignment
AlignDefault (ParsecT Text ParserState m Alignment
-> ParsecT Text ParserState m Alignment)
-> ParsecT Text ParserState m Alignment
-> ParsecT Text ParserState m Alignment
forall a b. (a -> b) -> a -> b
$ Char -> Alignment
toAlignment (Char -> Alignment)
-> ParsecT Text ParserState m Char
-> ParsecT Text ParserState m Alignment
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> [Char] -> ParsecT Text ParserState m Char
forall s (m :: * -> *) u.
Stream s m Char =>
[Char] -> ParsecT s u m Char
oneOf [Char]
"<>="
Attr
_ <- ParserT Text ParserState m Attr
forall (m :: * -> *).
PandocMonad m =>
ParserT Text ParserState m Attr
attributes
Char -> ParsecT Text ParserState m Char
forall s (m :: * -> *) u.
Stream s m Char =>
Char -> ParsecT s u m Char
char Char
'.'
(Bool, Alignment) -> ParserT Text ParserState m (Bool, Alignment)
forall (m :: * -> *) a. Monad m => a -> m a
return (Bool
isHeader, Alignment
alignment)
tableCell :: PandocMonad m => ParserT Text ParserState m ((Bool, Alignment), Blocks)
tableCell :: ParserT Text ParserState m ((Bool, Alignment), Many Block)
tableCell = ParserT Text ParserState m ((Bool, Alignment), Many Block)
-> ParserT Text ParserState m ((Bool, Alignment), Many Block)
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try (ParserT Text ParserState m ((Bool, Alignment), Many Block)
-> ParserT Text ParserState m ((Bool, Alignment), Many Block))
-> ParserT Text ParserState m ((Bool, Alignment), Many Block)
-> ParserT Text ParserState m ((Bool, Alignment), Many Block)
forall a b. (a -> b) -> a -> b
$ do
Char -> ParsecT Text ParserState m Char
forall s (m :: * -> *) u.
Stream s m Char =>
Char -> ParsecT s u m Char
char Char
'|'
(Bool
isHeader, Alignment
alignment) <- (Bool, Alignment)
-> ParsecT Text ParserState m (Bool, Alignment)
-> ParsecT Text ParserState m (Bool, Alignment)
forall s (m :: * -> *) t a u.
Stream s m t =>
a -> ParsecT s u m a -> ParsecT s u m a
option (Bool
False, Alignment
AlignDefault) ParsecT Text ParserState m (Bool, Alignment)
forall (m :: * -> *).
PandocMonad m =>
ParserT Text ParserState m (Bool, Alignment)
cellAttributes
ParsecT Text ParserState m Char -> ParsecT Text ParserState m ()
forall s (m :: * -> *) t a u.
(Stream s m t, Show a) =>
ParsecT s u m a -> ParsecT s u m ()
notFollowedBy ParsecT Text ParserState m Char
forall s (m :: * -> *) st. Stream s m Char => ParserT s st m Char
blankline
Text
raw <- Text -> Text
trim (Text -> Text) -> ([Char] -> Text) -> [Char] -> Text
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [Char] -> Text
T.pack ([Char] -> Text)
-> ParsecT Text ParserState m [Char]
-> ParsecT Text ParserState m Text
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$>
ParsecT Text ParserState m Char
-> ParsecT Text ParserState m [Char]
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m [a]
many ([Char] -> ParsecT Text ParserState m Char
forall s (m :: * -> *) u.
Stream s m Char =>
[Char] -> ParsecT s u m Char
noneOf [Char]
"|\n" ParsecT Text ParserState m Char
-> ParsecT Text ParserState m Char
-> ParsecT Text ParserState m Char
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> ParsecT Text ParserState m Char -> ParsecT Text ParserState m Char
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try (Char -> ParsecT Text ParserState m Char
forall s (m :: * -> *) u.
Stream s m Char =>
Char -> ParsecT s u m Char
char Char
'\n' ParsecT Text ParserState m Char
-> ParsecT Text ParserState m () -> ParsecT Text ParserState m Char
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
<* ParsecT Text ParserState m Char -> ParsecT Text ParserState m ()
forall s (m :: * -> *) t a u.
(Stream s m t, Show a) =>
ParsecT s u m a -> ParsecT s u m ()
notFollowedBy ParsecT Text ParserState m Char
forall s (m :: * -> *) st. Stream s m Char => ParserT s st m Char
blankline))
Inlines
content <- [Inlines] -> Inlines
forall a. Monoid a => [a] -> a
mconcat ([Inlines] -> Inlines)
-> ParsecT Text ParserState m [Inlines]
-> ParsecT Text ParserState m Inlines
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ParsecT Text ParserState m [Inlines]
-> Text -> ParsecT Text ParserState m [Inlines]
forall s (m :: * -> *) u a.
(Stream s m Char, IsString s, HasLastStrPosition u) =>
ParserT s u m a -> Text -> ParserT s u m a
parseFromString' (ParsecT Text ParserState m Inlines
-> ParsecT Text ParserState m [Inlines]
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m [a]
many ParsecT Text ParserState m Inlines
forall (m :: * -> *).
PandocMonad m =>
ParserT Text ParserState m Inlines
inline) Text
raw
((Bool, Alignment), Many Block)
-> ParserT Text ParserState m ((Bool, Alignment), Many Block)
forall (m :: * -> *) a. Monad m => a -> m a
return ((Bool
isHeader, Alignment
alignment), Inlines -> Many Block
B.plain Inlines
content)
tableRow :: PandocMonad m => ParserT Text ParserState m [((Bool, Alignment), Blocks)]
tableRow :: ParserT Text ParserState m [((Bool, Alignment), Many Block)]
tableRow = ParserT Text ParserState m [((Bool, Alignment), Many Block)]
-> ParserT Text ParserState m [((Bool, Alignment), Many Block)]
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try (ParserT Text ParserState m [((Bool, Alignment), Many Block)]
-> ParserT Text ParserState m [((Bool, Alignment), Many Block)])
-> ParserT Text ParserState m [((Bool, Alignment), Many Block)]
-> ParserT Text ParserState m [((Bool, Alignment), Many Block)]
forall a b. (a -> b) -> a -> b
$ do
ParsecT Text ParserState m [Char] -> ParsecT Text ParserState m ()
forall s (m :: * -> *) t u a.
Stream s m t =>
ParsecT s u m a -> ParsecT s u m ()
optional (ParsecT Text ParserState m [Char]
-> ParsecT Text ParserState m ())
-> ParsecT Text ParserState m [Char]
-> ParsecT Text ParserState m ()
forall a b. (a -> b) -> a -> b
$ ParsecT Text ParserState m [Char]
-> ParsecT Text ParserState m [Char]
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try (ParsecT Text ParserState m [Char]
-> ParsecT Text ParserState m [Char])
-> ParsecT Text ParserState m [Char]
-> ParsecT Text ParserState m [Char]
forall a b. (a -> b) -> a -> b
$ do
Attr
_ <- ParserT Text ParserState m Attr
forall (m :: * -> *).
PandocMonad m =>
ParserT Text ParserState m Attr
attributes
Char -> ParsecT Text ParserState m Char
forall s (m :: * -> *) u.
Stream s m Char =>
Char -> ParsecT s u m Char
char Char
'.'
ParsecT Text ParserState m Char
-> ParsecT Text ParserState m [Char]
forall s (m :: * -> *) t u a.
Stream s m t =>
ParsecT s u m a -> ParsecT s u m [a]
many1 ParsecT Text ParserState m Char
forall s (m :: * -> *) st. Stream s m Char => ParserT s st m Char
spaceChar
ParsecT Text ParserState m ((Bool, Alignment), Many Block)
-> ParserT Text ParserState m [((Bool, Alignment), Many Block)]
forall s (m :: * -> *) t u a.
Stream s m t =>
ParsecT s u m a -> ParsecT s u m [a]
many1 ParsecT Text ParserState m ((Bool, Alignment), Many Block)
forall (m :: * -> *).
PandocMonad m =>
ParserT Text ParserState m ((Bool, Alignment), Many Block)
tableCell ParserT Text ParserState m [((Bool, Alignment), Many Block)]
-> ParsecT Text ParserState m Char
-> ParserT Text ParserState m [((Bool, Alignment), Many Block)]
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
<* Char -> ParsecT Text ParserState m Char
forall s (m :: * -> *) u.
Stream s m Char =>
Char -> ParsecT s u m Char
char Char
'|' ParserT Text ParserState m [((Bool, Alignment), Many Block)]
-> ParsecT Text ParserState m Char
-> ParserT Text ParserState m [((Bool, Alignment), Many Block)]
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
<* ParsecT Text ParserState m Char
forall s (m :: * -> *) st. Stream s m Char => ParserT s st m Char
blankline
table :: PandocMonad m => ParserT Text ParserState m Blocks
table :: ParserT Text ParserState m (Many Block)
table = ParserT Text ParserState m (Many Block)
-> ParserT Text ParserState m (Many Block)
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try (ParserT Text ParserState m (Many Block)
-> ParserT Text ParserState m (Many Block))
-> ParserT Text ParserState m (Many Block)
-> ParserT Text ParserState m (Many Block)
forall a b. (a -> b) -> a -> b
$ do
Inlines
caption <- Inlines
-> ParsecT Text ParserState m Inlines
-> ParsecT Text ParserState m Inlines
forall s (m :: * -> *) t a u.
Stream s m t =>
a -> ParsecT s u m a -> ParsecT s u m a
option Inlines
forall a. Monoid a => a
mempty (ParsecT Text ParserState m Inlines
-> ParsecT Text ParserState m Inlines)
-> ParsecT Text ParserState m Inlines
-> ParsecT Text ParserState m Inlines
forall a b. (a -> b) -> a -> b
$ ParsecT Text ParserState m Inlines
-> ParsecT Text ParserState m Inlines
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try (ParsecT Text ParserState m Inlines
-> ParsecT Text ParserState m Inlines)
-> ParsecT Text ParserState m Inlines
-> ParsecT Text ParserState m Inlines
forall a b. (a -> b) -> a -> b
$ do
[Char] -> ParsecT Text ParserState m [Char]
forall s (m :: * -> *) u.
Stream s m Char =>
[Char] -> ParsecT s u m [Char]
string [Char]
"table"
Attr
_ <- ParserT Text ParserState m Attr
forall (m :: * -> *).
PandocMonad m =>
ParserT Text ParserState m Attr
attributes
Char -> ParsecT Text ParserState m Char
forall s (m :: * -> *) u.
Stream s m Char =>
Char -> ParsecT s u m Char
char Char
'.'
Text
rawcapt <- Text -> Text
trim (Text -> Text)
-> ParsecT Text ParserState m Text
-> ParsecT Text ParserState m Text
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ParsecT Text ParserState m Text
forall (m :: * -> *) st. Monad m => ParserT Text st m Text
anyLine
ParsecT Text ParserState m Inlines
-> Text -> ParsecT Text ParserState m Inlines
forall s (m :: * -> *) u a.
(Stream s m Char, IsString s, HasLastStrPosition u) =>
ParserT s u m a -> Text -> ParserT s u m a
parseFromString' ([Inlines] -> Inlines
forall a. Monoid a => [a] -> a
mconcat ([Inlines] -> Inlines)
-> ParsecT Text ParserState m [Inlines]
-> ParsecT Text ParserState m Inlines
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ParsecT Text ParserState m Inlines
-> ParsecT Text ParserState m [Inlines]
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m [a]
many ParsecT Text ParserState m Inlines
forall (m :: * -> *).
PandocMonad m =>
ParserT Text ParserState m Inlines
inline) Text
rawcapt
[[((Bool, Alignment), Many Block)]]
rawrows <- ParsecT Text ParserState m [((Bool, Alignment), Many Block)]
-> ParsecT Text ParserState m [[((Bool, Alignment), Many Block)]]
forall s (m :: * -> *) t u a.
Stream s m t =>
ParsecT s u m a -> ParsecT s u m [a]
many1 (ParsecT Text ParserState m [((Bool, Alignment), Many Block)]
-> ParsecT Text ParserState m [[((Bool, Alignment), Many Block)]])
-> ParsecT Text ParserState m [((Bool, Alignment), Many Block)]
-> ParsecT Text ParserState m [[((Bool, Alignment), Many Block)]]
forall a b. (a -> b) -> a -> b
$ ParsecT Text ParserState m () -> ParsecT Text ParserState m ()
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m ()
skipMany ParsecT Text ParserState m ()
forall (m :: * -> *).
PandocMonad m =>
ParserT Text ParserState m ()
ignorableRow ParsecT Text ParserState m ()
-> ParsecT Text ParserState m [((Bool, Alignment), Many Block)]
-> ParsecT Text ParserState m [((Bool, Alignment), Many Block)]
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> ParsecT Text ParserState m [((Bool, Alignment), Many Block)]
forall (m :: * -> *).
PandocMonad m =>
ParserT Text ParserState m [((Bool, Alignment), Many Block)]
tableRow
ParsecT Text ParserState m () -> ParsecT Text ParserState m ()
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m ()
skipMany ParsecT Text ParserState m ()
forall (m :: * -> *).
PandocMonad m =>
ParserT Text ParserState m ()
ignorableRow
ParsecT Text ParserState m Text
forall s (m :: * -> *) st. Stream s m Char => ParserT s st m Text
blanklines
let ([((Bool, Alignment), Many Block)]
headers, [[((Bool, Alignment), Many Block)]]
rows) = case [[((Bool, Alignment), Many Block)]]
rawrows of
([((Bool, Alignment), Many Block)]
toprow:[[((Bool, Alignment), Many Block)]]
rest) | (((Bool, Alignment), Many Block) -> Bool)
-> [((Bool, Alignment), Many Block)] -> Bool
forall (t :: * -> *) a. Foldable t => (a -> Bool) -> t a -> Bool
any ((Bool, Alignment) -> Bool
forall a b. (a, b) -> a
fst ((Bool, Alignment) -> Bool)
-> (((Bool, Alignment), Many Block) -> (Bool, Alignment))
-> ((Bool, Alignment), Many Block)
-> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ((Bool, Alignment), Many Block) -> (Bool, Alignment)
forall a b. (a, b) -> a
fst) [((Bool, Alignment), Many Block)]
toprow ->
([((Bool, Alignment), Many Block)]
toprow, [[((Bool, Alignment), Many Block)]]
rest)
[[((Bool, Alignment), Many Block)]]
_ -> ([((Bool, Alignment), Many Block)]
forall a. Monoid a => a
mempty, [[((Bool, Alignment), Many Block)]]
rawrows)
let nbOfCols :: Int
nbOfCols = [Int] -> Int
forall (t :: * -> *) a. (Foldable t, Ord a) => t a -> a
maximum ([Int] -> Int) -> [Int] -> Int
forall a b. (a -> b) -> a -> b
$ ([((Bool, Alignment), Many Block)] -> Int)
-> [[((Bool, Alignment), Many Block)]] -> [Int]
forall a b. (a -> b) -> [a] -> [b]
map [((Bool, Alignment), Many Block)] -> Int
forall (t :: * -> *) a. Foldable t => t a -> Int
length ([((Bool, Alignment), Many Block)]
headers[((Bool, Alignment), Many Block)]
-> [[((Bool, Alignment), Many Block)]]
-> [[((Bool, Alignment), Many Block)]]
forall a. a -> [a] -> [a]
:[[((Bool, Alignment), Many Block)]]
rows)
let aligns :: [Alignment]
aligns = ([Alignment] -> Alignment) -> [[Alignment]] -> [Alignment]
forall a b. (a -> b) -> [a] -> [b]
map [Alignment] -> Alignment
forall (t :: * -> *) a. (Foldable t, Ord a) => t a -> a
minimum ([[Alignment]] -> [Alignment]) -> [[Alignment]] -> [Alignment]
forall a b. (a -> b) -> a -> b
$ [[Alignment]] -> [[Alignment]]
forall a. [[a]] -> [[a]]
transpose ([[Alignment]] -> [[Alignment]]) -> [[Alignment]] -> [[Alignment]]
forall a b. (a -> b) -> a -> b
$ ([((Bool, Alignment), Many Block)] -> [Alignment])
-> [[((Bool, Alignment), Many Block)]] -> [[Alignment]]
forall a b. (a -> b) -> [a] -> [b]
map ((((Bool, Alignment), Many Block) -> Alignment)
-> [((Bool, Alignment), Many Block)] -> [Alignment]
forall a b. (a -> b) -> [a] -> [b]
map ((Bool, Alignment) -> Alignment
forall a b. (a, b) -> b
snd ((Bool, Alignment) -> Alignment)
-> (((Bool, Alignment), Many Block) -> (Bool, Alignment))
-> ((Bool, Alignment), Many Block)
-> Alignment
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ((Bool, Alignment), Many Block) -> (Bool, Alignment)
forall a b. (a, b) -> a
fst)) ([((Bool, Alignment), Many Block)]
headers[((Bool, Alignment), Many Block)]
-> [[((Bool, Alignment), Many Block)]]
-> [[((Bool, Alignment), Many Block)]]
forall a. a -> [a] -> [a]
:[[((Bool, Alignment), Many Block)]]
rows)
let toRow :: [Many Block] -> Row
toRow = Attr -> [Cell] -> Row
Row Attr
nullAttr ([Cell] -> Row) -> ([Many Block] -> [Cell]) -> [Many Block] -> Row
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Many Block -> Cell) -> [Many Block] -> [Cell]
forall a b. (a -> b) -> [a] -> [b]
map Many Block -> Cell
B.simpleCell
toHeaderRow :: [Many Block] -> [Row]
toHeaderRow [Many Block]
l = [[Many Block] -> Row
toRow [Many Block]
l | Bool -> Bool
not ([Many Block] -> Bool
forall (t :: * -> *) a. Foldable t => t a -> Bool
null [Many Block]
l)]
Many Block -> ParserT Text ParserState m (Many Block)
forall (m :: * -> *) a. Monad m => a -> m a
return (Many Block -> ParserT Text ParserState m (Many Block))
-> Many Block -> ParserT Text ParserState m (Many Block)
forall a b. (a -> b) -> a -> b
$ Caption
-> [ColSpec] -> TableHead -> [TableBody] -> TableFoot -> Many Block
B.table (Many Block -> Caption
B.simpleCaption (Many Block -> Caption) -> Many Block -> Caption
forall a b. (a -> b) -> a -> b
$ Inlines -> Many Block
B.plain Inlines
caption)
([Alignment] -> [ColWidth] -> [ColSpec]
forall a b. [a] -> [b] -> [(a, b)]
zip [Alignment]
aligns (Int -> ColWidth -> [ColWidth]
forall a. Int -> a -> [a]
replicate Int
nbOfCols ColWidth
ColWidthDefault))
(Attr -> [Row] -> TableHead
TableHead Attr
nullAttr ([Row] -> TableHead) -> [Row] -> TableHead
forall a b. (a -> b) -> a -> b
$ [Many Block] -> [Row]
toHeaderRow ([Many Block] -> [Row]) -> [Many Block] -> [Row]
forall a b. (a -> b) -> a -> b
$ (((Bool, Alignment), Many Block) -> Many Block)
-> [((Bool, Alignment), Many Block)] -> [Many Block]
forall a b. (a -> b) -> [a] -> [b]
map ((Bool, Alignment), Many Block) -> Many Block
forall a b. (a, b) -> b
snd [((Bool, Alignment), Many Block)]
headers)
[Attr -> RowHeadColumns -> [Row] -> [Row] -> TableBody
TableBody Attr
nullAttr RowHeadColumns
0 [] ([Row] -> TableBody) -> [Row] -> TableBody
forall a b. (a -> b) -> a -> b
$ ([((Bool, Alignment), Many Block)] -> Row)
-> [[((Bool, Alignment), Many Block)]] -> [Row]
forall a b. (a -> b) -> [a] -> [b]
map ([Many Block] -> Row
toRow ([Many Block] -> Row)
-> ([((Bool, Alignment), Many Block)] -> [Many Block])
-> [((Bool, Alignment), Many Block)]
-> Row
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (((Bool, Alignment), Many Block) -> Many Block)
-> [((Bool, Alignment), Many Block)] -> [Many Block]
forall a b. (a -> b) -> [a] -> [b]
map ((Bool, Alignment), Many Block) -> Many Block
forall a b. (a, b) -> b
snd) [[((Bool, Alignment), Many Block)]]
rows]
(Attr -> [Row] -> TableFoot
TableFoot Attr
nullAttr [])
ignorableRow :: PandocMonad m => ParserT Text ParserState m ()
ignorableRow :: ParserT Text ParserState m ()
ignorableRow = ParserT Text ParserState m () -> ParserT Text ParserState m ()
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try (ParserT Text ParserState m () -> ParserT Text ParserState m ())
-> ParserT Text ParserState m () -> ParserT Text ParserState m ()
forall a b. (a -> b) -> a -> b
$ do
Char -> ParsecT Text ParserState m Char
forall s (m :: * -> *) u.
Stream s m Char =>
Char -> ParsecT s u m Char
char Char
'|'
[Char] -> ParsecT Text ParserState m Char
forall s (m :: * -> *) u.
Stream s m Char =>
[Char] -> ParsecT s u m Char
oneOf [Char]
":^-~"
Attr
_ <- ParserT Text ParserState m Attr
forall (m :: * -> *).
PandocMonad m =>
ParserT Text ParserState m Attr
attributes
Char -> ParsecT Text ParserState m Char
forall s (m :: * -> *) u.
Stream s m Char =>
Char -> ParsecT s u m Char
char Char
'.'
Text
_ <- ParserT Text ParserState m Text
forall (m :: * -> *) st. Monad m => ParserT Text st m Text
anyLine
() -> ParserT Text ParserState m ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()
explicitBlockStart :: PandocMonad m => Text -> ParserT Text ParserState m ()
explicitBlockStart :: Text -> ParserT Text ParserState m ()
explicitBlockStart Text
name = ParserT Text ParserState m () -> ParserT Text ParserState m ()
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try (ParserT Text ParserState m () -> ParserT Text ParserState m ())
-> ParserT Text ParserState m () -> ParserT Text ParserState m ()
forall a b. (a -> b) -> a -> b
$ do
[Char] -> ParsecT Text ParserState m [Char]
forall s (m :: * -> *) u.
Stream s m Char =>
[Char] -> ParsecT s u m [Char]
string (Text -> [Char]
T.unpack Text
name)
ParserT Text ParserState m Attr
forall (m :: * -> *).
PandocMonad m =>
ParserT Text ParserState m Attr
attributes
Char -> ParsecT Text ParserState m Char
forall s (m :: * -> *) u.
Stream s m Char =>
Char -> ParsecT s u m Char
char Char
'.'
ParsecT Text ParserState m Inlines -> ParserT Text ParserState m ()
forall s (m :: * -> *) t u a.
Stream s m t =>
ParsecT s u m a -> ParsecT s u m ()
optional ParsecT Text ParserState m Inlines
forall (m :: * -> *) st. PandocMonad m => ParserT Text st m Inlines
whitespace
ParsecT Text ParserState m Inlines -> ParserT Text ParserState m ()
forall s (m :: * -> *) t u a.
Stream s m t =>
ParsecT s u m a -> ParsecT s u m ()
optional ParsecT Text ParserState m Inlines
forall (m :: * -> *).
PandocMonad m =>
ParserT Text ParserState m Inlines
endline
maybeExplicitBlock :: PandocMonad m
=> Text
-> ParserT Text ParserState m Blocks
-> ParserT Text ParserState m Blocks
maybeExplicitBlock :: Text
-> ParserT Text ParserState m (Many Block)
-> ParserT Text ParserState m (Many Block)
maybeExplicitBlock Text
name ParserT Text ParserState m (Many Block)
blk = ParserT Text ParserState m (Many Block)
-> ParserT Text ParserState m (Many Block)
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try (ParserT Text ParserState m (Many Block)
-> ParserT Text ParserState m (Many Block))
-> ParserT Text ParserState m (Many Block)
-> ParserT Text ParserState m (Many Block)
forall a b. (a -> b) -> a -> b
$ do
ParsecT Text ParserState m () -> ParsecT Text ParserState m ()
forall s (m :: * -> *) t u a.
Stream s m t =>
ParsecT s u m a -> ParsecT s u m ()
optional (ParsecT Text ParserState m () -> ParsecT Text ParserState m ())
-> ParsecT Text ParserState m () -> ParsecT Text ParserState m ()
forall a b. (a -> b) -> a -> b
$ Text -> ParsecT Text ParserState m ()
forall (m :: * -> *).
PandocMonad m =>
Text -> ParserT Text ParserState m ()
explicitBlockStart Text
name
ParserT Text ParserState m (Many Block)
blk
inline :: PandocMonad m => ParserT Text ParserState m Inlines
inline :: ParserT Text ParserState m Inlines
inline = [ParserT Text ParserState m Inlines]
-> ParserT Text ParserState m Inlines
forall s (m :: * -> *) t u a.
Stream s m t =>
[ParsecT s u m a] -> ParsecT s u m a
choice [ParserT Text ParserState m Inlines]
forall (m :: * -> *).
PandocMonad m =>
[ParserT Text ParserState m Inlines]
inlineParsers ParserT Text ParserState m Inlines
-> [Char] -> ParserT Text ParserState m Inlines
forall s u (m :: * -> *) a.
ParsecT s u m a -> [Char] -> ParsecT s u m a
<?> [Char]
"inline"
inlineParsers :: PandocMonad m => [ParserT Text ParserState m Inlines]
inlineParsers :: [ParserT Text ParserState m Inlines]
inlineParsers = [ ParserT Text ParserState m Inlines
forall (m :: * -> *).
PandocMonad m =>
ParserT Text ParserState m Inlines
str
, ParserT Text ParserState m Inlines
forall (m :: * -> *) st. PandocMonad m => ParserT Text st m Inlines
whitespace
, ParserT Text ParserState m Inlines
forall (m :: * -> *).
PandocMonad m =>
ParserT Text ParserState m Inlines
endline
, ParserT Text ParserState m Inlines
forall (m :: * -> *).
PandocMonad m =>
ParserT Text ParserState m Inlines
code
, ParserT Text ParserState m Inlines
forall (m :: * -> *).
PandocMonad m =>
ParserT Text ParserState m Inlines
escapedInline
, ParserT Text ParserState m Inlines
forall (m :: * -> *).
PandocMonad m =>
ParserT Text ParserState m Inlines
inlineMarkup
, ParserT Text ParserState m Inlines
forall (m :: * -> *).
PandocMonad m =>
ParserT Text ParserState m Inlines
groupedInlineMarkup
, ParserT Text ParserState m Inlines
forall (m :: * -> *).
PandocMonad m =>
ParserT Text ParserState m Inlines
rawHtmlInline
, ParserT Text ParserState m Inlines
forall (m :: * -> *).
PandocMonad m =>
ParserT Text ParserState m Inlines
rawLaTeXInline'
, ParserT Text ParserState m Inlines
forall (m :: * -> *).
PandocMonad m =>
ParserT Text ParserState m Inlines
note
, ParserT Text ParserState m Inlines
forall (m :: * -> *).
PandocMonad m =>
ParserT Text ParserState m Inlines
link
, ParserT Text ParserState m Inlines
forall (m :: * -> *).
PandocMonad m =>
ParserT Text ParserState m Inlines
image
, ParserT Text ParserState m Inlines
forall (m :: * -> *) st. PandocMonad m => ParserT Text st m Inlines
mark
, Text -> Inlines
B.str (Text -> Inlines) -> (Char -> Text) -> Char -> Inlines
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Char -> Text
T.singleton (Char -> Inlines)
-> ParsecT Text ParserState m Char
-> ParserT Text ParserState m Inlines
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ParsecT Text ParserState m Char
forall s (m :: * -> *) st. Stream s m Char => ParserT s st m Char
characterReference
, ParserT Text ParserState m Inlines
-> ParserT Text ParserState m Inlines
forall st (m :: * -> *) s.
(HasReaderOptions st, HasLastStrPosition st, HasQuoteContext st m,
Stream s m Char) =>
ParserT s st m Inlines -> ParserT s st m Inlines
smartPunctuation ParserT Text ParserState m Inlines
forall (m :: * -> *).
PandocMonad m =>
ParserT Text ParserState m Inlines
inline
, ParserT Text ParserState m Inlines
forall (m :: * -> *).
PandocMonad m =>
ParserT Text ParserState m Inlines
symbol
]
inlineMarkup :: PandocMonad m => ParserT Text ParserState m Inlines
inlineMarkup :: ParserT Text ParserState m Inlines
inlineMarkup = [ParserT Text ParserState m Inlines]
-> ParserT Text ParserState m Inlines
forall s (m :: * -> *) t u a.
Stream s m t =>
[ParsecT s u m a] -> ParsecT s u m a
choice [ ParserT Text ParserState m [Char]
-> (Inlines -> Inlines) -> ParserT Text ParserState m Inlines
forall (m :: * -> *) t.
PandocMonad m =>
ParserT Text ParserState m t
-> (Inlines -> Inlines) -> ParserT Text ParserState m Inlines
simpleInline ([Char] -> ParserT Text ParserState m [Char]
forall s (m :: * -> *) u.
Stream s m Char =>
[Char] -> ParsecT s u m [Char]
string [Char]
"??") ([Citation] -> Inlines -> Inlines
B.cite [])
, ParserT Text ParserState m [Char]
-> (Inlines -> Inlines) -> ParserT Text ParserState m Inlines
forall (m :: * -> *) t.
PandocMonad m =>
ParserT Text ParserState m t
-> (Inlines -> Inlines) -> ParserT Text ParserState m Inlines
simpleInline ([Char] -> ParserT Text ParserState m [Char]
forall s (m :: * -> *) u.
Stream s m Char =>
[Char] -> ParsecT s u m [Char]
string [Char]
"**") Inlines -> Inlines
B.strong
, ParserT Text ParserState m [Char]
-> (Inlines -> Inlines) -> ParserT Text ParserState m Inlines
forall (m :: * -> *) t.
PandocMonad m =>
ParserT Text ParserState m t
-> (Inlines -> Inlines) -> ParserT Text ParserState m Inlines
simpleInline ([Char] -> ParserT Text ParserState m [Char]
forall s (m :: * -> *) u.
Stream s m Char =>
[Char] -> ParsecT s u m [Char]
string [Char]
"__") Inlines -> Inlines
B.emph
, ParserT Text ParserState m Char
-> (Inlines -> Inlines) -> ParserT Text ParserState m Inlines
forall (m :: * -> *) t.
PandocMonad m =>
ParserT Text ParserState m t
-> (Inlines -> Inlines) -> ParserT Text ParserState m Inlines
simpleInline (Char -> ParserT Text ParserState m Char
forall s (m :: * -> *) u.
Stream s m Char =>
Char -> ParsecT s u m Char
char Char
'*') Inlines -> Inlines
B.strong
, ParserT Text ParserState m Char
-> (Inlines -> Inlines) -> ParserT Text ParserState m Inlines
forall (m :: * -> *) t.
PandocMonad m =>
ParserT Text ParserState m t
-> (Inlines -> Inlines) -> ParserT Text ParserState m Inlines
simpleInline (Char -> ParserT Text ParserState m Char
forall s (m :: * -> *) u.
Stream s m Char =>
Char -> ParsecT s u m Char
char Char
'_') Inlines -> Inlines
B.emph
, ParserT Text ParserState m Char
-> (Inlines -> Inlines) -> ParserT Text ParserState m Inlines
forall (m :: * -> *) t.
PandocMonad m =>
ParserT Text ParserState m t
-> (Inlines -> Inlines) -> ParserT Text ParserState m Inlines
simpleInline (Char -> ParserT Text ParserState m Char
forall s (m :: * -> *) u.
Stream s m Char =>
Char -> ParsecT s u m Char
char Char
'+') Inlines -> Inlines
B.underline
, ParserT Text ParserState m Char
-> (Inlines -> Inlines) -> ParserT Text ParserState m Inlines
forall (m :: * -> *) t.
PandocMonad m =>
ParserT Text ParserState m t
-> (Inlines -> Inlines) -> ParserT Text ParserState m Inlines
simpleInline (Char -> ParserT Text ParserState m Char
forall s (m :: * -> *) u.
Stream s m Char =>
Char -> ParsecT s u m Char
char Char
'-' ParserT Text ParserState m Char
-> ParsecT Text ParserState m () -> ParserT Text ParserState m Char
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
<* ParserT Text ParserState m Char -> ParsecT Text ParserState m ()
forall s (m :: * -> *) t a u.
(Stream s m t, Show a) =>
ParsecT s u m a -> ParsecT s u m ()
notFollowedBy (Char -> ParserT Text ParserState m Char
forall s (m :: * -> *) u.
Stream s m Char =>
Char -> ParsecT s u m Char
char Char
'-')) Inlines -> Inlines
B.strikeout
, ParserT Text ParserState m Char
-> (Inlines -> Inlines) -> ParserT Text ParserState m Inlines
forall (m :: * -> *) t.
PandocMonad m =>
ParserT Text ParserState m t
-> (Inlines -> Inlines) -> ParserT Text ParserState m Inlines
simpleInline (Char -> ParserT Text ParserState m Char
forall s (m :: * -> *) u.
Stream s m Char =>
Char -> ParsecT s u m Char
char Char
'^') Inlines -> Inlines
B.superscript
, ParserT Text ParserState m Char
-> (Inlines -> Inlines) -> ParserT Text ParserState m Inlines
forall (m :: * -> *) t.
PandocMonad m =>
ParserT Text ParserState m t
-> (Inlines -> Inlines) -> ParserT Text ParserState m Inlines
simpleInline (Char -> ParserT Text ParserState m Char
forall s (m :: * -> *) u.
Stream s m Char =>
Char -> ParsecT s u m Char
char Char
'~') Inlines -> Inlines
B.subscript
, ParserT Text ParserState m Char
-> (Inlines -> Inlines) -> ParserT Text ParserState m Inlines
forall (m :: * -> *) t.
PandocMonad m =>
ParserT Text ParserState m t
-> (Inlines -> Inlines) -> ParserT Text ParserState m Inlines
simpleInline (Char -> ParserT Text ParserState m Char
forall s (m :: * -> *) u.
Stream s m Char =>
Char -> ParsecT s u m Char
char Char
'%') Inlines -> Inlines
forall a. a -> a
id
]
mark :: PandocMonad m => ParserT Text st m Inlines
mark :: ParserT Text st m Inlines
mark = ParserT Text st m Inlines -> ParserT Text st m Inlines
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try (ParserT Text st m Inlines -> ParserT Text st m Inlines)
-> ParserT Text st m Inlines -> ParserT Text st m Inlines
forall a b. (a -> b) -> a -> b
$ Char -> ParsecT Text st m Char
forall s (m :: * -> *) u.
Stream s m Char =>
Char -> ParsecT s u m Char
char Char
'(' ParsecT Text st m Char
-> ParserT Text st m Inlines -> ParserT Text st m Inlines
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> (ParserT Text st m Inlines -> ParserT Text st m Inlines
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try ParserT Text st m Inlines
forall (m :: * -> *) st. PandocMonad m => ParserT Text st m Inlines
tm ParserT Text st m Inlines
-> ParserT Text st m Inlines -> ParserT Text st m Inlines
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> ParserT Text st m Inlines -> ParserT Text st m Inlines
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try ParserT Text st m Inlines
forall (m :: * -> *) st. PandocMonad m => ParserT Text st m Inlines
reg ParserT Text st m Inlines
-> ParserT Text st m Inlines -> ParserT Text st m Inlines
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> ParserT Text st m Inlines
forall (m :: * -> *) st. PandocMonad m => ParserT Text st m Inlines
copy)
reg :: PandocMonad m => ParserT Text st m Inlines
reg :: ParserT Text st m Inlines
reg = do
[Char] -> ParsecT Text st m Char
forall s (m :: * -> *) u.
Stream s m Char =>
[Char] -> ParsecT s u m Char
oneOf [Char]
"Rr"
Char -> ParsecT Text st m Char
forall s (m :: * -> *) u.
Stream s m Char =>
Char -> ParsecT s u m Char
char Char
')'
Inlines -> ParserT Text st m Inlines
forall (m :: * -> *) a. Monad m => a -> m a
return (Inlines -> ParserT Text st m Inlines)
-> Inlines -> ParserT Text st m Inlines
forall a b. (a -> b) -> a -> b
$ Text -> Inlines
B.str Text
"\174"
tm :: PandocMonad m => ParserT Text st m Inlines
tm :: ParserT Text st m Inlines
tm = do
[Char] -> ParsecT Text st m Char
forall s (m :: * -> *) u.
Stream s m Char =>
[Char] -> ParsecT s u m Char
oneOf [Char]
"Tt"
[Char] -> ParsecT Text st m Char
forall s (m :: * -> *) u.
Stream s m Char =>
[Char] -> ParsecT s u m Char
oneOf [Char]
"Mm"
Char -> ParsecT Text st m Char
forall s (m :: * -> *) u.
Stream s m Char =>
Char -> ParsecT s u m Char
char Char
')'
Inlines -> ParserT Text st m Inlines
forall (m :: * -> *) a. Monad m => a -> m a
return (Inlines -> ParserT Text st m Inlines)
-> Inlines -> ParserT Text st m Inlines
forall a b. (a -> b) -> a -> b
$ Text -> Inlines
B.str Text
"\8482"
copy :: PandocMonad m => ParserT Text st m Inlines
copy :: ParserT Text st m Inlines
copy = do
[Char] -> ParsecT Text st m Char
forall s (m :: * -> *) u.
Stream s m Char =>
[Char] -> ParsecT s u m Char
oneOf [Char]
"Cc"
Char -> ParsecT Text st m Char
forall s (m :: * -> *) u.
Stream s m Char =>
Char -> ParsecT s u m Char
char Char
')'
Inlines -> ParserT Text st m Inlines
forall (m :: * -> *) a. Monad m => a -> m a
return (Inlines -> ParserT Text st m Inlines)
-> Inlines -> ParserT Text st m Inlines
forall a b. (a -> b) -> a -> b
$ Text -> Inlines
B.str Text
"\169"
note :: PandocMonad m => ParserT Text ParserState m Inlines
note :: ParserT Text ParserState m Inlines
note = ParserT Text ParserState m Inlines
-> ParserT Text ParserState m Inlines
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try (ParserT Text ParserState m Inlines
-> ParserT Text ParserState m Inlines)
-> ParserT Text ParserState m Inlines
-> ParserT Text ParserState m Inlines
forall a b. (a -> b) -> a -> b
$ do
[Char]
ref <- Char -> ParsecT Text ParserState m Char
forall s (m :: * -> *) u.
Stream s m Char =>
Char -> ParsecT s u m Char
char Char
'[' ParsecT Text ParserState m Char
-> ParsecT Text ParserState m [Char]
-> ParsecT Text ParserState m [Char]
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> ParsecT Text ParserState m Char
-> ParsecT Text ParserState m [Char]
forall s (m :: * -> *) t u a.
Stream s m t =>
ParsecT s u m a -> ParsecT s u m [a]
many1 ParsecT Text ParserState m Char
forall s (m :: * -> *) st. Stream s m Char => ParserT s st m Char
digit ParsecT Text ParserState m [Char]
-> ParsecT Text ParserState m Char
-> ParsecT Text ParserState m [Char]
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
<* Char -> ParsecT Text ParserState m Char
forall s (m :: * -> *) u.
Stream s m Char =>
Char -> ParsecT s u m Char
char Char
']'
NoteTable
notes <- ParserState -> NoteTable
stateNotes (ParserState -> NoteTable)
-> ParsecT Text ParserState m ParserState
-> ParsecT Text ParserState m NoteTable
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ParsecT Text ParserState m ParserState
forall (m :: * -> *) s u. Monad m => ParsecT s u m u
getState
case Text -> NoteTable -> Maybe Text
forall a b. Eq a => a -> [(a, b)] -> Maybe b
lookup ([Char] -> Text
T.pack [Char]
ref) NoteTable
notes of
Maybe Text
Nothing -> [Char] -> ParserT Text ParserState m Inlines
forall (m :: * -> *) a. MonadFail m => [Char] -> m a
Prelude.fail [Char]
"note not found"
Just Text
raw -> Many Block -> Inlines
B.note (Many Block -> Inlines)
-> ParsecT Text ParserState m (Many Block)
-> ParserT Text ParserState m Inlines
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ParsecT Text ParserState m (Many Block)
-> Text -> ParsecT Text ParserState m (Many Block)
forall s (m :: * -> *) u a.
(Stream s m Char, IsString s, HasLastStrPosition u) =>
ParserT s u m a -> Text -> ParserT s u m a
parseFromString' ParsecT Text ParserState m (Many Block)
forall (m :: * -> *).
PandocMonad m =>
ParserT Text ParserState m (Many Block)
parseBlocks Text
raw
markupChars :: [Char]
markupChars :: [Char]
markupChars = [Char]
"\\*#_@~-+^|%=[]&"
stringBreakers :: [Char]
stringBreakers :: [Char]
stringBreakers = [Char]
" \t\n\r.,\"'?!;:<>«»„“”‚‘’()[]"
wordBoundaries :: [Char]
wordBoundaries :: [Char]
wordBoundaries = [Char]
markupChars [Char] -> [Char] -> [Char]
forall a. Semigroup a => a -> a -> a
<> [Char]
stringBreakers
hyphenedWords :: PandocMonad m => ParserT Text ParserState m Text
hyphenedWords :: ParserT Text ParserState m Text
hyphenedWords = do
Text
x <- ParserT Text ParserState m Text
forall (m :: * -> *).
PandocMonad m =>
ParserT Text ParserState m Text
wordChunk
[Text]
xs <- ParserT Text ParserState m Text
-> ParsecT Text ParserState m [Text]
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m [a]
many (ParserT Text ParserState m Text -> ParserT Text ParserState m Text
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try (ParserT Text ParserState m Text
-> ParserT Text ParserState m Text)
-> ParserT Text ParserState m Text
-> ParserT Text ParserState m Text
forall a b. (a -> b) -> a -> b
$ Char -> ParsecT Text ParserState m Char
forall s (m :: * -> *) u.
Stream s m Char =>
Char -> ParsecT s u m Char
char Char
'-' ParsecT Text ParserState m Char
-> ParserT Text ParserState m Text
-> ParserT Text ParserState m Text
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> ParserT Text ParserState m Text
forall (m :: * -> *).
PandocMonad m =>
ParserT Text ParserState m Text
wordChunk)
Text -> ParserT Text ParserState m Text
forall (m :: * -> *) a. Monad m => a -> m a
return (Text -> ParserT Text ParserState m Text)
-> Text -> ParserT Text ParserState m Text
forall a b. (a -> b) -> a -> b
$ Text -> [Text] -> Text
T.intercalate Text
"-" (Text
xText -> [Text] -> [Text]
forall a. a -> [a] -> [a]
:[Text]
xs)
wordChunk :: PandocMonad m => ParserT Text ParserState m Text
wordChunk :: ParserT Text ParserState m Text
wordChunk = ParserT Text ParserState m Text -> ParserT Text ParserState m Text
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try (ParserT Text ParserState m Text
-> ParserT Text ParserState m Text)
-> ParserT Text ParserState m Text
-> ParserT Text ParserState m Text
forall a b. (a -> b) -> a -> b
$ do
Char
hd <- [Char] -> ParsecT Text ParserState m Char
forall s (m :: * -> *) u.
Stream s m Char =>
[Char] -> ParsecT s u m Char
noneOf [Char]
wordBoundaries
[Char]
tl <- ParsecT Text ParserState m Char
-> ParsecT Text ParserState m [Char]
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m [a]
many ( [Char] -> ParsecT Text ParserState m Char
forall s (m :: * -> *) u.
Stream s m Char =>
[Char] -> ParsecT s u m Char
noneOf [Char]
wordBoundaries ParsecT Text ParserState m Char
-> ParsecT Text ParserState m Char
-> ParsecT Text ParserState m Char
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|>
ParsecT Text ParserState m Char -> ParsecT Text ParserState m Char
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try (ParserT Text ParserState m Inlines -> ParserT Text ParserState m ()
forall b s (m :: * -> *) a st.
(Show b, Stream s m a) =>
ParserT s st m b -> ParserT s st m ()
notFollowedBy' ParserT Text ParserState m Inlines
forall (m :: * -> *).
PandocMonad m =>
ParserT Text ParserState m Inlines
note ParserT Text ParserState m ()
-> ParsecT Text ParserState m Char
-> ParsecT Text ParserState m Char
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> [Char] -> ParsecT Text ParserState m Char
forall s (m :: * -> *) u.
Stream s m Char =>
[Char] -> ParsecT s u m Char
oneOf [Char]
markupChars
ParsecT Text ParserState m Char
-> ParsecT Text ParserState m Char
-> ParsecT Text ParserState m Char
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
<* ParsecT Text ParserState m Char -> ParsecT Text ParserState m Char
forall s (m :: * -> *) t u a.
Stream s m t =>
ParsecT s u m a -> ParsecT s u m a
lookAhead ([Char] -> ParsecT Text ParserState m Char
forall s (m :: * -> *) u.
Stream s m Char =>
[Char] -> ParsecT s u m Char
noneOf [Char]
wordBoundaries) ) )
Text -> ParserT Text ParserState m Text
forall (m :: * -> *) a. Monad m => a -> m a
return (Text -> ParserT Text ParserState m Text)
-> Text -> ParserT Text ParserState m Text
forall a b. (a -> b) -> a -> b
$ [Char] -> Text
T.pack ([Char] -> Text) -> [Char] -> Text
forall a b. (a -> b) -> a -> b
$ Char
hdChar -> [Char] -> [Char]
forall a. a -> [a] -> [a]
:[Char]
tl
str :: PandocMonad m => ParserT Text ParserState m Inlines
str :: ParserT Text ParserState m Inlines
str = do
Text
baseStr <- ParserT Text ParserState m Text
forall (m :: * -> *).
PandocMonad m =>
ParserT Text ParserState m Text
hyphenedWords
Text
fullStr <- Text
-> ParserT Text ParserState m Text
-> ParserT Text ParserState 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
baseStr (ParserT Text ParserState m Text
-> ParserT Text ParserState m Text)
-> ParserT Text ParserState m Text
-> ParserT Text ParserState m Text
forall a b. (a -> b) -> a -> b
$ ParserT Text ParserState m Text -> ParserT Text ParserState m Text
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try (ParserT Text ParserState m Text
-> ParserT Text ParserState m Text)
-> ParserT Text ParserState m Text
-> ParserT Text ParserState m Text
forall a b. (a -> b) -> a -> b
$ do
Bool -> ParsecT Text ParserState m ()
forall (f :: * -> *). Alternative f => Bool -> f ()
guard (Bool -> ParsecT Text ParserState m ())
-> Bool -> ParsecT Text ParserState m ()
forall a b. (a -> b) -> a -> b
$ (Char -> Bool) -> Text -> Bool
T.all Char -> Bool
isUpper Text
baseStr
Text
acro <- [Char] -> Text
T.pack ([Char] -> Text)
-> ParsecT Text ParserState m [Char]
-> ParserT Text ParserState m Text
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ParserT Text ParserState m Char
-> ParserT Text ParserState m Char
-> ParserT Text ParserState m Char
-> ParsecT Text ParserState m [Char]
forall end s (m :: * -> *) st t a.
(Show end, Stream s m Char) =>
ParserT s st m t
-> ParserT s st m end -> ParserT s st m a -> ParserT s st m [a]
enclosed (Char -> ParserT Text ParserState m Char
forall s (m :: * -> *) u.
Stream s m Char =>
Char -> ParsecT s u m Char
char Char
'(') (Char -> ParserT Text ParserState m Char
forall s (m :: * -> *) u.
Stream s m Char =>
Char -> ParsecT s u m Char
char Char
')') ParserT Text ParserState m Char
forall (m :: * -> *).
PandocMonad m =>
ParserT Text ParserState m Char
anyChar'
Text -> ParserT Text ParserState m Text
forall (m :: * -> *) a. Monad m => a -> m a
return (Text -> ParserT Text ParserState m Text)
-> Text -> ParserT Text ParserState m Text
forall a b. (a -> b) -> a -> b
$ [Text] -> Text
T.concat [Text
baseStr, Text
" (", Text
acro, Text
")"]
ParsecT Text ParserState m ()
forall s (m :: * -> *) a st.
(Stream s m a, HasLastStrPosition st) =>
ParserT s st m ()
updateLastStrPos
Inlines -> ParserT Text ParserState m Inlines
forall (m :: * -> *) a. Monad m => a -> m a
return (Inlines -> ParserT Text ParserState m Inlines)
-> Inlines -> ParserT Text ParserState m Inlines
forall a b. (a -> b) -> a -> b
$ Text -> Inlines
B.str Text
fullStr
whitespace :: PandocMonad m => ParserT Text st m Inlines
whitespace :: ParserT Text st m Inlines
whitespace = ParsecT Text st m Char -> ParsecT Text st m [Char]
forall s (m :: * -> *) t u a.
Stream s m t =>
ParsecT s u m a -> ParsecT s u m [a]
many1 ParsecT Text st m Char
forall s (m :: * -> *) st. Stream s m Char => ParserT s st m Char
spaceChar ParsecT Text st m [Char]
-> ParserT Text st m Inlines -> ParserT Text st m Inlines
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> Inlines -> ParserT Text st m Inlines
forall (m :: * -> *) a. Monad m => a -> m a
return Inlines
B.space ParserT Text st m Inlines -> [Char] -> ParserT Text st m Inlines
forall s u (m :: * -> *) a.
ParsecT s u m a -> [Char] -> ParsecT s u m a
<?> [Char]
"whitespace"
endline :: PandocMonad m => ParserT Text ParserState m Inlines
endline :: ParserT Text ParserState m Inlines
endline = ParserT Text ParserState m Inlines
-> ParserT Text ParserState m Inlines
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try (ParserT Text ParserState m Inlines
-> ParserT Text ParserState m Inlines)
-> ParserT Text ParserState m Inlines
-> ParserT Text ParserState m Inlines
forall a b. (a -> b) -> a -> b
$ do
ParsecT Text ParserState m Char
forall s (m :: * -> *) st. Stream s m Char => ParserT s st m Char
newline
ParsecT Text ParserState m Char -> ParsecT Text ParserState m ()
forall s (m :: * -> *) t a u.
(Stream s m t, Show a) =>
ParsecT s u m a -> ParsecT s u m ()
notFollowedBy ParsecT Text ParserState m Char
forall s (m :: * -> *) st. Stream s m Char => ParserT s st m Char
blankline
ParsecT Text ParserState m () -> ParsecT Text ParserState m ()
forall s (m :: * -> *) t a u.
(Stream s m t, Show a) =>
ParsecT s u m a -> ParsecT s u m ()
notFollowedBy ParsecT Text ParserState m ()
forall (m :: * -> *).
PandocMonad m =>
ParserT Text ParserState m ()
listStart
ParsecT Text ParserState m (Many Block)
-> ParsecT Text ParserState m ()
forall s (m :: * -> *) t a u.
(Stream s m t, Show a) =>
ParsecT s u m a -> ParsecT s u m ()
notFollowedBy ParsecT Text ParserState m (Many Block)
forall (m :: * -> *).
PandocMonad m =>
ParserT Text ParserState m (Many Block)
rawHtmlBlock
Inlines -> ParserT Text ParserState m Inlines
forall (m :: * -> *) a. Monad m => a -> m a
return Inlines
B.linebreak
rawHtmlInline :: PandocMonad m => ParserT Text ParserState m Inlines
rawHtmlInline :: ParserT Text ParserState m Inlines
rawHtmlInline = Text -> Text -> Inlines
B.rawInline Text
"html" (Text -> Inlines)
-> ((Tag Text, Text) -> Text) -> (Tag Text, Text) -> Inlines
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Tag Text, Text) -> Text
forall a b. (a, b) -> b
snd ((Tag Text, Text) -> Inlines)
-> ParsecT Text ParserState m (Tag Text, Text)
-> ParserT Text ParserState m Inlines
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (Tag Text -> Bool) -> ParsecT Text ParserState m (Tag Text, Text)
forall st (m :: * -> *).
(HasReaderOptions st, Monad m) =>
(Tag Text -> Bool) -> ParserT Text st m (Tag Text, Text)
htmlTag Tag Text -> Bool
isInlineTag
rawLaTeXInline' :: PandocMonad m => ParserT Text ParserState m Inlines
rawLaTeXInline' :: ParserT Text ParserState m Inlines
rawLaTeXInline' = ParserT Text ParserState m Inlines
-> ParserT Text ParserState m Inlines
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try (ParserT Text ParserState m Inlines
-> ParserT Text ParserState m Inlines)
-> ParserT Text ParserState m Inlines
-> ParserT Text ParserState m Inlines
forall a b. (a -> b) -> a -> b
$ do
Extension -> ParserT Text ParserState m ()
forall s (m :: * -> *) a st.
(Stream s m a, HasReaderOptions st) =>
Extension -> ParserT s st m ()
guardEnabled Extension
Ext_raw_tex
Text -> Text -> Inlines
B.rawInline Text
"latex" (Text -> Inlines)
-> ParsecT Text ParserState m Text
-> ParserT Text ParserState m Inlines
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ParsecT Text ParserState m Text
forall (m :: * -> *) s.
(PandocMonad m, HasMacros s, HasReaderOptions s) =>
ParserT Text s m Text
rawLaTeXInline
link :: PandocMonad m => ParserT Text ParserState m Inlines
link :: ParserT Text ParserState m Inlines
link = ParserT Text ParserState m Inlines
-> ParserT Text ParserState m Inlines
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try (ParserT Text ParserState m Inlines
-> ParserT Text ParserState m Inlines)
-> ParserT Text ParserState m Inlines
-> ParserT Text ParserState m Inlines
forall a b. (a -> b) -> a -> b
$ do
Bool
bracketed <- (Bool
True Bool
-> ParsecT Text ParserState m Char
-> ParsecT Text ParserState m Bool
forall (f :: * -> *) a b. Functor f => a -> f b -> f a
<$ Char -> ParsecT Text ParserState m Char
forall s (m :: * -> *) u.
Stream s m Char =>
Char -> ParsecT s u m Char
char Char
'[') ParsecT Text ParserState m Bool
-> ParsecT Text ParserState m Bool
-> ParsecT Text ParserState m Bool
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> Bool -> ParsecT Text ParserState m Bool
forall (m :: * -> *) a. Monad m => a -> m a
return Bool
False
Char -> ParsecT Text ParserState m Char
forall s (m :: * -> *) u.
Stream s m Char =>
Char -> ParsecT s u m Char
char Char
'"' ParsecT Text ParserState m Char
-> ParsecT Text ParserState m () -> ParsecT Text ParserState m ()
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> ParsecT Text ParserState m Char -> ParsecT Text ParserState m ()
forall s (m :: * -> *) t a u.
(Stream s m t, Show a) =>
ParsecT s u m a -> ParsecT s u m ()
notFollowedBy ([Char] -> ParsecT Text ParserState m Char
forall s (m :: * -> *) u.
Stream s m Char =>
[Char] -> ParsecT s u m Char
oneOf [Char]
" \t\n\r")
Attr
attr <- ParserT Text ParserState m Attr
forall (m :: * -> *).
PandocMonad m =>
ParserT Text ParserState m Attr
attributes
Inlines
name <- Inlines -> Inlines
trimInlines (Inlines -> Inlines)
-> ([Inlines] -> Inlines) -> [Inlines] -> Inlines
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [Inlines] -> Inlines
forall a. Monoid a => [a] -> a
mconcat ([Inlines] -> Inlines)
-> ParsecT Text ParserState m [Inlines]
-> ParserT Text ParserState m Inlines
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$>
QuoteContext
-> ParsecT Text ParserState m [Inlines]
-> ParsecT Text ParserState m [Inlines]
forall st (m :: * -> *) s a.
HasQuoteContext st m =>
QuoteContext -> ParsecT s st m a -> ParsecT s st m a
withQuoteContext QuoteContext
InDoubleQuote (ParserT Text ParserState m Inlines
-> ParsecT Text ParserState m Char
-> ParsecT Text ParserState m [Inlines]
forall end s (m :: * -> *) t st a.
(Show end, Stream s m t) =>
ParserT s st m a -> ParserT s st m end -> ParserT s st m [a]
many1Till ParserT Text ParserState m Inlines
forall (m :: * -> *).
PandocMonad m =>
ParserT Text ParserState m Inlines
inline (Char -> ParsecT Text ParserState m Char
forall s (m :: * -> *) u.
Stream s m Char =>
Char -> ParsecT s u m Char
char Char
'"'))
Char -> ParsecT Text ParserState m Char
forall s (m :: * -> *) u.
Stream s m Char =>
Char -> ParsecT s u m Char
char Char
':'
let stop :: ParsecT Text u m Char
stop = if Bool
bracketed
then Char -> ParsecT Text u m Char
forall s (m :: * -> *) u.
Stream s m Char =>
Char -> ParsecT s u m Char
char Char
']'
else ParsecT Text u m Char -> ParsecT Text u m Char
forall s (m :: * -> *) t u a.
Stream s m t =>
ParsecT s u m a -> ParsecT s u m a
lookAhead (ParsecT Text u m Char -> ParsecT Text u m Char)
-> ParsecT Text u m Char -> ParsecT Text u m Char
forall a b. (a -> b) -> a -> b
$ ParsecT Text u m Char
forall s (m :: * -> *) st. Stream s m Char => ParserT s st m Char
space ParsecT Text u m Char
-> ParsecT Text u m Char -> ParsecT Text u m Char
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> ParsecT Text u m Char
forall (m :: * -> *) s. Monad m => ParserT Text s m Char
eof' ParsecT Text u m Char
-> ParsecT Text u m Char -> ParsecT Text u m Char
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|>
ParsecT Text u m Char -> ParsecT Text u m Char
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try ([Char] -> ParsecT Text u m Char
forall s (m :: * -> *) u.
Stream s m Char =>
[Char] -> ParsecT s u m Char
oneOf [Char]
"!.,;:" ParsecT Text u m Char
-> ParsecT Text u m Char -> ParsecT Text u m Char
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*>
(ParsecT Text u m Char
forall s (m :: * -> *) st. Stream s m Char => ParserT s st m Char
space ParsecT Text u m Char
-> ParsecT Text u m Char -> ParsecT Text u m Char
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> ParsecT Text u m Char
forall s (m :: * -> *) st. Stream s m Char => ParserT s st m Char
newline ParsecT Text u m Char
-> ParsecT Text u m Char -> ParsecT Text u m Char
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> ParsecT Text u m Char
forall (m :: * -> *) s. Monad m => ParserT Text s m Char
eof'))
Text
url <- [Char] -> Text
T.pack ([Char] -> Text)
-> ParsecT Text ParserState m [Char]
-> ParsecT Text ParserState m Text
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ParsecT Text ParserState m Char
-> ParsecT Text ParserState m Char
-> ParsecT Text ParserState m [Char]
forall end s (m :: * -> *) t st a.
(Show end, Stream s m t) =>
ParserT s st m a -> ParserT s st m end -> ParserT s st m [a]
many1Till ParsecT Text ParserState m Char
forall s (m :: * -> *) st. Stream s m Char => ParserT s st m Char
nonspaceChar ParsecT Text ParserState m Char
forall u. ParsecT Text u m Char
stop
let name' :: Inlines
name' = if Inlines -> [Inline]
forall a. Many a -> [a]
B.toList Inlines
name [Inline] -> [Inline] -> Bool
forall a. Eq a => a -> a -> Bool
== [Text -> Inline
Str Text
"$"] then Text -> Inlines
B.str Text
url else Inlines
name
Inlines -> ParserT Text ParserState m Inlines
forall (m :: * -> *) a. Monad m => a -> m a
return (Inlines -> ParserT Text ParserState m Inlines)
-> Inlines -> ParserT Text ParserState m Inlines
forall a b. (a -> b) -> a -> b
$ if Attr
attr Attr -> Attr -> Bool
forall a. Eq a => a -> a -> Bool
== Attr
nullAttr
then Text -> Text -> Inlines -> Inlines
B.link Text
url Text
"" Inlines
name'
else Attr -> Inlines -> Inlines
B.spanWith Attr
attr (Inlines -> Inlines) -> Inlines -> Inlines
forall a b. (a -> b) -> a -> b
$ Text -> Text -> Inlines -> Inlines
B.link Text
url Text
"" Inlines
name'
image :: PandocMonad m => ParserT Text ParserState m Inlines
image :: ParserT Text ParserState m Inlines
image = ParserT Text ParserState m Inlines
-> ParserT Text ParserState m Inlines
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try (ParserT Text ParserState m Inlines
-> ParserT Text ParserState m Inlines)
-> ParserT Text ParserState m Inlines
-> ParserT Text ParserState m Inlines
forall a b. (a -> b) -> a -> b
$ do
Char -> ParsecT Text ParserState m Char
forall s (m :: * -> *) u.
Stream s m Char =>
Char -> ParsecT s u m Char
char Char
'!' ParsecT Text ParserState m Char
-> ParsecT Text ParserState m () -> ParsecT Text ParserState m ()
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> ParsecT Text ParserState m Char -> ParsecT Text ParserState m ()
forall s (m :: * -> *) t a u.
(Stream s m t, Show a) =>
ParsecT s u m a -> ParsecT s u m ()
notFollowedBy ParsecT Text ParserState m Char
forall s (m :: * -> *) st. Stream s m Char => ParserT s st m Char
space
(Text
ident, [Text]
cls, NoteTable
kvs) <- ParserT Text ParserState m Attr
forall (m :: * -> *).
PandocMonad m =>
ParserT Text ParserState m Attr
attributes
let attr :: Attr
attr = case Text -> NoteTable -> Maybe Text
forall a b. Eq a => a -> [(a, b)] -> Maybe b
lookup Text
"style" NoteTable
kvs of
Just Text
stls -> (Text
ident, [Text]
cls, [Text] -> Text -> NoteTable
pickStylesToKVs [Text
"width", Text
"height"] Text
stls)
Maybe Text
Nothing -> (Text
ident, [Text]
cls, NoteTable
kvs)
Text
src <- [Char] -> Text
T.pack ([Char] -> Text)
-> ParsecT Text ParserState m [Char]
-> ParsecT Text ParserState m Text
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ParsecT Text ParserState m Char
-> ParsecT Text ParserState m [Char]
forall s (m :: * -> *) t u a.
Stream s m t =>
ParsecT s u m a -> ParsecT s u m [a]
many1 ([Char] -> ParsecT Text ParserState m Char
forall s (m :: * -> *) u.
Stream s m Char =>
[Char] -> ParsecT s u m Char
noneOf [Char]
" \t\n\r!(")
Text
alt <- ([Char] -> Text)
-> ParsecT Text ParserState m [Char]
-> ParsecT Text ParserState m Text
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap [Char] -> Text
T.pack (ParsecT Text ParserState m [Char]
-> ParsecT Text ParserState m Text)
-> ParsecT Text ParserState m [Char]
-> ParsecT Text ParserState m Text
forall a b. (a -> b) -> a -> b
$ [Char]
-> ParsecT Text ParserState m [Char]
-> ParsecT Text ParserState m [Char]
forall s (m :: * -> *) t a u.
Stream s m t =>
a -> ParsecT s u m a -> ParsecT s u m a
option [Char]
"" (ParsecT Text ParserState m [Char]
-> ParsecT Text ParserState m [Char])
-> ParsecT Text ParserState m [Char]
-> ParsecT Text ParserState m [Char]
forall a b. (a -> b) -> a -> b
$ ParsecT Text ParserState m [Char]
-> ParsecT Text ParserState m [Char]
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try (ParsecT Text ParserState m [Char]
-> ParsecT Text ParserState m [Char])
-> ParsecT Text ParserState m [Char]
-> ParsecT Text ParserState m [Char]
forall a b. (a -> b) -> a -> b
$ Char -> ParsecT Text ParserState m Char
forall s (m :: * -> *) u.
Stream s m Char =>
Char -> ParsecT s u m Char
char Char
'(' ParsecT Text ParserState m Char
-> ParsecT Text ParserState m [Char]
-> ParsecT Text ParserState m [Char]
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> ParsecT Text ParserState m Char
-> ParsecT Text ParserState m Char
-> ParsecT Text ParserState m [Char]
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 Text ParserState m Char
forall s (m :: * -> *) st. Stream s m Char => ParserT s st m Char
anyChar (Char -> ParsecT Text ParserState m Char
forall s (m :: * -> *) u.
Stream s m Char =>
Char -> ParsecT s u m Char
char Char
')')
Char -> ParsecT Text ParserState m Char
forall s (m :: * -> *) u.
Stream s m Char =>
Char -> ParsecT s u m Char
char Char
'!'
Inlines -> ParserT Text ParserState m Inlines
forall (m :: * -> *) a. Monad m => a -> m a
return (Inlines -> ParserT Text ParserState m Inlines)
-> Inlines -> ParserT Text ParserState m Inlines
forall a b. (a -> b) -> a -> b
$ Attr -> Text -> Text -> Inlines -> Inlines
B.imageWith Attr
attr Text
src Text
alt (Text -> Inlines
B.str Text
alt)
escapedInline :: PandocMonad m => ParserT Text ParserState m Inlines
escapedInline :: ParserT Text ParserState m Inlines
escapedInline = ParserT Text ParserState m Inlines
forall (m :: * -> *).
PandocMonad m =>
ParserT Text ParserState m Inlines
escapedEqs ParserT Text ParserState m Inlines
-> ParserT Text ParserState m Inlines
-> ParserT Text ParserState m Inlines
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> ParserT Text ParserState m Inlines
forall (m :: * -> *).
PandocMonad m =>
ParserT Text ParserState m Inlines
escapedTag
escapedEqs :: PandocMonad m => ParserT Text ParserState m Inlines
escapedEqs :: ParserT Text ParserState m Inlines
escapedEqs = Text -> Inlines
B.str (Text -> Inlines) -> ([Char] -> Text) -> [Char] -> Inlines
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [Char] -> Text
T.pack ([Char] -> Inlines)
-> ParsecT Text ParserState m [Char]
-> ParserT Text ParserState m Inlines
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$>
ParsecT Text ParserState m [Char]
-> ParsecT Text ParserState m [Char]
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try ([Char] -> ParsecT Text ParserState m [Char]
forall s (m :: * -> *) u.
Stream s m Char =>
[Char] -> ParsecT s u m [Char]
string [Char]
"==" ParsecT Text ParserState m [Char]
-> ParsecT Text ParserState m [Char]
-> ParsecT Text ParserState m [Char]
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> ParsecT Text ParserState m Char
-> ParsecT Text ParserState m [Char]
-> ParsecT Text ParserState m [Char]
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 Text ParserState m Char
forall (m :: * -> *).
PandocMonad m =>
ParserT Text ParserState m Char
anyChar' (ParsecT Text ParserState m [Char]
-> ParsecT Text ParserState m [Char]
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try (ParsecT Text ParserState m [Char]
-> ParsecT Text ParserState m [Char])
-> ParsecT Text ParserState m [Char]
-> ParsecT Text ParserState m [Char]
forall a b. (a -> b) -> a -> b
$ [Char] -> ParsecT Text ParserState m [Char]
forall s (m :: * -> *) u.
Stream s m Char =>
[Char] -> ParsecT s u m [Char]
string [Char]
"=="))
escapedTag :: PandocMonad m => ParserT Text ParserState m Inlines
escapedTag :: ParserT Text ParserState m Inlines
escapedTag = Text -> Inlines
B.str (Text -> Inlines) -> ([Char] -> Text) -> [Char] -> Inlines
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [Char] -> Text
T.pack ([Char] -> Inlines)
-> ParsecT Text ParserState m [Char]
-> ParserT Text ParserState m Inlines
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$>
ParsecT Text ParserState m [Char]
-> ParsecT Text ParserState m [Char]
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try ([Char] -> ParsecT Text ParserState m [Char]
forall s (m :: * -> *) u.
Stream s m Char =>
[Char] -> ParsecT s u m [Char]
string [Char]
"<notextile>" ParsecT Text ParserState m [Char]
-> ParsecT Text ParserState m [Char]
-> ParsecT Text ParserState m [Char]
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*>
ParsecT Text ParserState m Char
-> ParsecT Text ParserState m [Char]
-> ParsecT Text ParserState m [Char]
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 Text ParserState m Char
forall (m :: * -> *).
PandocMonad m =>
ParserT Text ParserState m Char
anyChar' (ParsecT Text ParserState m [Char]
-> ParsecT Text ParserState m [Char]
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try (ParsecT Text ParserState m [Char]
-> ParsecT Text ParserState m [Char])
-> ParsecT Text ParserState m [Char]
-> ParsecT Text ParserState m [Char]
forall a b. (a -> b) -> a -> b
$ [Char] -> ParsecT Text ParserState m [Char]
forall s (m :: * -> *) u.
Stream s m Char =>
[Char] -> ParsecT s u m [Char]
string [Char]
"</notextile>"))
symbol :: PandocMonad m => ParserT Text ParserState m Inlines
symbol :: ParserT Text ParserState m Inlines
symbol = Text -> Inlines
B.str (Text -> Inlines) -> (Char -> Text) -> Char -> Inlines
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Char -> Text
T.singleton (Char -> Inlines)
-> ParsecT Text ParserState m Char
-> ParserT Text ParserState m Inlines
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (ParsecT Text ParserState m Char -> ParsecT Text ParserState m ()
forall s (m :: * -> *) t a u.
(Stream s m t, Show a) =>
ParsecT s u m a -> ParsecT s u m ()
notFollowedBy ParsecT Text ParserState m Char
forall s (m :: * -> *) st. Stream s m Char => ParserT s st m Char
newline ParsecT Text ParserState m ()
-> ParsecT Text ParserState m () -> ParsecT Text ParserState m ()
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*>
ParsecT Text ParserState m (Many Block)
-> ParsecT Text ParserState m ()
forall s (m :: * -> *) t a u.
(Stream s m t, Show a) =>
ParsecT s u m a -> ParsecT s u m ()
notFollowedBy ParsecT Text ParserState m (Many Block)
forall (m :: * -> *).
PandocMonad m =>
ParserT Text ParserState m (Many Block)
rawHtmlBlock ParsecT Text ParserState m ()
-> ParsecT Text ParserState m Char
-> ParsecT Text ParserState m Char
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*>
[Char] -> ParsecT Text ParserState m Char
forall s (m :: * -> *) u.
Stream s m Char =>
[Char] -> ParsecT s u m Char
oneOf [Char]
wordBoundaries)
code :: PandocMonad m => ParserT Text ParserState m Inlines
code :: ParserT Text ParserState m Inlines
code = ParserT Text ParserState m Inlines
forall (m :: * -> *).
PandocMonad m =>
ParserT Text ParserState m Inlines
code1 ParserT Text ParserState m Inlines
-> ParserT Text ParserState m Inlines
-> ParserT Text ParserState m Inlines
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> ParserT Text ParserState m Inlines
forall (m :: * -> *).
PandocMonad m =>
ParserT Text ParserState m Inlines
code2
anyChar' :: PandocMonad m => ParserT Text ParserState m Char
anyChar' :: ParserT Text ParserState m Char
anyChar' =
(Char -> Bool) -> ParserT Text ParserState m Char
forall s (m :: * -> *) u.
Stream s m Char =>
(Char -> Bool) -> ParsecT s u m Char
satisfy (Char -> Char -> Bool
forall a. Eq a => a -> a -> Bool
/=Char
'\n') ParserT Text ParserState m Char
-> ParserT Text ParserState m Char
-> ParserT Text ParserState m Char
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|>
ParserT Text ParserState m Char -> ParserT Text ParserState m Char
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try (Char -> ParserT Text ParserState m Char
forall s (m :: * -> *) u.
Stream s m Char =>
Char -> ParsecT s u m Char
char Char
'\n' ParserT Text ParserState m Char
-> ParsecT Text ParserState m () -> ParserT Text ParserState m Char
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
<* ParserT Text ParserState m Char -> ParsecT Text ParserState m ()
forall s (m :: * -> *) t a u.
(Stream s m t, Show a) =>
ParsecT s u m a -> ParsecT s u m ()
notFollowedBy ParserT Text ParserState m Char
forall s (m :: * -> *) st. Stream s m Char => ParserT s st m Char
blankline)
code1 :: PandocMonad m => ParserT Text ParserState m Inlines
code1 :: ParserT Text ParserState m Inlines
code1 = Text -> Inlines
B.code (Text -> Inlines) -> ([Char] -> Text) -> [Char] -> Inlines
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [Char] -> Text
T.pack ([Char] -> Inlines)
-> ParsecT Text ParserState m [Char]
-> ParserT Text ParserState m Inlines
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ParserT Text ParserState m Char
-> ParserT Text ParserState m Char
-> ParsecT Text ParserState m [Char]
forall (m :: * -> *) t st a.
(PandocMonad m, Show t) =>
ParserT Text st m t -> ParserT Text st m a -> ParserT Text st m [a]
surrounded (Char -> ParserT Text ParserState m Char
forall s (m :: * -> *) u.
Stream s m Char =>
Char -> ParsecT s u m Char
char Char
'@') ParserT Text ParserState m Char
forall (m :: * -> *).
PandocMonad m =>
ParserT Text ParserState m Char
anyChar'
code2 :: PandocMonad m => ParserT Text ParserState m Inlines
code2 :: ParserT Text ParserState m Inlines
code2 = do
(Tag Text -> Bool) -> ParserT Text ParserState m (Tag Text, Text)
forall st (m :: * -> *).
(HasReaderOptions st, Monad m) =>
(Tag Text -> Bool) -> ParserT Text st m (Tag Text, Text)
htmlTag ((Text -> Bool) -> (NoteTable -> Bool) -> Tag Text -> Bool
forall str.
(str -> Bool) -> ([Attribute str] -> Bool) -> Tag str -> Bool
tagOpen (Text -> Text -> Bool
forall a. Eq a => a -> a -> Bool
==Text
"tt") NoteTable -> Bool
forall (t :: * -> *) a. Foldable t => t a -> Bool
null)
Text -> Inlines
B.code (Text -> Inlines) -> ([Char] -> Text) -> [Char] -> Inlines
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [Char] -> Text
T.pack ([Char] -> Inlines)
-> ParsecT Text ParserState m [Char]
-> ParserT Text ParserState m Inlines
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ParsecT Text ParserState m Char
-> ParserT Text ParserState m (Tag Text, Text)
-> ParsecT Text ParserState m [Char]
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 Text ParserState m Char
forall (m :: * -> *).
PandocMonad m =>
ParserT Text ParserState m Char
anyChar' (ParserT Text ParserState m (Tag Text, Text)
-> ParserT Text ParserState m (Tag Text, Text)
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try (ParserT Text ParserState m (Tag Text, Text)
-> ParserT Text ParserState m (Tag Text, Text))
-> ParserT Text ParserState m (Tag Text, Text)
-> ParserT Text ParserState m (Tag Text, Text)
forall a b. (a -> b) -> a -> b
$ (Tag Text -> Bool) -> ParserT Text ParserState m (Tag Text, Text)
forall st (m :: * -> *).
(HasReaderOptions st, Monad m) =>
(Tag Text -> Bool) -> ParserT Text st m (Tag Text, Text)
htmlTag ((Tag Text -> Bool) -> ParserT Text ParserState m (Tag Text, Text))
-> (Tag Text -> Bool)
-> ParserT Text ParserState m (Tag Text, Text)
forall a b. (a -> b) -> a -> b
$ (Text -> Bool) -> Tag Text -> Bool
forall str. (str -> Bool) -> Tag str -> Bool
tagClose (Text -> Text -> Bool
forall a. Eq a => a -> a -> Bool
==Text
"tt"))
attributes :: PandocMonad m => ParserT Text ParserState m Attr
attributes :: ParserT Text ParserState m Attr
attributes = (Attr -> (Attr -> Attr) -> Attr) -> Attr -> [Attr -> Attr] -> Attr
forall (t :: * -> *) b a.
Foldable t =>
(b -> a -> b) -> b -> t a -> b
foldl (((Attr -> Attr) -> Attr -> Attr) -> Attr -> (Attr -> Attr) -> Attr
forall a b c. (a -> b -> c) -> b -> a -> c
flip (Attr -> Attr) -> Attr -> Attr
forall a b. (a -> b) -> a -> b
($)) (Text
"",[],[]) ([Attr -> Attr] -> Attr)
-> ParsecT Text ParserState m [Attr -> Attr]
-> ParserT Text ParserState m Attr
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$>
ParsecT Text ParserState m [Attr -> Attr]
-> ParsecT Text ParserState m [Attr -> Attr]
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try (do Attr -> Attr
special <- (Attr -> Attr)
-> ParsecT Text ParserState m (Attr -> Attr)
-> ParsecT Text ParserState m (Attr -> Attr)
forall s (m :: * -> *) t a u.
Stream s m t =>
a -> ParsecT s u m a -> ParsecT s u m a
option Attr -> Attr
forall a. a -> a
id ParsecT Text ParserState m (Attr -> Attr)
forall (m :: * -> *).
PandocMonad m =>
ParserT Text ParserState m (Attr -> Attr)
specialAttribute
[Attr -> Attr]
attrs <- ParsecT Text ParserState m (Attr -> Attr)
-> ParsecT Text ParserState m [Attr -> Attr]
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m [a]
many ParsecT Text ParserState m (Attr -> Attr)
forall (m :: * -> *).
PandocMonad m =>
ParserT Text ParserState m (Attr -> Attr)
attribute
[Attr -> Attr] -> ParsecT Text ParserState m [Attr -> Attr]
forall (m :: * -> *) a. Monad m => a -> m a
return (Attr -> Attr
special (Attr -> Attr) -> [Attr -> Attr] -> [Attr -> Attr]
forall a. a -> [a] -> [a]
: [Attr -> Attr]
attrs))
specialAttribute :: PandocMonad m => ParserT Text ParserState m (Attr -> Attr)
specialAttribute :: ParserT Text ParserState m (Attr -> Attr)
specialAttribute = do
[Char]
alignStr <- ([Char]
"center" [Char]
-> ParsecT Text ParserState m Char
-> ParsecT Text ParserState m [Char]
forall (f :: * -> *) a b. Functor f => a -> f b -> f a
<$ Char -> ParsecT Text ParserState m Char
forall s (m :: * -> *) u.
Stream s m Char =>
Char -> ParsecT s u m Char
char Char
'=') ParsecT Text ParserState m [Char]
-> ParsecT Text ParserState m [Char]
-> ParsecT Text ParserState m [Char]
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|>
([Char]
"justify" [Char]
-> ParsecT Text ParserState m [Char]
-> ParsecT Text ParserState m [Char]
forall (f :: * -> *) a b. Functor f => a -> f b -> f a
<$ ParsecT Text ParserState m [Char]
-> ParsecT Text ParserState m [Char]
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try ([Char] -> ParsecT Text ParserState m [Char]
forall s (m :: * -> *) u.
Stream s m Char =>
[Char] -> ParsecT s u m [Char]
string [Char]
"<>")) ParsecT Text ParserState m [Char]
-> ParsecT Text ParserState m [Char]
-> ParsecT Text ParserState m [Char]
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|>
([Char]
"right" [Char]
-> ParsecT Text ParserState m Char
-> ParsecT Text ParserState m [Char]
forall (f :: * -> *) a b. Functor f => a -> f b -> f a
<$ Char -> ParsecT Text ParserState m Char
forall s (m :: * -> *) u.
Stream s m Char =>
Char -> ParsecT s u m Char
char Char
'>') ParsecT Text ParserState m [Char]
-> ParsecT Text ParserState m [Char]
-> ParsecT Text ParserState m [Char]
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|>
([Char]
"left" [Char]
-> ParsecT Text ParserState m Char
-> ParsecT Text ParserState m [Char]
forall (f :: * -> *) a b. Functor f => a -> f b -> f a
<$ Char -> ParsecT Text ParserState m Char
forall s (m :: * -> *) u.
Stream s m Char =>
Char -> ParsecT s u m Char
char Char
'<')
ParsecT Text ParserState m Char -> ParsecT Text ParserState m ()
forall s (m :: * -> *) t a u.
(Stream s m t, Show a) =>
ParsecT s u m a -> ParsecT s u m ()
notFollowedBy ParsecT Text ParserState m Char
forall s (m :: * -> *) st. Stream s m Char => ParserT s st m Char
spaceChar
(Attr -> Attr) -> ParserT Text ParserState m (Attr -> Attr)
forall (m :: * -> *) a. Monad m => a -> m a
return ((Attr -> Attr) -> ParserT Text ParserState m (Attr -> Attr))
-> (Attr -> Attr) -> ParserT Text ParserState m (Attr -> Attr)
forall a b. (a -> b) -> a -> b
$ Text -> Attr -> Attr
addStyle (Text -> Attr -> Attr) -> Text -> Attr -> Attr
forall a b. (a -> b) -> a -> b
$ [Char] -> Text
T.pack ([Char] -> Text) -> [Char] -> Text
forall a b. (a -> b) -> a -> b
$ [Char]
"text-align:" [Char] -> [Char] -> [Char]
forall a. [a] -> [a] -> [a]
++ [Char]
alignStr
attribute :: PandocMonad m => ParserT Text ParserState m (Attr -> Attr)
attribute :: ParserT Text ParserState m (Attr -> Attr)
attribute = ParserT Text ParserState m (Attr -> Attr)
-> ParserT Text ParserState m (Attr -> Attr)
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try (ParserT Text ParserState m (Attr -> Attr)
-> ParserT Text ParserState m (Attr -> Attr))
-> ParserT Text ParserState m (Attr -> Attr)
-> ParserT Text ParserState m (Attr -> Attr)
forall a b. (a -> b) -> a -> b
$
(ParserT Text ParserState m (Attr -> Attr)
forall (m :: * -> *).
PandocMonad m =>
ParserT Text ParserState m (Attr -> Attr)
classIdAttr ParserT Text ParserState m (Attr -> Attr)
-> ParserT Text ParserState m (Attr -> Attr)
-> ParserT Text ParserState m (Attr -> Attr)
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> ParserT Text ParserState m (Attr -> Attr)
forall (m :: * -> *).
PandocMonad m =>
ParserT Text ParserState m (Attr -> Attr)
styleAttr ParserT Text ParserState m (Attr -> Attr)
-> ParserT Text ParserState m (Attr -> Attr)
-> ParserT Text ParserState m (Attr -> Attr)
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> ParserT Text ParserState m (Attr -> Attr)
forall (m :: * -> *).
PandocMonad m =>
ParserT Text ParserState m (Attr -> Attr)
langAttr) ParserT Text ParserState m (Attr -> Attr)
-> ParsecT Text ParserState m ()
-> ParserT Text ParserState m (Attr -> Attr)
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
<* ParsecT Text ParserState m Char -> ParsecT Text ParserState m ()
forall s (m :: * -> *) t a u.
(Stream s m t, Show a) =>
ParsecT s u m a -> ParsecT s u m ()
notFollowedBy ParsecT Text ParserState m Char
forall s (m :: * -> *) st. Stream s m Char => ParserT s st m Char
spaceChar
classIdAttr :: PandocMonad m => ParserT Text ParserState m (Attr -> Attr)
classIdAttr :: ParserT Text ParserState m (Attr -> Attr)
classIdAttr = ParserT Text ParserState m (Attr -> Attr)
-> ParserT Text ParserState m (Attr -> Attr)
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try (ParserT Text ParserState m (Attr -> Attr)
-> ParserT Text ParserState m (Attr -> Attr))
-> ParserT Text ParserState m (Attr -> Attr)
-> ParserT Text ParserState m (Attr -> Attr)
forall a b. (a -> b) -> a -> b
$ do
Char -> ParsecT Text ParserState m Char
forall s (m :: * -> *) u.
Stream s m Char =>
Char -> ParsecT s u m Char
char Char
'('
[Text]
ws <- Text -> [Text]
T.words (Text -> [Text]) -> ([Char] -> Text) -> [Char] -> [Text]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
`fmap` [Char] -> Text
T.pack ([Char] -> [Text])
-> ParsecT Text ParserState m [Char]
-> ParsecT Text ParserState m [Text]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ParsecT Text ParserState m Char
-> ParsecT Text ParserState m Char
-> ParsecT Text ParserState m [Char]
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 Text ParserState m Char
forall (m :: * -> *).
PandocMonad m =>
ParserT Text ParserState m Char
anyChar' (Char -> ParsecT Text ParserState m Char
forall s (m :: * -> *) u.
Stream s m Char =>
Char -> ParsecT s u m Char
char Char
')')
case [Text] -> [Text]
forall a. [a] -> [a]
reverse [Text]
ws of
[]
-> (Attr -> Attr) -> ParserT Text ParserState m (Attr -> Attr)
forall (m :: * -> *) a. Monad m => a -> m a
return ((Attr -> Attr) -> ParserT Text ParserState m (Attr -> Attr))
-> (Attr -> Attr) -> ParserT Text ParserState m (Attr -> Attr)
forall a b. (a -> b) -> a -> b
$ \(Text
_,[Text]
_,NoteTable
keyvals) -> (Text
"",[],NoteTable
keyvals)
((Text -> Maybe (Char, Text)
T.uncons -> Just (Char
'#', Text
ident')):[Text]
classes')
-> (Attr -> Attr) -> ParserT Text ParserState m (Attr -> Attr)
forall (m :: * -> *) a. Monad m => a -> m a
return ((Attr -> Attr) -> ParserT Text ParserState m (Attr -> Attr))
-> (Attr -> Attr) -> ParserT Text ParserState m (Attr -> Attr)
forall a b. (a -> b) -> a -> b
$ \(Text
_,[Text]
_,NoteTable
keyvals) -> (Text
ident',[Text]
classes',NoteTable
keyvals)
[Text]
classes'
-> (Attr -> Attr) -> ParserT Text ParserState m (Attr -> Attr)
forall (m :: * -> *) a. Monad m => a -> m a
return ((Attr -> Attr) -> ParserT Text ParserState m (Attr -> Attr))
-> (Attr -> Attr) -> ParserT Text ParserState m (Attr -> Attr)
forall a b. (a -> b) -> a -> b
$ \(Text
_,[Text]
_,NoteTable
keyvals) -> (Text
"",[Text]
classes',NoteTable
keyvals)
styleAttr :: PandocMonad m => ParserT Text ParserState m (Attr -> Attr)
styleAttr :: ParserT Text ParserState m (Attr -> Attr)
styleAttr = do
[Char]
style <- ParsecT Text ParserState m [Char]
-> ParsecT Text ParserState m [Char]
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try (ParsecT Text ParserState m [Char]
-> ParsecT Text ParserState m [Char])
-> ParsecT Text ParserState m [Char]
-> ParsecT Text ParserState m [Char]
forall a b. (a -> b) -> a -> b
$ ParserT Text ParserState m Char
-> ParserT Text ParserState m Char
-> ParserT Text ParserState m Char
-> ParsecT Text ParserState m [Char]
forall end s (m :: * -> *) st t a.
(Show end, Stream s m Char) =>
ParserT s st m t
-> ParserT s st m end -> ParserT s st m a -> ParserT s st m [a]
enclosed (Char -> ParserT Text ParserState m Char
forall s (m :: * -> *) u.
Stream s m Char =>
Char -> ParsecT s u m Char
char Char
'{') (Char -> ParserT Text ParserState m Char
forall s (m :: * -> *) u.
Stream s m Char =>
Char -> ParsecT s u m Char
char Char
'}') ParserT Text ParserState m Char
forall (m :: * -> *).
PandocMonad m =>
ParserT Text ParserState m Char
anyChar'
(Attr -> Attr) -> ParserT Text ParserState m (Attr -> Attr)
forall (m :: * -> *) a. Monad m => a -> m a
return ((Attr -> Attr) -> ParserT Text ParserState m (Attr -> Attr))
-> (Attr -> Attr) -> ParserT Text ParserState m (Attr -> Attr)
forall a b. (a -> b) -> a -> b
$ Text -> Attr -> Attr
addStyle (Text -> Attr -> Attr) -> Text -> Attr -> Attr
forall a b. (a -> b) -> a -> b
$ [Char] -> Text
T.pack [Char]
style
addStyle :: Text -> Attr -> Attr
addStyle :: Text -> Attr -> Attr
addStyle Text
style (Text
id',[Text]
classes,NoteTable
keyvals) =
(Text
id',[Text]
classes,NoteTable
keyvals')
where keyvals' :: NoteTable
keyvals' = (Text
"style", Text
style') (Text, Text) -> NoteTable -> NoteTable
forall a. a -> [a] -> [a]
: [(Text
k,Text
v) | (Text
k,Text
v) <- NoteTable
keyvals, Text
k Text -> Text -> Bool
forall a. Eq a => a -> a -> Bool
/= Text
"style"]
style' :: Text
style' = Text
style Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
";" Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> [Text] -> Text
T.concat [Text
v | (Text
"style",Text
v) <- NoteTable
keyvals]
langAttr :: PandocMonad m => ParserT Text ParserState m (Attr -> Attr)
langAttr :: ParserT Text ParserState m (Attr -> Attr)
langAttr = do
[Char]
lang <- ParsecT Text ParserState m [Char]
-> ParsecT Text ParserState m [Char]
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try (ParsecT Text ParserState m [Char]
-> ParsecT Text ParserState m [Char])
-> ParsecT Text ParserState m [Char]
-> ParsecT Text ParserState m [Char]
forall a b. (a -> b) -> a -> b
$ ParserT Text ParserState m Char
-> ParserT Text ParserState m Char
-> ParserT Text ParserState m Char
-> ParsecT Text ParserState m [Char]
forall end s (m :: * -> *) st t a.
(Show end, Stream s m Char) =>
ParserT s st m t
-> ParserT s st m end -> ParserT s st m a -> ParserT s st m [a]
enclosed (Char -> ParserT Text ParserState m Char
forall s (m :: * -> *) u.
Stream s m Char =>
Char -> ParsecT s u m Char
char Char
'[') (Char -> ParserT Text ParserState m Char
forall s (m :: * -> *) u.
Stream s m Char =>
Char -> ParsecT s u m Char
char Char
']') ParserT Text ParserState m Char
forall s (m :: * -> *) st. Stream s m Char => ParserT s st m Char
alphaNum
(Attr -> Attr) -> ParserT Text ParserState m (Attr -> Attr)
forall (m :: * -> *) a. Monad m => a -> m a
return ((Attr -> Attr) -> ParserT Text ParserState m (Attr -> Attr))
-> (Attr -> Attr) -> ParserT Text ParserState m (Attr -> Attr)
forall a b. (a -> b) -> a -> b
$ \(Text
id',[Text]
classes,NoteTable
keyvals) -> (Text
id',[Text]
classes,(Text
"lang",[Char] -> Text
T.pack [Char]
lang)(Text, Text) -> NoteTable -> NoteTable
forall a. a -> [a] -> [a]
:NoteTable
keyvals)
surrounded :: (PandocMonad m, Show t)
=> ParserT Text st m t
-> ParserT Text st m a
-> ParserT Text st m [a]
surrounded :: ParserT Text st m t -> ParserT Text st m a -> ParserT Text st m [a]
surrounded ParserT Text st m t
border =
ParserT Text st m ()
-> ParserT Text st m t
-> ParserT Text st m a
-> ParserT Text st m [a]
forall end s (m :: * -> *) st t a.
(Show end, Stream s m Char) =>
ParserT s st m t
-> ParserT s st m end -> ParserT s st m a -> ParserT s st m [a]
enclosed (ParserT Text st m t
border ParserT Text st m t -> ParserT Text st m () -> ParserT Text st m ()
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> ParsecT Text st m Char -> ParserT Text st m ()
forall s (m :: * -> *) t a u.
(Stream s m t, Show a) =>
ParsecT s u m a -> ParsecT s u m ()
notFollowedBy ([Char] -> ParsecT Text st m Char
forall s (m :: * -> *) u.
Stream s m Char =>
[Char] -> ParsecT s u m Char
oneOf [Char]
" \t\n\r")) (ParserT Text st m t -> ParserT Text st m t
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try ParserT Text st m t
border)
simpleInline :: PandocMonad m
=> ParserT Text ParserState m t
-> (Inlines -> Inlines)
-> ParserT Text ParserState m Inlines
simpleInline :: ParserT Text ParserState m t
-> (Inlines -> Inlines) -> ParserT Text ParserState m Inlines
simpleInline ParserT Text ParserState m t
border Inlines -> Inlines
construct = ParserT Text ParserState m Inlines
-> ParserT Text ParserState m Inlines
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try (ParserT Text ParserState m Inlines
-> ParserT Text ParserState m Inlines)
-> ParserT Text ParserState m Inlines
-> ParserT Text ParserState m Inlines
forall a b. (a -> b) -> a -> b
$ do
ParserT Text ParserState m Bool
forall s (m :: * -> *) a st.
(Stream s m a, HasLastStrPosition st) =>
ParserT s st m Bool
notAfterString
ParserT Text ParserState m t
border ParserT Text ParserState m t
-> ParsecT Text ParserState m () -> ParsecT Text ParserState m ()
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> ParsecT Text ParserState m Char -> ParsecT Text ParserState m ()
forall s (m :: * -> *) t a u.
(Stream s m t, Show a) =>
ParsecT s u m a -> ParsecT s u m ()
notFollowedBy ([Char] -> ParsecT Text ParserState m Char
forall s (m :: * -> *) u.
Stream s m Char =>
[Char] -> ParsecT s u m Char
oneOf [Char]
" \t\n\r")
Attr
attr <- ParserT Text ParserState m Attr
forall (m :: * -> *).
PandocMonad m =>
ParserT Text ParserState m Attr
attributes
Inlines
body <- Inlines -> Inlines
trimInlines (Inlines -> Inlines)
-> ([Inlines] -> Inlines) -> [Inlines] -> Inlines
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [Inlines] -> Inlines
forall a. Monoid a => [a] -> a
mconcat ([Inlines] -> Inlines)
-> ParsecT Text ParserState m [Inlines]
-> ParserT Text ParserState m Inlines
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$>
QuoteContext
-> ParsecT Text ParserState m [Inlines]
-> ParsecT Text ParserState m [Inlines]
forall st (m :: * -> *) s a.
HasQuoteContext st m =>
QuoteContext -> ParsecT s st m a -> ParsecT s st m a
withQuoteContext QuoteContext
InSingleQuote
(ParserT Text ParserState m Inlines
-> ParserT Text ParserState m t
-> ParsecT Text ParserState m [Inlines]
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 Text ParserState m Char -> ParsecT Text ParserState m ()
forall s (m :: * -> *) t a u.
(Stream s m t, Show a) =>
ParsecT s u m a -> ParsecT s u m ()
notFollowedBy ParsecT Text ParserState m Char
forall s (m :: * -> *) st. Stream s m Char => ParserT s st m Char
newline ParsecT Text ParserState m ()
-> ParserT Text ParserState m Inlines
-> ParserT Text ParserState m Inlines
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> ParserT Text ParserState m Inlines
forall (m :: * -> *).
PandocMonad m =>
ParserT Text ParserState m Inlines
inline)
(ParserT Text ParserState m t -> ParserT Text ParserState m t
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try ParserT Text ParserState m t
border ParserT Text ParserState m t
-> ParsecT Text ParserState m () -> ParserT Text ParserState m t
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
<* ParsecT Text ParserState m Char -> ParsecT Text ParserState m ()
forall s (m :: * -> *) t a u.
(Stream s m t, Show a) =>
ParsecT s u m a -> ParsecT s u m ()
notFollowedBy ParsecT Text ParserState m Char
forall s (m :: * -> *) st. Stream s m Char => ParserT s st m Char
alphaNum))
Inlines -> ParserT Text ParserState m Inlines
forall (m :: * -> *) a. Monad m => a -> m a
return (Inlines -> ParserT Text ParserState m Inlines)
-> Inlines -> ParserT Text ParserState m Inlines
forall a b. (a -> b) -> a -> b
$ Inlines -> Inlines
construct (Inlines -> Inlines) -> Inlines -> Inlines
forall a b. (a -> b) -> a -> b
$
if Attr
attr Attr -> Attr -> Bool
forall a. Eq a => a -> a -> Bool
== Attr
nullAttr
then Inlines
body
else Attr -> Inlines -> Inlines
B.spanWith Attr
attr Inlines
body
groupedInlineMarkup :: PandocMonad m => ParserT Text ParserState m Inlines
groupedInlineMarkup :: ParserT Text ParserState m Inlines
groupedInlineMarkup = ParserT Text ParserState m Inlines
-> ParserT Text ParserState m Inlines
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try (ParserT Text ParserState m Inlines
-> ParserT Text ParserState m Inlines)
-> ParserT Text ParserState m Inlines
-> ParserT Text ParserState m Inlines
forall a b. (a -> b) -> a -> b
$ do
Char -> ParsecT Text ParserState m Char
forall s (m :: * -> *) u.
Stream s m Char =>
Char -> ParsecT s u m Char
char Char
'['
Inlines
sp1 <- Inlines
-> ParserT Text ParserState m Inlines
-> ParserT Text ParserState m Inlines
forall s (m :: * -> *) t a u.
Stream s m t =>
a -> ParsecT s u m a -> ParsecT s u m a
option Inlines
forall a. Monoid a => a
mempty (ParserT Text ParserState m Inlines
-> ParserT Text ParserState m Inlines)
-> ParserT Text ParserState m Inlines
-> ParserT Text ParserState m Inlines
forall a b. (a -> b) -> a -> b
$ Inlines
B.space Inlines
-> ParserT Text ParserState m Inlines
-> ParserT Text ParserState m Inlines
forall (f :: * -> *) a b. Functor f => a -> f b -> f a
<$ ParserT Text ParserState m Inlines
forall (m :: * -> *) st. PandocMonad m => ParserT Text st m Inlines
whitespace
Inlines
result <- QuoteContext
-> ParserT Text ParserState m Inlines
-> ParserT Text ParserState m Inlines
forall st (m :: * -> *) s a.
HasQuoteContext st m =>
QuoteContext -> ParsecT s st m a -> ParsecT s st m a
withQuoteContext QuoteContext
InSingleQuote ParserT Text ParserState m Inlines
forall (m :: * -> *).
PandocMonad m =>
ParserT Text ParserState m Inlines
inlineMarkup
Inlines
sp2 <- Inlines
-> ParserT Text ParserState m Inlines
-> ParserT Text ParserState m Inlines
forall s (m :: * -> *) t a u.
Stream s m t =>
a -> ParsecT s u m a -> ParsecT s u m a
option Inlines
forall a. Monoid a => a
mempty (ParserT Text ParserState m Inlines
-> ParserT Text ParserState m Inlines)
-> ParserT Text ParserState m Inlines
-> ParserT Text ParserState m Inlines
forall a b. (a -> b) -> a -> b
$ Inlines
B.space Inlines
-> ParserT Text ParserState m Inlines
-> ParserT Text ParserState m Inlines
forall (f :: * -> *) a b. Functor f => a -> f b -> f a
<$ ParserT Text ParserState m Inlines
forall (m :: * -> *) st. PandocMonad m => ParserT Text st m Inlines
whitespace
Char -> ParsecT Text ParserState m Char
forall s (m :: * -> *) u.
Stream s m Char =>
Char -> ParsecT s u m Char
char Char
']'
Inlines -> ParserT Text ParserState m Inlines
forall (m :: * -> *) a. Monad m => a -> m a
return (Inlines -> ParserT Text ParserState m Inlines)
-> Inlines -> ParserT Text ParserState m Inlines
forall a b. (a -> b) -> a -> b
$ Inlines
sp1 Inlines -> Inlines -> Inlines
forall a. Semigroup a => a -> a -> a
<> Inlines
result Inlines -> Inlines -> Inlines
forall a. Semigroup a => a -> a -> a
<> Inlines
sp2
eof' :: Monad m => ParserT Text s m Char
eof' :: ParserT Text s m Char
eof' = Char
'\n' Char -> ParsecT Text s m () -> ParserT Text s m Char
forall (f :: * -> *) a b. Functor f => a -> f b -> f a
<$ ParsecT Text s m ()
forall s (m :: * -> *) t u.
(Stream s m t, Show t) =>
ParsecT s u m ()
eof