{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE CPP #-}
module Text.Pandoc.Readers.Vimwiki ( readVimwiki
) where
import Control.Monad (guard)
import Control.Monad.Except (throwError)
import Data.Default
import Data.List (isInfixOf)
import Data.Maybe
import Data.Text (Text)
import qualified Data.Text as T
import Safe (lastMay)
import Text.Pandoc.Builder (Blocks, Inlines, fromList, toList, trimInlines)
import qualified Text.Pandoc.Builder as B
import Text.Pandoc.Class.PandocMonad (PandocMonad (..))
import Text.Pandoc.Definition (Attr, Block (BulletList, OrderedList),
Inline (Space), ListNumberDelim (..),
ListNumberStyle (..), Pandoc (..),
nullMeta)
import Text.Pandoc.Options (ReaderOptions)
import Text.Pandoc.Parsing (ParserState, ParsecT, blanklines, emailAddress,
many1Till, orderedListMarker, readWithM,
registerHeader, spaceChar, stateMeta,
stateOptions, uri, manyTillChar, manyChar, textStr,
many1Char, countChar, many1TillChar,
alphaNum, anyChar, char, newline, noneOf, oneOf,
space, spaces, string, choice, eof, lookAhead,
many1, many, manyTill, notFollowedBy,
skipMany1, try, option,
updateState, getState, (<|>))
import Text.Pandoc.Sources (ToSources(..), Sources)
import Text.Pandoc.Shared (splitTextBy, stringify, stripFirstAndLast, tshow)
import Text.Pandoc.URI (isURI)
readVimwiki :: (PandocMonad m, ToSources a)
=> ReaderOptions
-> a
-> m Pandoc
readVimwiki :: forall (m :: * -> *) a.
(PandocMonad m, ToSources a) =>
ReaderOptions -> a -> m Pandoc
readVimwiki ReaderOptions
opts a
s = do
let sources :: Sources
sources = a -> Sources
forall a. ToSources a => a -> Sources
toSources a
s
res <- ParsecT Sources ParserState m Pandoc
-> ParserState -> Sources -> m (Either PandocError Pandoc)
forall (m :: * -> *) t st a.
(Monad m, ToSources t) =>
ParsecT Sources st m a -> st -> t -> m (Either PandocError a)
readWithM ParsecT Sources ParserState m Pandoc
forall (m :: * -> *). PandocMonad m => VwParser m Pandoc
parseVimwiki ParserState
forall a. Default a => a
def{ stateOptions = opts } Sources
sources
case res of
Left PandocError
e -> PandocError -> m Pandoc
forall a. PandocError -> m a
forall e (m :: * -> *) a. MonadError e m => e -> m a
throwError PandocError
e
Right Pandoc
result -> Pandoc -> m Pandoc
forall a. a -> m a
forall (m :: * -> *) a. Monad m => a -> m a
return Pandoc
result
type VwParser = ParsecT Sources ParserState
specialChars :: [Char]
specialChars :: [Char]
specialChars = [Char]
"=*-#[]_~{}`$|:%^,"
spaceChars :: [Char]
spaceChars :: [Char]
spaceChars = [Char]
" \t\n"
parseVimwiki :: PandocMonad m => VwParser m Pandoc
parseVimwiki :: forall (m :: * -> *). PandocMonad m => VwParser m Pandoc
parseVimwiki = do
bs <- [Blocks] -> Blocks
forall a. Monoid a => [a] -> a
mconcat ([Blocks] -> Blocks)
-> ParsecT Sources ParserState m [Blocks]
-> ParsecT Sources ParserState m Blocks
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ParsecT Sources ParserState m Blocks
-> ParsecT Sources ParserState m [Blocks]
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m [a]
many ParsecT Sources ParserState m Blocks
forall (m :: * -> *). PandocMonad m => VwParser m Blocks
block
spaces
eof
st <- getState
let meta = ParserState -> Meta
stateMeta ParserState
st
return $ Pandoc meta (toList bs)
block :: PandocMonad m => VwParser m Blocks
block :: forall (m :: * -> *). PandocMonad m => VwParser m Blocks
block = do
res <- [ParsecT Sources ParserState m Blocks]
-> ParsecT Sources ParserState m Blocks
forall s (m :: * -> *) t u a.
Stream s m t =>
[ParsecT s u m a] -> ParsecT s u m a
choice [ Blocks
forall a. Monoid a => a
mempty Blocks
-> ParsecT Sources ParserState m Text
-> ParsecT Sources ParserState m Blocks
forall a b.
a
-> ParsecT Sources ParserState m b
-> ParsecT Sources ParserState m a
forall (f :: * -> *) a b. Functor f => a -> f b -> f a
<$ ParsecT Sources ParserState m Text
forall s (m :: * -> *) st.
(Stream s m Char, UpdateSourcePos s Char) =>
ParsecT s st m Text
blanklines
, ParsecT Sources ParserState m Blocks
forall (m :: * -> *). PandocMonad m => VwParser m Blocks
header
, ParsecT Sources ParserState m Blocks
forall (m :: * -> *). PandocMonad m => VwParser m Blocks
hrule
, Blocks
forall a. Monoid a => a
mempty Blocks
-> ParsecT Sources ParserState m ()
-> ParsecT Sources ParserState m Blocks
forall a b.
a
-> ParsecT Sources ParserState m b
-> ParsecT Sources ParserState m a
forall (f :: * -> *) a b. Functor f => a -> f b -> f a
<$ ParsecT Sources ParserState m ()
forall (m :: * -> *). PandocMonad m => VwParser m ()
comment
, ParsecT Sources ParserState m Blocks
forall (m :: * -> *). PandocMonad m => VwParser m Blocks
mixedList
, ParsecT Sources ParserState m Blocks
forall (m :: * -> *). PandocMonad m => VwParser m Blocks
preformatted
, ParsecT Sources ParserState m Blocks
forall (m :: * -> *). PandocMonad m => VwParser m Blocks
displayMath
, ParsecT Sources ParserState m Blocks
forall (m :: * -> *). PandocMonad m => VwParser m Blocks
table
, Blocks
forall a. Monoid a => a
mempty Blocks
-> ParsecT Sources ParserState m ()
-> ParsecT Sources ParserState m Blocks
forall a b.
a
-> ParsecT Sources ParserState m b
-> ParsecT Sources ParserState m a
forall (f :: * -> *) a b. Functor f => a -> f b -> f a
<$ ParsecT Sources ParserState m ()
forall (m :: * -> *). PandocMonad m => VwParser m ()
placeholder
, ParsecT Sources ParserState m Blocks
forall (m :: * -> *). PandocMonad m => VwParser m Blocks
blockQuote
, ParsecT Sources ParserState m Blocks
forall (m :: * -> *). PandocMonad m => VwParser m Blocks
definitionList
, ParsecT Sources ParserState m Blocks
forall (m :: * -> *). PandocMonad m => VwParser m Blocks
para
]
trace (T.take 60 $ tshow $ toList res)
return res
blockML :: PandocMonad m => VwParser m Blocks
blockML :: forall (m :: * -> *). PandocMonad m => VwParser m Blocks
blockML = [ParsecT Sources ParserState m Blocks]
-> ParsecT Sources ParserState m Blocks
forall s (m :: * -> *) t u a.
Stream s m t =>
[ParsecT s u m a] -> ParsecT s u m a
choice [ParsecT Sources ParserState m Blocks
forall (m :: * -> *). PandocMonad m => VwParser m Blocks
preformatted, ParsecT Sources ParserState m Blocks
forall (m :: * -> *). PandocMonad m => VwParser m Blocks
displayMath, ParsecT Sources ParserState m Blocks
forall (m :: * -> *). PandocMonad m => VwParser m Blocks
table]
header :: PandocMonad m => VwParser m Blocks
= ParsecT Sources ParserState m Blocks
-> ParsecT Sources ParserState m Blocks
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try (ParsecT Sources ParserState m Blocks
-> ParsecT Sources ParserState m Blocks)
-> ParsecT Sources ParserState m Blocks
-> ParsecT Sources ParserState m Blocks
forall a b. (a -> b) -> a -> b
$ do
sp <- ParsecT Sources ParserState m Char
-> ParsecT Sources ParserState m [Char]
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m [a]
many ParsecT Sources ParserState m Char
forall s (m :: * -> *) st.
(Stream s m Char, UpdateSourcePos s Char) =>
ParsecT s st m Char
spaceChar
eqs <- many1 (char '=')
spaceChar
let lev = [Char] -> Int
forall a. [a] -> Int
forall (t :: * -> *) a. Foldable t => t a -> Int
length [Char]
eqs
guard $ lev <= 6
contents <- trimInlines . mconcat <$> manyTill inline (try $ spaceChar
>> string eqs >> many spaceChar >> newline)
attr <- registerHeader (makeId contents,
["justcenter" | not (null sp)], []) contents
return $ B.headerWith attr lev contents
para :: PandocMonad m => VwParser m Blocks
para :: forall (m :: * -> *). PandocMonad m => VwParser m Blocks
para = ParsecT Sources ParserState m Blocks
-> ParsecT Sources ParserState m Blocks
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try (ParsecT Sources ParserState m Blocks
-> ParsecT Sources ParserState m Blocks)
-> ParsecT Sources ParserState m Blocks
-> ParsecT Sources ParserState m Blocks
forall a b. (a -> b) -> a -> b
$ do
contents <- Many Inline -> Many Inline
trimInlines (Many Inline -> Many Inline)
-> ([Many Inline] -> Many Inline) -> [Many Inline] -> Many Inline
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [Many Inline] -> Many Inline
forall a. Monoid a => [a] -> a
mconcat ([Many Inline] -> Many Inline)
-> ParsecT Sources ParserState m [Many Inline]
-> ParsecT Sources ParserState m (Many Inline)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ParsecT Sources ParserState m (Many Inline)
-> ParsecT Sources ParserState m [Many Inline]
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m [a]
many1 ParsecT Sources ParserState m (Many Inline)
forall (m :: * -> *). PandocMonad m => VwParser m (Many Inline)
inline
if all (==Space) (toList contents)
then return mempty
else return $ B.para contents
hrule :: PandocMonad m => VwParser m Blocks
hrule :: forall (m :: * -> *). PandocMonad m => VwParser m Blocks
hrule = ParsecT Sources ParserState m Blocks
-> ParsecT Sources ParserState m Blocks
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try (ParsecT Sources ParserState m Blocks
-> ParsecT Sources ParserState m Blocks)
-> ParsecT Sources ParserState m Blocks
-> ParsecT Sources ParserState m Blocks
forall a b. (a -> b) -> a -> b
$ Blocks
B.horizontalRule Blocks
-> ParsecT Sources ParserState m Char
-> ParsecT Sources ParserState m Blocks
forall a b.
a
-> ParsecT Sources ParserState m b
-> ParsecT Sources ParserState m a
forall (f :: * -> *) a b. Functor f => a -> f b -> f a
<$ ([Char] -> ParsecT Sources ParserState m [Char]
forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
[Char] -> ParsecT s u m [Char]
string [Char]
"----" ParsecT Sources ParserState m [Char]
-> ParsecT Sources ParserState m [Char]
-> ParsecT Sources ParserState m [Char]
forall a b.
ParsecT Sources ParserState m a
-> ParsecT Sources ParserState m b
-> ParsecT Sources ParserState m b
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> ParsecT Sources ParserState m Char
-> ParsecT Sources ParserState m [Char]
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m [a]
many (Char -> ParsecT Sources ParserState m Char
forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
Char -> ParsecT s u m Char
char Char
'-') ParsecT Sources ParserState m [Char]
-> ParsecT Sources ParserState m Char
-> ParsecT Sources ParserState m Char
forall a b.
ParsecT Sources ParserState m a
-> ParsecT Sources ParserState m b
-> ParsecT Sources ParserState m b
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> ParsecT Sources ParserState m Char
forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
ParsecT s u m Char
newline)
comment :: PandocMonad m => VwParser m ()
= ParsecT Sources ParserState m ()
-> ParsecT Sources ParserState m ()
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try (ParsecT Sources ParserState m ()
-> ParsecT Sources ParserState m ())
-> ParsecT Sources ParserState m ()
-> ParsecT Sources ParserState m ()
forall a b. (a -> b) -> a -> b
$ do
ParsecT Sources ParserState m Char
-> ParsecT Sources ParserState m [Char]
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m [a]
many ParsecT Sources ParserState m Char
forall s (m :: * -> *) st.
(Stream s m Char, UpdateSourcePos s Char) =>
ParsecT s st m Char
spaceChar ParsecT Sources ParserState m [Char]
-> ParsecT Sources ParserState m [Char]
-> ParsecT Sources ParserState m [Char]
forall a b.
ParsecT Sources ParserState m a
-> ParsecT Sources ParserState m b
-> ParsecT Sources ParserState m b
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> [Char] -> ParsecT Sources ParserState m [Char]
forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
[Char] -> ParsecT s u m [Char]
string [Char]
"%%" ParsecT Sources ParserState m [Char]
-> ParsecT Sources ParserState m [Char]
-> ParsecT Sources ParserState m [Char]
forall a b.
ParsecT Sources ParserState m a
-> ParsecT Sources ParserState m b
-> ParsecT Sources ParserState m b
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> ParsecT Sources ParserState m Char
-> ParsecT Sources ParserState m [Char]
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m [a]
many ([Char] -> ParsecT Sources ParserState m Char
forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
[Char] -> ParsecT s u m Char
noneOf [Char]
"\n")
() -> ParsecT Sources ParserState m ()
forall a. a -> ParsecT Sources ParserState m a
forall (m :: * -> *) a. Monad m => a -> m a
return ()
blockQuote :: PandocMonad m => VwParser m Blocks
blockQuote :: forall (m :: * -> *). PandocMonad m => VwParser m Blocks
blockQuote = ParsecT Sources ParserState m Blocks
-> ParsecT Sources ParserState m Blocks
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try (ParsecT Sources ParserState m Blocks
-> ParsecT Sources ParserState m Blocks)
-> ParsecT Sources ParserState m Blocks
-> ParsecT Sources ParserState m Blocks
forall a b. (a -> b) -> a -> b
$ do
[Char] -> ParsecT Sources ParserState m [Char]
forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
[Char] -> ParsecT s u m [Char]
string [Char]
" "
contents <- Many Inline -> Many Inline
trimInlines (Many Inline -> Many Inline)
-> ([Many Inline] -> Many Inline) -> [Many Inline] -> Many Inline
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [Many Inline] -> Many Inline
forall a. Monoid a => [a] -> a
mconcat ([Many Inline] -> Many Inline)
-> ParsecT Sources ParserState m [Many Inline]
-> ParsecT Sources ParserState m (Many Inline)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ParsecT Sources ParserState m (Many Inline)
-> ParsecT Sources ParserState m [Many Inline]
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m [a]
many1 ParsecT Sources ParserState m (Many Inline)
forall (m :: * -> *). PandocMonad m => VwParser m (Many Inline)
inlineBQ
if all (==Space) (toList contents)
then return mempty
else return $ B.blockQuote $ B.plain contents
definitionList :: PandocMonad m => VwParser m Blocks
definitionList :: forall (m :: * -> *). PandocMonad m => VwParser m Blocks
definitionList = ParsecT Sources ParserState m Blocks
-> ParsecT Sources ParserState m Blocks
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try (ParsecT Sources ParserState m Blocks
-> ParsecT Sources ParserState m Blocks)
-> ParsecT Sources ParserState m Blocks
-> ParsecT Sources ParserState m Blocks
forall a b. (a -> b) -> a -> b
$
[(Many Inline, [Blocks])] -> Blocks
B.definitionList ([(Many Inline, [Blocks])] -> Blocks)
-> ParsecT Sources ParserState m [(Many Inline, [Blocks])]
-> ParsecT Sources ParserState m Blocks
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ParsecT Sources ParserState m (Many Inline, [Blocks])
-> ParsecT Sources ParserState m [(Many Inline, [Blocks])]
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m [a]
many1 (ParsecT Sources ParserState m (Many Inline, [Blocks])
forall (m :: * -> *).
PandocMonad m =>
VwParser m (Many Inline, [Blocks])
dlItemWithDT ParsecT Sources ParserState m (Many Inline, [Blocks])
-> ParsecT Sources ParserState m (Many Inline, [Blocks])
-> ParsecT Sources ParserState m (Many Inline, [Blocks])
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> ParsecT Sources ParserState m (Many Inline, [Blocks])
forall (m :: * -> *).
PandocMonad m =>
VwParser m (Many Inline, [Blocks])
dlItemWithoutDT)
dlItemWithDT :: PandocMonad m => VwParser m (Inlines, [Blocks])
dlItemWithDT :: forall (m :: * -> *).
PandocMonad m =>
VwParser m (Many Inline, [Blocks])
dlItemWithDT = do
dt <- VwParser m (Many Inline)
forall (m :: * -> *). PandocMonad m => VwParser m (Many Inline)
definitionTerm
dds <- many definitionDef
return (dt, dds)
dlItemWithoutDT :: PandocMonad m => VwParser m (Inlines, [Blocks])
dlItemWithoutDT :: forall (m :: * -> *).
PandocMonad m =>
VwParser m (Many Inline, [Blocks])
dlItemWithoutDT = do
dds <- ParsecT Sources ParserState m Blocks
-> ParsecT Sources ParserState m [Blocks]
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m [a]
many1 ParsecT Sources ParserState m Blocks
forall (m :: * -> *). PandocMonad m => VwParser m Blocks
definitionDef
return (mempty, dds)
definitionDef :: PandocMonad m => VwParser m Blocks
definitionDef :: forall (m :: * -> *). PandocMonad m => VwParser m Blocks
definitionDef = ParsecT Sources ParserState m Blocks
-> ParsecT Sources ParserState m Blocks
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try (ParsecT Sources ParserState m Blocks
-> ParsecT Sources ParserState m Blocks)
-> ParsecT Sources ParserState m Blocks
-> ParsecT Sources ParserState m Blocks
forall a b. (a -> b) -> a -> b
$
ParsecT Sources ParserState m (Many Inline)
-> ParsecT Sources 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 Sources ParserState m (Many Inline)
forall (m :: * -> *). PandocMonad m => VwParser m (Many Inline)
definitionTerm ParsecT Sources ParserState m ()
-> ParsecT Sources ParserState m [Char]
-> ParsecT Sources ParserState m [Char]
forall a b.
ParsecT Sources ParserState m a
-> ParsecT Sources ParserState m b
-> ParsecT Sources ParserState m b
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> ParsecT Sources ParserState m Char
-> ParsecT Sources ParserState m [Char]
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m [a]
many ParsecT Sources ParserState m Char
forall s (m :: * -> *) st.
(Stream s m Char, UpdateSourcePos s Char) =>
ParsecT s st m Char
spaceChar
ParsecT Sources ParserState m [Char]
-> ParsecT Sources ParserState m Blocks
-> ParsecT Sources ParserState m Blocks
forall a b.
ParsecT Sources ParserState m a
-> ParsecT Sources ParserState m b
-> ParsecT Sources ParserState m b
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> (ParsecT Sources ParserState m Blocks
forall (m :: * -> *). PandocMonad m => VwParser m Blocks
definitionDef1 ParsecT Sources ParserState m Blocks
-> ParsecT Sources ParserState m Blocks
-> ParsecT Sources ParserState m Blocks
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> ParsecT Sources ParserState m Blocks
forall (m :: * -> *). PandocMonad m => VwParser m Blocks
definitionDef2)
definitionDef1 :: PandocMonad m => VwParser m Blocks
definitionDef1 :: forall (m :: * -> *). PandocMonad m => VwParser m Blocks
definitionDef1 = ParsecT Sources ParserState m Blocks
-> ParsecT Sources ParserState m Blocks
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try (ParsecT Sources ParserState m Blocks
-> ParsecT Sources ParserState m Blocks)
-> ParsecT Sources ParserState m Blocks
-> ParsecT Sources ParserState m Blocks
forall a b. (a -> b) -> a -> b
$ Blocks
forall a. Monoid a => a
mempty Blocks
-> ParsecT Sources ParserState m Char
-> ParsecT Sources ParserState m Blocks
forall a b.
a
-> ParsecT Sources ParserState m b
-> ParsecT Sources ParserState m a
forall (f :: * -> *) a b. Functor f => a -> f b -> f a
<$ ParsecT Sources ParserState m Char
forall (m :: * -> *). PandocMonad m => VwParser m Char
defMarkerE
definitionDef2 :: PandocMonad m => VwParser m Blocks
definitionDef2 :: forall (m :: * -> *). PandocMonad m => VwParser m Blocks
definitionDef2 = ParsecT Sources ParserState m Blocks
-> ParsecT Sources ParserState m Blocks
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try (ParsecT Sources ParserState m Blocks
-> ParsecT Sources ParserState m Blocks)
-> ParsecT Sources ParserState m Blocks
-> ParsecT Sources ParserState m Blocks
forall a b. (a -> b) -> a -> b
$ Many Inline -> Blocks
B.plain (Many Inline -> Blocks)
-> ParsecT Sources ParserState m (Many Inline)
-> ParsecT Sources ParserState m Blocks
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$>
(VwParser m Char
forall (m :: * -> *). PandocMonad m => VwParser m Char
defMarkerM VwParser m Char
-> ParsecT Sources ParserState m (Many Inline)
-> ParsecT Sources ParserState m (Many Inline)
forall a b.
ParsecT Sources ParserState m a
-> ParsecT Sources ParserState m b
-> ParsecT Sources ParserState m b
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> (Many Inline -> Many Inline
trimInlines (Many Inline -> Many Inline)
-> ([Many Inline] -> Many Inline) -> [Many Inline] -> Many Inline
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [Many Inline] -> Many Inline
forall a. Monoid a => [a] -> a
mconcat ([Many Inline] -> Many Inline)
-> ParsecT Sources ParserState m [Many Inline]
-> ParsecT Sources ParserState m (Many Inline)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ParsecT Sources ParserState m (Many Inline)
-> ParsecT Sources ParserState m [Many Inline]
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m [a]
many ParsecT Sources ParserState m (Many Inline)
forall (m :: * -> *). PandocMonad m => VwParser m (Many Inline)
inline') ParsecT Sources ParserState m (Many Inline)
-> VwParser m Char -> ParsecT Sources ParserState m (Many Inline)
forall a b.
ParsecT Sources ParserState m a
-> ParsecT Sources ParserState m b
-> ParsecT Sources ParserState m a
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
<* VwParser m Char
forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
ParsecT s u m Char
newline)
definitionTerm :: PandocMonad m => VwParser m Inlines
definitionTerm :: forall (m :: * -> *). PandocMonad m => VwParser m (Many Inline)
definitionTerm = ParsecT Sources ParserState m (Many Inline)
-> ParsecT Sources ParserState m (Many Inline)
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try (ParsecT Sources ParserState m (Many Inline)
-> ParsecT Sources ParserState m (Many Inline))
-> ParsecT Sources ParserState m (Many Inline)
-> ParsecT Sources ParserState m (Many Inline)
forall a b. (a -> b) -> a -> b
$ do
x <- ParsecT Sources ParserState m (Many Inline)
forall (m :: * -> *). PandocMonad m => VwParser m (Many Inline)
definitionTerm1 ParsecT Sources ParserState m (Many Inline)
-> ParsecT Sources ParserState m (Many Inline)
-> ParsecT Sources ParserState m (Many Inline)
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> ParsecT Sources ParserState m (Many Inline)
forall (m :: * -> *). PandocMonad m => VwParser m (Many Inline)
definitionTerm2
guard (stringify x /= "")
return x
definitionTerm1 :: PandocMonad m => VwParser m Inlines
definitionTerm1 :: forall (m :: * -> *). PandocMonad m => VwParser m (Many Inline)
definitionTerm1 = ParsecT Sources ParserState m (Many Inline)
-> ParsecT Sources ParserState m (Many Inline)
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try (ParsecT Sources ParserState m (Many Inline)
-> ParsecT Sources ParserState m (Many Inline))
-> ParsecT Sources ParserState m (Many Inline)
-> ParsecT Sources ParserState m (Many Inline)
forall a b. (a -> b) -> a -> b
$
Many Inline -> Many Inline
trimInlines (Many Inline -> Many Inline)
-> ([Many Inline] -> Many Inline) -> [Many Inline] -> Many Inline
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [Many Inline] -> Many Inline
forall a. Monoid a => [a] -> a
mconcat ([Many Inline] -> Many Inline)
-> ParsecT Sources ParserState m [Many Inline]
-> ParsecT Sources ParserState m (Many Inline)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ParsecT Sources ParserState m (Many Inline)
-> ParsecT Sources ParserState m Char
-> ParsecT Sources ParserState m [Many Inline]
forall s (m :: * -> *) t u a end.
Stream s m t =>
ParsecT s u m a -> ParsecT s u m end -> ParsecT s u m [a]
manyTill ParsecT Sources ParserState m (Many Inline)
forall (m :: * -> *). PandocMonad m => VwParser m (Many Inline)
inline' (ParsecT Sources ParserState m Char
-> ParsecT Sources ParserState m Char
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try ParsecT Sources ParserState m Char
forall (m :: * -> *). PandocMonad m => VwParser m Char
defMarkerE)
definitionTerm2 :: PandocMonad m => VwParser m Inlines
definitionTerm2 :: forall (m :: * -> *). PandocMonad m => VwParser m (Many Inline)
definitionTerm2 = ParsecT Sources ParserState m (Many Inline)
-> ParsecT Sources ParserState m (Many Inline)
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try (ParsecT Sources ParserState m (Many Inline)
-> ParsecT Sources ParserState m (Many Inline))
-> ParsecT Sources ParserState m (Many Inline)
-> ParsecT Sources ParserState m (Many Inline)
forall a b. (a -> b) -> a -> b
$ Many Inline -> Many Inline
trimInlines (Many Inline -> Many Inline)
-> ([Many Inline] -> Many Inline) -> [Many Inline] -> Many Inline
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [Many Inline] -> Many Inline
forall a. Monoid a => [a] -> a
mconcat ([Many Inline] -> Many Inline)
-> ParsecT Sources ParserState m [Many Inline]
-> ParsecT Sources ParserState m (Many Inline)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ParsecT Sources ParserState m (Many Inline)
-> ParsecT Sources ParserState m ()
-> ParsecT Sources ParserState m [Many Inline]
forall s (m :: * -> *) t u a end.
Stream s m t =>
ParsecT s u m a -> ParsecT s u m end -> ParsecT s u m [a]
manyTill ParsecT Sources ParserState m (Many Inline)
forall (m :: * -> *). PandocMonad m => VwParser m (Many Inline)
inline'
(ParsecT Sources ParserState m ()
-> ParsecT Sources ParserState m ()
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try (ParsecT Sources ParserState m ()
-> ParsecT Sources ParserState m ())
-> ParsecT Sources ParserState m ()
-> ParsecT Sources ParserState m ()
forall a b. (a -> b) -> a -> b
$ ParsecT Sources ParserState m ()
-> ParsecT Sources ParserState m ()
forall s (m :: * -> *) t u a.
Stream s m t =>
ParsecT s u m a -> ParsecT s u m a
lookAhead (VwParser m Char
forall (m :: * -> *). PandocMonad m => VwParser m Char
defMarkerM VwParser m Char
-> ParsecT Sources ParserState m ()
-> ParsecT Sources ParserState m ()
forall a b.
ParsecT Sources ParserState m a
-> ParsecT Sources ParserState m b
-> ParsecT Sources ParserState m b
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> ParsecT Sources ParserState m Text
-> ParsecT Sources 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 Sources ParserState m Text
forall (m :: * -> *). PandocMonad m => VwParser m Text
hasDefMarkerM))
defMarkerM :: PandocMonad m => VwParser m Char
defMarkerM :: forall (m :: * -> *). PandocMonad m => VwParser m Char
defMarkerM = [Char] -> ParsecT Sources ParserState m [Char]
forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
[Char] -> ParsecT s u m [Char]
string [Char]
"::" ParsecT Sources ParserState m [Char]
-> ParsecT Sources ParserState m Char
-> ParsecT Sources ParserState m Char
forall a b.
ParsecT Sources ParserState m a
-> ParsecT Sources ParserState m b
-> ParsecT Sources ParserState m b
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> ParsecT Sources ParserState m Char
forall s (m :: * -> *) st.
(Stream s m Char, UpdateSourcePos s Char) =>
ParsecT s st m Char
spaceChar
defMarkerE :: PandocMonad m => VwParser m Char
defMarkerE :: forall (m :: * -> *). PandocMonad m => VwParser m Char
defMarkerE = [Char] -> ParsecT Sources ParserState m [Char]
forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
[Char] -> ParsecT s u m [Char]
string [Char]
"::" ParsecT Sources ParserState m [Char]
-> ParsecT Sources ParserState m Char
-> ParsecT Sources ParserState m Char
forall a b.
ParsecT Sources ParserState m a
-> ParsecT Sources ParserState m b
-> ParsecT Sources ParserState m b
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> ParsecT Sources ParserState m Char
forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
ParsecT s u m Char
newline
hasDefMarkerM :: PandocMonad m => VwParser m Text
hasDefMarkerM :: forall (m :: * -> *). PandocMonad m => VwParser m Text
hasDefMarkerM = ParsecT Sources ParserState m Char
-> ParsecT Sources ParserState m Char
-> ParsecT Sources ParserState m Text
forall s (m :: * -> *) t st a.
Stream s m t =>
ParsecT s st m Char -> ParsecT s st m a -> ParsecT s st m Text
manyTillChar ([Char] -> ParsecT Sources ParserState m Char
forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
[Char] -> ParsecT s u m Char
noneOf [Char]
"\n") (ParsecT Sources ParserState m Char
-> ParsecT Sources ParserState m Char
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try ParsecT Sources ParserState m Char
forall (m :: * -> *). PandocMonad m => VwParser m Char
defMarkerM)
preformatted :: PandocMonad m => VwParser m Blocks
preformatted :: forall (m :: * -> *). PandocMonad m => VwParser m Blocks
preformatted = ParsecT Sources ParserState m Blocks
-> ParsecT Sources ParserState m Blocks
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try (ParsecT Sources ParserState m Blocks
-> ParsecT Sources ParserState m Blocks)
-> ParsecT Sources ParserState m Blocks
-> ParsecT Sources ParserState m Blocks
forall a b. (a -> b) -> a -> b
$ do
ParsecT Sources ParserState m Char
-> ParsecT Sources ParserState m [Char]
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m [a]
many ParsecT Sources ParserState m Char
forall s (m :: * -> *) st.
(Stream s m Char, UpdateSourcePos s Char) =>
ParsecT s st m Char
spaceChar ParsecT Sources ParserState m [Char]
-> ParsecT Sources ParserState m [Char]
-> ParsecT Sources ParserState m [Char]
forall a b.
ParsecT Sources ParserState m a
-> ParsecT Sources ParserState m b
-> ParsecT Sources ParserState m b
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> [Char] -> ParsecT Sources ParserState m [Char]
forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
[Char] -> ParsecT s u m [Char]
string [Char]
"{{{"
attrText <- ParsecT Sources ParserState m Char
-> ParsecT Sources ParserState m Text
forall s (m :: * -> *) t st.
Stream s m t =>
ParsecT s st m Char -> ParsecT s st m Text
manyChar ([Char] -> ParsecT Sources ParserState m Char
forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
[Char] -> ParsecT s u m Char
noneOf [Char]
"\n")
lookAhead newline
contents <- manyTillChar anyChar (try (char '\n' >> many spaceChar >> string "}}}"
>> many spaceChar >> newline))
if (contents /= "") && (T.head contents == '\n')
then return $ B.codeBlockWith (makeAttr attrText) (T.tail contents)
else return $ B.codeBlockWith (makeAttr attrText) contents
makeAttr :: Text -> Attr
makeAttr :: Text -> Attr
makeAttr Text
s =
let xs :: [Text]
xs = (Char -> Bool) -> Text -> [Text]
splitTextBy (Char -> [Char] -> Bool
forall a. Eq a => a -> [a] -> Bool
forall (t :: * -> *) a. (Foldable t, Eq a) => a -> t a -> Bool
`elem` ([Char]
" \t" :: String)) Text
s in
(Text
"", [Text] -> [Text]
syntax [Text]
xs, (Text -> Maybe (Text, Text)) -> [Text] -> [(Text, Text)]
forall a b. (a -> Maybe b) -> [a] -> [b]
mapMaybe Text -> Maybe (Text, Text)
nameValue [Text]
xs)
syntax :: [Text] -> [Text]
syntax :: [Text] -> [Text]
syntax (Text
s:[Text]
_) | Bool -> Bool
not (Bool -> Bool) -> Bool -> Bool
forall a b. (a -> b) -> a -> b
$ Text -> Text -> Bool
T.isInfixOf Text
"=" Text
s = [Text
s]
syntax [Text]
_ = []
nameValue :: Text -> Maybe (Text, Text)
nameValue :: Text -> Maybe (Text, Text)
nameValue Text
s =
case (Char -> Bool) -> Text -> [Text]
splitTextBy (Char -> Char -> Bool
forall a. Eq a => a -> a -> Bool
== Char
'=') Text
s of
[Text
a,Text
b]
| Text -> Int
T.length Text
b Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
>= Int
2
, Text
"\"" Text -> Text -> Bool
`T.isPrefixOf` Text
b
, Text
"\"" Text -> Text -> Bool
`T.isSuffixOf` Text
b
-> (Text, Text) -> Maybe (Text, Text)
forall a. a -> Maybe a
Just (Text
a, Text -> Text
stripFirstAndLast Text
b)
[Text]
_ -> Maybe (Text, Text)
forall a. Maybe a
Nothing
displayMath :: PandocMonad m => VwParser m Blocks
displayMath :: forall (m :: * -> *). PandocMonad m => VwParser m Blocks
displayMath = ParsecT Sources ParserState m Blocks
-> ParsecT Sources ParserState m Blocks
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try (ParsecT Sources ParserState m Blocks
-> ParsecT Sources ParserState m Blocks)
-> ParsecT Sources ParserState m Blocks
-> ParsecT Sources ParserState m Blocks
forall a b. (a -> b) -> a -> b
$ do
ParsecT Sources ParserState m Char
-> ParsecT Sources ParserState m [Char]
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m [a]
many ParsecT Sources ParserState m Char
forall s (m :: * -> *) st.
(Stream s m Char, UpdateSourcePos s Char) =>
ParsecT s st m Char
spaceChar ParsecT Sources ParserState m [Char]
-> ParsecT Sources ParserState m [Char]
-> ParsecT Sources ParserState m [Char]
forall a b.
ParsecT Sources ParserState m a
-> ParsecT Sources ParserState m b
-> ParsecT Sources ParserState m b
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> [Char] -> ParsecT Sources ParserState m [Char]
forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
[Char] -> ParsecT s u m [Char]
string [Char]
"{{$"
mathTag <- Text
-> ParsecT Sources ParserState m Text
-> ParsecT Sources 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
"" ParsecT Sources ParserState m Text
forall (m :: * -> *). PandocMonad m => VwParser m Text
mathTagParser
many space
contents <- manyTillChar anyChar (try (char '\n' >> many spaceChar >> string "}}$"
>> many spaceChar >> newline))
let contentsWithTags
| Text
mathTag Text -> Text -> Bool
forall a. Eq a => a -> a -> Bool
== Text
"" = Text
contents
| Bool
otherwise = Text
"\\begin{" Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
mathTag Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
"}\n" Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
contents
Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
"\n\\end{" Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
mathTag Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
"}"
return $ B.para $ B.displayMath contentsWithTags
mathTagLaTeX :: Text -> Text
mathTagLaTeX :: Text -> Text
mathTagLaTeX Text
s = case Text
s of
Text
"equation" -> Text
""
Text
"equation*" -> Text
""
Text
"gather" -> Text
"gathered"
Text
"gather*" -> Text
"gathered"
Text
"multline" -> Text
"gathered"
Text
"multline*" -> Text
"gathered"
Text
"eqnarray" -> Text
"aligned"
Text
"eqnarray*" -> Text
"aligned"
Text
"align" -> Text
"aligned"
Text
"align*" -> Text
"aligned"
Text
"alignat" -> Text
"aligned"
Text
"alignat*" -> Text
"aligned"
Text
_ -> Text
s
mixedList :: PandocMonad m => VwParser m Blocks
mixedList :: forall (m :: * -> *). PandocMonad m => VwParser m Blocks
mixedList = ParsecT Sources ParserState m Blocks
-> ParsecT Sources ParserState m Blocks
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try (ParsecT Sources ParserState m Blocks
-> ParsecT Sources ParserState m Blocks)
-> ParsecT Sources ParserState m Blocks
-> ParsecT Sources ParserState m Blocks
forall a b. (a -> b) -> a -> b
$ do
((bl:_), _) <- Int -> VwParser m ([Blocks], Int)
forall (m :: * -> *).
PandocMonad m =>
Int -> VwParser m ([Blocks], Int)
mixedList' (-Int
1)
return bl
mixedList' :: PandocMonad m => Int -> VwParser m ([Blocks], Int)
mixedList' :: forall (m :: * -> *).
PandocMonad m =>
Int -> VwParser m ([Blocks], Int)
mixedList' Int
prevInd = do
(curInd, builder) <- (Int, Text)
-> ParsecT Sources ParserState m (Int, Text)
-> ParsecT Sources ParserState m (Int, Text)
forall s (m :: * -> *) t a u.
Stream s m t =>
a -> ParsecT s u m a -> ParsecT s u m a
option (-Int
1, Text
"na") (ParsecT Sources ParserState m (Int, Text)
-> ParsecT Sources ParserState m (Int, Text)
forall s (m :: * -> *) t u a.
Stream s m t =>
ParsecT s u m a -> ParsecT s u m a
lookAhead ParsecT Sources ParserState m (Int, Text)
forall (m :: * -> *). PandocMonad m => VwParser m (Int, Text)
listStart)
if curInd < prevInd
then return ([], curInd)
else do
listStart
curLine <- listItemContent
let listBuilder =
if Text
builder Text -> Text -> Bool
forall a. Eq a => a -> a -> Bool
== Text
"ul" then [Blocks] -> Blocks
B.bulletList else [Blocks] -> Blocks
B.orderedList
(subList, lowInd) <- mixedList' curInd
if lowInd >= curInd
then do
(sameIndList, endInd) <- mixedList' lowInd
let curList = Blocks -> [Blocks] -> [Blocks]
combineList Blocks
curLine [Blocks]
subList [Blocks] -> [Blocks] -> [Blocks]
forall a. [a] -> [a] -> [a]
++ [Blocks]
sameIndList
if curInd > prevInd
then return ([listBuilder curList], endInd)
else return (curList, endInd)
else do
let (curList, endInd) = (combineList curLine subList,
lowInd)
if curInd > prevInd
then return ([listBuilder curList], endInd)
else return (curList, endInd)
plainInlineML' :: PandocMonad m => Inlines -> VwParser m Blocks
plainInlineML' :: forall (m :: * -> *).
PandocMonad m =>
Many Inline -> VwParser m Blocks
plainInlineML' Many Inline
w = do
xs <- ParsecT Sources ParserState m (Many Inline)
-> ParsecT Sources ParserState m [Many Inline]
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m [a]
many ParsecT Sources ParserState m (Many Inline)
forall (m :: * -> *). PandocMonad m => VwParser m (Many Inline)
inlineML
newline
return $ B.plain $ trimInlines $ mconcat $ w:xs
plainInlineML :: PandocMonad m => VwParser m Blocks
plainInlineML :: forall (m :: * -> *). PandocMonad m => VwParser m Blocks
plainInlineML = ParsecT Sources ParserState m (Int, Text)
-> ParsecT Sources 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 Sources ParserState m (Int, Text)
forall (m :: * -> *). PandocMonad m => VwParser m (Int, Text)
listStart ParsecT Sources ParserState m ()
-> ParsecT Sources ParserState m Char
-> ParsecT Sources ParserState m Char
forall a b.
ParsecT Sources ParserState m a
-> ParsecT Sources ParserState m b
-> ParsecT Sources ParserState m b
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> ParsecT Sources ParserState m Char
forall s (m :: * -> *) st.
(Stream s m Char, UpdateSourcePos s Char) =>
ParsecT s st m Char
spaceChar ParsecT Sources ParserState m Char
-> ParsecT Sources ParserState m Blocks
-> ParsecT Sources ParserState m Blocks
forall a b.
ParsecT Sources ParserState m a
-> ParsecT Sources ParserState m b
-> ParsecT Sources ParserState m b
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> Many Inline -> ParsecT Sources ParserState m Blocks
forall (m :: * -> *).
PandocMonad m =>
Many Inline -> VwParser m Blocks
plainInlineML' Many Inline
forall a. Monoid a => a
mempty
listItemContent :: PandocMonad m => VwParser m Blocks
listItemContent :: forall (m :: * -> *). PandocMonad m => VwParser m Blocks
listItemContent = ParsecT Sources ParserState m Blocks
-> ParsecT Sources ParserState m Blocks
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try (ParsecT Sources ParserState m Blocks
-> ParsecT Sources ParserState m Blocks)
-> ParsecT Sources ParserState m Blocks
-> ParsecT Sources ParserState m Blocks
forall a b. (a -> b) -> a -> b
$ do
w <- Many Inline
-> ParsecT Sources ParserState m (Many Inline)
-> ParsecT Sources ParserState m (Many Inline)
forall s (m :: * -> *) t a u.
Stream s m t =>
a -> ParsecT s u m a -> ParsecT s u m a
option Many Inline
forall a. Monoid a => a
mempty ParsecT Sources ParserState m (Many Inline)
forall (m :: * -> *). PandocMonad m => VwParser m (Many Inline)
listTodoMarker
x <- plainInlineML' w
y <- many blocksThenInline
z <- many blockML
return $ mconcat $ x:y ++ z
blocksThenInline :: PandocMonad m => VwParser m Blocks
blocksThenInline :: forall (m :: * -> *). PandocMonad m => VwParser m Blocks
blocksThenInline = ParsecT Sources ParserState m Blocks
-> ParsecT Sources ParserState m Blocks
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try (ParsecT Sources ParserState m Blocks
-> ParsecT Sources ParserState m Blocks)
-> ParsecT Sources ParserState m Blocks
-> ParsecT Sources ParserState m Blocks
forall a b. (a -> b) -> a -> b
$ do
y <- ParsecT Sources ParserState m Blocks
-> ParsecT Sources ParserState m [Blocks]
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m [a]
many1 ParsecT Sources ParserState m Blocks
forall (m :: * -> *). PandocMonad m => VwParser m Blocks
blockML
x <- plainInlineML
return $ mconcat $ y ++ [x]
listTodoMarker :: PandocMonad m => VwParser m Inlines
listTodoMarker :: forall (m :: * -> *). PandocMonad m => VwParser m (Many Inline)
listTodoMarker = ParsecT Sources ParserState m (Many Inline)
-> ParsecT Sources ParserState m (Many Inline)
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try (ParsecT Sources ParserState m (Many Inline)
-> ParsecT Sources ParserState m (Many Inline))
-> ParsecT Sources ParserState m (Many Inline)
-> ParsecT Sources ParserState m (Many Inline)
forall a b. (a -> b) -> a -> b
$ do
x <- (ParsecT Sources ParserState m Char
-> ParsecT Sources ParserState m [Char]
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m [a]
many ParsecT Sources ParserState m Char
forall s (m :: * -> *) st.
(Stream s m Char, UpdateSourcePos s Char) =>
ParsecT s st m Char
spaceChar ParsecT Sources ParserState m [Char]
-> ParsecT Sources ParserState m Char
-> ParsecT Sources ParserState m Char
forall a b.
ParsecT Sources ParserState m a
-> ParsecT Sources ParserState m b
-> ParsecT Sources ParserState m b
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> Char -> ParsecT Sources ParserState m Char
forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
Char -> ParsecT s u m Char
char Char
'[')
ParsecT Sources ParserState m Char
-> ParsecT Sources ParserState m Char
-> ParsecT Sources ParserState m Char
forall a b.
ParsecT Sources ParserState m a
-> ParsecT Sources ParserState m b
-> ParsecT Sources ParserState m b
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> [Char] -> ParsecT Sources ParserState m Char
forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
[Char] -> ParsecT s u m Char
oneOf [Char]
" .oOX"
ParsecT Sources ParserState m Char
-> ParsecT Sources ParserState m Char
-> ParsecT Sources ParserState m Char
forall a b.
ParsecT Sources ParserState m a
-> ParsecT Sources ParserState m b
-> ParsecT Sources ParserState m a
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
<* (Char -> ParsecT Sources ParserState m Char
forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
Char -> ParsecT s u m Char
char Char
']' ParsecT Sources ParserState m Char
-> ParsecT Sources ParserState m Char
-> ParsecT Sources ParserState m Char
forall a b.
ParsecT Sources ParserState m a
-> ParsecT Sources ParserState m b
-> ParsecT Sources ParserState m b
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> ParsecT Sources ParserState m Char
forall s (m :: * -> *) st.
(Stream s m Char, UpdateSourcePos s Char) =>
ParsecT s st m Char
spaceChar)
return $ makeListMarkerSpan x
makeListMarkerSpan :: Char -> Inlines
makeListMarkerSpan :: Char -> Many Inline
makeListMarkerSpan Char
x =
let cl :: Text
cl = case Char
x of
Char
' ' -> Text
"done0"
Char
'.' -> Text
"done1"
Char
'o' -> Text
"done2"
Char
'O' -> Text
"done3"
Char
'X' -> Text
"done4"
Char
_ -> Text
""
in
Attr -> Many Inline -> Many Inline
B.spanWith (Text
"", [Text
cl], []) Many Inline
forall a. Monoid a => a
mempty
combineList :: Blocks -> [Blocks] -> [Blocks]
combineList :: Blocks -> [Blocks] -> [Blocks]
combineList Blocks
x [Blocks
y] = case Blocks -> [Block]
forall a. Many a -> [a]
toList Blocks
y of
[BulletList [[Block]]
z] -> [[Block] -> Blocks
forall a. [a] -> Many a
fromList ([Block] -> Blocks) -> [Block] -> Blocks
forall a b. (a -> b) -> a -> b
$ Blocks -> [Block]
forall a. Many a -> [a]
toList Blocks
x
[Block] -> [Block] -> [Block]
forall a. [a] -> [a] -> [a]
++ [[[Block]] -> Block
BulletList [[Block]]
z]]
[OrderedList ListAttributes
attr [[Block]]
z] -> [[Block] -> Blocks
forall a. [a] -> Many a
fromList ([Block] -> Blocks) -> [Block] -> Blocks
forall a b. (a -> b) -> a -> b
$ Blocks -> [Block]
forall a. Many a -> [a]
toList Blocks
x
[Block] -> [Block] -> [Block]
forall a. [a] -> [a] -> [a]
++ [ListAttributes -> [[Block]] -> Block
OrderedList ListAttributes
attr [[Block]]
z]]
[Block]
_ -> Blocks
xBlocks -> [Blocks] -> [Blocks]
forall a. a -> [a] -> [a]
:[Blocks
y]
combineList Blocks
x [Blocks]
xs = Blocks
xBlocks -> [Blocks] -> [Blocks]
forall a. a -> [a] -> [a]
:[Blocks]
xs
listStart :: PandocMonad m => VwParser m (Int, Text)
listStart :: forall (m :: * -> *). PandocMonad m => VwParser m (Int, Text)
listStart = ParsecT Sources ParserState m (Int, Text)
-> ParsecT Sources ParserState m (Int, Text)
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try (ParsecT Sources ParserState m (Int, Text)
-> ParsecT Sources ParserState m (Int, Text))
-> ParsecT Sources ParserState m (Int, Text)
-> ParsecT Sources ParserState m (Int, Text)
forall a b. (a -> b) -> a -> b
$ do
s <- ParsecT Sources ParserState m Char
-> ParsecT Sources ParserState m [Char]
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m [a]
many ParsecT Sources ParserState m Char
forall s (m :: * -> *) st.
(Stream s m Char, UpdateSourcePos s Char) =>
ParsecT s st m Char
spaceChar
listType <- bulletListMarkers <|> orderedListMarkers
spaceChar
return (length s, listType)
bulletListMarkers :: PandocMonad m => VwParser m Text
bulletListMarkers :: forall (m :: * -> *). PandocMonad m => VwParser m Text
bulletListMarkers = Text
"ul" Text
-> ParsecT Sources ParserState m Char
-> ParsecT Sources ParserState m Text
forall a b.
a
-> ParsecT Sources ParserState m b
-> ParsecT Sources ParserState m a
forall (f :: * -> *) a b. Functor f => a -> f b -> f a
<$ (Char -> ParsecT Sources ParserState m Char
forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
Char -> ParsecT s u m Char
char Char
'*' ParsecT Sources ParserState m Char
-> ParsecT Sources ParserState m Char
-> ParsecT Sources ParserState m Char
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> Char -> ParsecT Sources ParserState m Char
forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
Char -> ParsecT s u m Char
char Char
'-')
orderedListMarkers :: PandocMonad m => VwParser m Text
orderedListMarkers :: forall (m :: * -> *). PandocMonad m => VwParser m Text
orderedListMarkers =
(Text
"ol" Text
-> ParsecT Sources ParserState m Int
-> ParsecT Sources ParserState m Text
forall a b.
a
-> ParsecT Sources ParserState m b
-> ParsecT Sources ParserState m a
forall (f :: * -> *) a b. Functor f => a -> f b -> f a
<$ [ParsecT Sources ParserState m Int]
-> ParsecT Sources ParserState m Int
forall s (m :: * -> *) t u a.
Stream s m t =>
[ParsecT s u m a] -> ParsecT s u m a
choice (ListNumberStyle
-> ListNumberDelim -> ParsecT Sources ParserState m Int
forall s (m :: * -> *).
(Stream s m Char, UpdateSourcePos s Char) =>
ListNumberStyle -> ListNumberDelim -> ParsecT s ParserState m Int
orderedListMarker ListNumberStyle
Decimal ListNumberDelim
PeriodParsecT Sources ParserState m Int
-> [ParsecT Sources ParserState m Int]
-> [ParsecT Sources ParserState m Int]
forall a. a -> [a] -> [a]
:(((ListNumberDelim -> ParsecT Sources ParserState m Int)
-> ListNumberDelim -> ParsecT Sources ParserState m Int
forall a b. (a -> b) -> a -> b
$ ListNumberDelim
OneParen) ((ListNumberDelim -> ParsecT Sources ParserState m Int)
-> ParsecT Sources ParserState m Int)
-> (ListNumberStyle
-> ListNumberDelim -> ParsecT Sources ParserState m Int)
-> ListNumberStyle
-> ParsecT Sources ParserState m Int
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ListNumberStyle
-> ListNumberDelim -> ParsecT Sources ParserState m Int
forall s (m :: * -> *).
(Stream s m Char, UpdateSourcePos s Char) =>
ListNumberStyle -> ListNumberDelim -> ParsecT s ParserState m Int
orderedListMarker (ListNumberStyle -> ParsecT Sources ParserState m Int)
-> [ListNumberStyle] -> [ParsecT Sources ParserState m Int]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> [ListNumberStyle
Decimal, ListNumberStyle
LowerRoman, ListNumberStyle
UpperRoman, ListNumberStyle
LowerAlpha, ListNumberStyle
UpperAlpha])))
ParsecT Sources ParserState m Text
-> ParsecT Sources ParserState m Text
-> ParsecT Sources ParserState m Text
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> (Text
"ol" Text
-> ParsecT Sources ParserState m Char
-> ParsecT Sources ParserState m Text
forall a b.
a
-> ParsecT Sources ParserState m b
-> ParsecT Sources ParserState m a
forall (f :: * -> *) a b. Functor f => a -> f b -> f a
<$ Char -> ParsecT Sources ParserState m Char
forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
Char -> ParsecT s u m Char
char Char
'#')
table :: PandocMonad m => VwParser m Blocks
table :: forall (m :: * -> *). PandocMonad m => VwParser m Blocks
table = ParsecT Sources ParserState m Blocks
-> ParsecT Sources ParserState m Blocks
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try (ParsecT Sources ParserState m Blocks
-> ParsecT Sources ParserState m Blocks)
-> ParsecT Sources ParserState m Blocks
-> ParsecT Sources ParserState m Blocks
forall a b. (a -> b) -> a -> b
$ do
indent <- ParsecT Sources ParserState m [Char]
-> ParsecT Sources ParserState m [Char]
forall s (m :: * -> *) t u a.
Stream s m t =>
ParsecT s u m a -> ParsecT s u m a
lookAhead (ParsecT Sources ParserState m Char
-> ParsecT Sources ParserState m [Char]
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m [a]
many ParsecT Sources ParserState m Char
forall s (m :: * -> *) st.
(Stream s m Char, UpdateSourcePos s Char) =>
ParsecT s st m Char
spaceChar)
(th, trs) <- table1 <|> table2
let tab = [Blocks] -> [[Blocks]] -> Blocks
B.simpleTable [Blocks]
th [[Blocks]]
trs
if indent == ""
then return tab
else return $ B.divWith ("", ["center"], []) tab
table1 :: PandocMonad m => VwParser m ([Blocks], [[Blocks]])
table1 :: forall (m :: * -> *).
PandocMonad m =>
VwParser m ([Blocks], [[Blocks]])
table1 = ParsecT Sources ParserState m ([Blocks], [[Blocks]])
-> ParsecT Sources ParserState m ([Blocks], [[Blocks]])
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try (ParsecT Sources ParserState m ([Blocks], [[Blocks]])
-> ParsecT Sources ParserState m ([Blocks], [[Blocks]]))
-> ParsecT Sources ParserState m ([Blocks], [[Blocks]])
-> ParsecT Sources ParserState m ([Blocks], [[Blocks]])
forall a b. (a -> b) -> a -> b
$ do
th <- VwParser m [Blocks]
forall (m :: * -> *). PandocMonad m => VwParser m [Blocks]
tableRow
many1 tableHeaderSeparator
trs <- many tableRow
return (th, trs)
table2 :: PandocMonad m => VwParser m ([Blocks], [[Blocks]])
table2 :: forall (m :: * -> *).
PandocMonad m =>
VwParser m ([Blocks], [[Blocks]])
table2 = ParsecT Sources ParserState m ([Blocks], [[Blocks]])
-> ParsecT Sources ParserState m ([Blocks], [[Blocks]])
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try (ParsecT Sources ParserState m ([Blocks], [[Blocks]])
-> ParsecT Sources ParserState m ([Blocks], [[Blocks]]))
-> ParsecT Sources ParserState m ([Blocks], [[Blocks]])
-> ParsecT Sources ParserState m ([Blocks], [[Blocks]])
forall a b. (a -> b) -> a -> b
$ do
trs@(firstrow:_) <- ParsecT Sources ParserState m [Blocks]
-> ParsecT Sources ParserState m [[Blocks]]
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m [a]
many1 ParsecT Sources ParserState m [Blocks]
forall (m :: * -> *). PandocMonad m => VwParser m [Blocks]
tableRow
return (replicate (length firstrow) mempty, trs)
tableHeaderSeparator :: PandocMonad m => VwParser m ()
= ParsecT Sources ParserState m ()
-> ParsecT Sources ParserState m ()
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try (ParsecT Sources ParserState m ()
-> ParsecT Sources ParserState m ())
-> ParsecT Sources ParserState m ()
-> ParsecT Sources ParserState m ()
forall a b. (a -> b) -> a -> b
$ do
ParsecT Sources ParserState m Char
-> ParsecT Sources ParserState m [Char]
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m [a]
many ParsecT Sources ParserState m Char
forall s (m :: * -> *) st.
(Stream s m Char, UpdateSourcePos s Char) =>
ParsecT s st m Char
spaceChar ParsecT Sources ParserState m [Char]
-> ParsecT Sources ParserState m Char
-> ParsecT Sources ParserState m Char
forall a b.
ParsecT Sources ParserState m a
-> ParsecT Sources ParserState m b
-> ParsecT Sources ParserState m b
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> Char -> ParsecT Sources ParserState m Char
forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
Char -> ParsecT s u m Char
char Char
'|' ParsecT Sources ParserState m Char
-> ParsecT Sources ParserState m [Char]
-> ParsecT Sources ParserState m [Char]
forall a b.
ParsecT Sources ParserState m a
-> ParsecT Sources ParserState m b
-> ParsecT Sources ParserState m b
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> ParsecT Sources ParserState m Char
-> ParsecT Sources ParserState m [Char]
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m [a]
many1 (ParsecT Sources ParserState m Char
-> ParsecT Sources ParserState m [Char]
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m [a]
many1 (Char -> ParsecT Sources ParserState m Char
forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
Char -> ParsecT s u m Char
char Char
'-') ParsecT Sources ParserState m [Char]
-> ParsecT Sources ParserState m Char
-> ParsecT Sources ParserState m Char
forall a b.
ParsecT Sources ParserState m a
-> ParsecT Sources ParserState m b
-> ParsecT Sources ParserState m b
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> Char -> ParsecT Sources ParserState m Char
forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
Char -> ParsecT s u m Char
char Char
'|')
ParsecT Sources ParserState m [Char]
-> ParsecT Sources ParserState m [Char]
-> ParsecT Sources ParserState m [Char]
forall a b.
ParsecT Sources ParserState m a
-> ParsecT Sources ParserState m b
-> ParsecT Sources ParserState m b
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> ParsecT Sources ParserState m Char
-> ParsecT Sources ParserState m [Char]
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m [a]
many ParsecT Sources ParserState m Char
forall s (m :: * -> *) st.
(Stream s m Char, UpdateSourcePos s Char) =>
ParsecT s st m Char
spaceChar ParsecT Sources ParserState m [Char]
-> ParsecT Sources ParserState m Char
-> ParsecT Sources ParserState m Char
forall a b.
ParsecT Sources ParserState m a
-> ParsecT Sources ParserState m b
-> ParsecT Sources ParserState m b
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> ParsecT Sources ParserState m Char
forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
ParsecT s u m Char
newline
() -> ParsecT Sources ParserState m ()
forall a. a -> ParsecT Sources ParserState m a
forall (m :: * -> *) a. Monad m => a -> m a
return ()
tableRow :: PandocMonad m => VwParser m [Blocks]
tableRow :: forall (m :: * -> *). PandocMonad m => VwParser m [Blocks]
tableRow = ParsecT Sources ParserState m [Blocks]
-> ParsecT Sources ParserState m [Blocks]
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try (ParsecT Sources ParserState m [Blocks]
-> ParsecT Sources ParserState m [Blocks])
-> ParsecT Sources ParserState m [Blocks]
-> ParsecT Sources ParserState m [Blocks]
forall a b. (a -> b) -> a -> b
$ do
ParsecT Sources ParserState m Char
-> ParsecT Sources ParserState m [Char]
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m [a]
many ParsecT Sources ParserState m Char
forall s (m :: * -> *) st.
(Stream s m Char, UpdateSourcePos s Char) =>
ParsecT s st m Char
spaceChar ParsecT Sources ParserState m [Char]
-> ParsecT Sources ParserState m Char
-> ParsecT Sources ParserState m Char
forall a b.
ParsecT Sources ParserState m a
-> ParsecT Sources ParserState m b
-> ParsecT Sources ParserState m b
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> Char -> ParsecT Sources ParserState m Char
forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
Char -> ParsecT s u m Char
char Char
'|'
s <- ParsecT Sources ParserState m [Char]
-> ParsecT Sources ParserState m [Char]
forall s (m :: * -> *) t u a.
Stream s m t =>
ParsecT s u m a -> ParsecT s u m a
lookAhead (ParsecT Sources ParserState m [Char]
-> ParsecT Sources ParserState m [Char])
-> ParsecT Sources ParserState m [Char]
-> ParsecT Sources ParserState m [Char]
forall a b. (a -> b) -> a -> b
$ ParsecT Sources ParserState m Char
-> ParsecT Sources ParserState m Char
-> ParsecT Sources 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 Sources ParserState m Char
forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
ParsecT s u m Char
anyChar (ParsecT Sources ParserState m Char
-> ParsecT Sources ParserState m Char
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try (Char -> ParsecT Sources ParserState m Char
forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
Char -> ParsecT s u m Char
char Char
'|' ParsecT Sources ParserState m Char
-> ParsecT Sources ParserState m [Char]
-> ParsecT Sources ParserState m [Char]
forall a b.
ParsecT Sources ParserState m a
-> ParsecT Sources ParserState m b
-> ParsecT Sources ParserState m b
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> ParsecT Sources ParserState m Char
-> ParsecT Sources ParserState m [Char]
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m [a]
many ParsecT Sources ParserState m Char
forall s (m :: * -> *) st.
(Stream s m Char, UpdateSourcePos s Char) =>
ParsecT s st m Char
spaceChar
ParsecT Sources ParserState m [Char]
-> ParsecT Sources ParserState m Char
-> ParsecT Sources ParserState m Char
forall a b.
ParsecT Sources ParserState m a
-> ParsecT Sources ParserState m b
-> ParsecT Sources ParserState m b
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> ParsecT Sources ParserState m Char
forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
ParsecT s u m Char
newline))
guard $ not $ "||" `isInfixOf` ("|" ++ s ++ "|")
many tableCell <* many spaceChar <* char '\n'
tableCell :: PandocMonad m => VwParser m Blocks
tableCell :: forall (m :: * -> *). PandocMonad m => VwParser m Blocks
tableCell = ParsecT Sources ParserState m Blocks
-> ParsecT Sources ParserState m Blocks
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try (ParsecT Sources ParserState m Blocks
-> ParsecT Sources ParserState m Blocks)
-> ParsecT Sources ParserState m Blocks
-> ParsecT Sources ParserState m Blocks
forall a b. (a -> b) -> a -> b
$
Many Inline -> Blocks
B.plain (Many Inline -> Blocks)
-> ([Many Inline] -> Many Inline) -> [Many Inline] -> Blocks
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Many Inline -> Many Inline
trimInlines (Many Inline -> Many Inline)
-> ([Many Inline] -> Many Inline) -> [Many Inline] -> Many Inline
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [Many Inline] -> Many Inline
forall a. Monoid a => [a] -> a
mconcat ([Many Inline] -> Blocks)
-> ParsecT Sources ParserState m [Many Inline]
-> ParsecT Sources ParserState m Blocks
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ParsecT Sources ParserState m (Many Inline)
-> ParsecT Sources ParserState m Char
-> ParsecT Sources ParserState m [Many Inline]
forall s (m :: * -> *) t u a end.
Stream s m t =>
ParsecT s u m a -> ParsecT s u m end -> ParsecT s u m [a]
manyTill ParsecT Sources ParserState m (Many Inline)
forall (m :: * -> *). PandocMonad m => VwParser m (Many Inline)
inline' (Char -> ParsecT Sources ParserState m Char
forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
Char -> ParsecT s u m Char
char Char
'|')
placeholder :: PandocMonad m => VwParser m ()
placeholder :: forall (m :: * -> *). PandocMonad m => VwParser m ()
placeholder = ParsecT Sources ParserState m ()
-> ParsecT Sources ParserState m ()
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try (ParsecT Sources ParserState m ()
-> ParsecT Sources ParserState m ())
-> ParsecT Sources ParserState m ()
-> ParsecT Sources ParserState m ()
forall a b. (a -> b) -> a -> b
$
[ParsecT Sources ParserState m ()]
-> ParsecT Sources ParserState m ()
forall s (m :: * -> *) t u a.
Stream s m t =>
[ParsecT s u m a] -> ParsecT s u m a
choice (Text -> ParsecT Sources ParserState m ()
forall (m :: * -> *). PandocMonad m => Text -> VwParser m ()
ph (Text -> ParsecT Sources ParserState m ())
-> [Text] -> [ParsecT Sources ParserState m ()]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> [Text
"title", Text
"date"]) ParsecT Sources ParserState m ()
-> ParsecT Sources ParserState m ()
-> ParsecT Sources ParserState m ()
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> ParsecT Sources ParserState m ()
forall (m :: * -> *). PandocMonad m => VwParser m ()
noHtmlPh ParsecT Sources ParserState m ()
-> ParsecT Sources ParserState m ()
-> ParsecT Sources ParserState m ()
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> ParsecT Sources ParserState m ()
forall (m :: * -> *). PandocMonad m => VwParser m ()
templatePh
ph :: PandocMonad m => Text -> VwParser m ()
ph :: forall (m :: * -> *). PandocMonad m => Text -> VwParser m ()
ph Text
s = ParsecT Sources ParserState m ()
-> ParsecT Sources ParserState m ()
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try (ParsecT Sources ParserState m ()
-> ParsecT Sources ParserState m ())
-> ParsecT Sources ParserState m ()
-> ParsecT Sources ParserState m ()
forall a b. (a -> b) -> a -> b
$ do
ParsecT Sources ParserState m Char
-> ParsecT Sources ParserState m [Char]
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m [a]
many ParsecT Sources ParserState m Char
forall s (m :: * -> *) st.
(Stream s m Char, UpdateSourcePos s Char) =>
ParsecT s st m Char
spaceChar ParsecT Sources ParserState m [Char]
-> ParsecT Sources ParserState m Text
-> ParsecT Sources ParserState m Text
forall a b.
ParsecT Sources ParserState m a
-> ParsecT Sources ParserState m b
-> ParsecT Sources ParserState m b
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> Text -> ParsecT Sources ParserState m Text
forall s (m :: * -> *) u.
(Stream s m Char, UpdateSourcePos s Char) =>
Text -> ParsecT s u m Text
textStr (Char -> Text -> Text
T.cons Char
'%' Text
s) ParsecT Sources ParserState m Text
-> ParsecT Sources ParserState m Char
-> ParsecT Sources ParserState m Char
forall a b.
ParsecT Sources ParserState m a
-> ParsecT Sources ParserState m b
-> ParsecT Sources ParserState m b
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> ParsecT Sources ParserState m Char
forall s (m :: * -> *) st.
(Stream s m Char, UpdateSourcePos s Char) =>
ParsecT s st m Char
spaceChar
contents <- Many Inline -> Many Inline
trimInlines (Many Inline -> Many Inline)
-> ([Many Inline] -> Many Inline) -> [Many Inline] -> Many Inline
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [Many Inline] -> Many Inline
forall a. Monoid a => [a] -> a
mconcat ([Many Inline] -> Many Inline)
-> ParsecT Sources ParserState m [Many Inline]
-> ParsecT Sources ParserState m (Many Inline)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ParsecT Sources ParserState m (Many Inline)
-> ParsecT Sources ParserState m Char
-> ParsecT Sources ParserState m [Many Inline]
forall s (m :: * -> *) t u a end.
Stream s m t =>
ParsecT s u m a -> ParsecT s u m end -> ParsecT s u m [a]
manyTill ParsecT Sources ParserState m (Many Inline)
forall (m :: * -> *). PandocMonad m => VwParser m (Many Inline)
inline (ParsecT Sources ParserState m Char
-> ParsecT Sources ParserState m Char
forall s (m :: * -> *) t u a.
Stream s m t =>
ParsecT s u m a -> ParsecT s u m a
lookAhead ParsecT Sources ParserState m Char
forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
ParsecT s u m Char
newline)
let meta' = Text -> Many Inline -> Meta -> Meta
forall a b. (HasMeta a, ToMetaValue b) => Text -> b -> a -> a
forall b. ToMetaValue b => Text -> b -> Meta -> Meta
B.setMeta Text
s Many Inline
contents Meta
nullMeta
updateState $ \ParserState
st -> ParserState
st { stateMeta = meta' <> stateMeta st }
noHtmlPh :: PandocMonad m => VwParser m ()
noHtmlPh :: forall (m :: * -> *). PandocMonad m => VwParser m ()
noHtmlPh = ParsecT Sources ParserState m ()
-> ParsecT Sources ParserState m ()
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try (ParsecT Sources ParserState m ()
-> ParsecT Sources ParserState m ())
-> ParsecT Sources ParserState m ()
-> ParsecT Sources ParserState m ()
forall a b. (a -> b) -> a -> b
$
() ()
-> ParsecT Sources ParserState m [Char]
-> ParsecT Sources ParserState m ()
forall a b.
a
-> ParsecT Sources ParserState m b
-> ParsecT Sources ParserState m a
forall (f :: * -> *) a b. Functor f => a -> f b -> f a
<$ ParsecT Sources ParserState m Char
-> ParsecT Sources ParserState m [Char]
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m [a]
many ParsecT Sources ParserState m Char
forall s (m :: * -> *) st.
(Stream s m Char, UpdateSourcePos s Char) =>
ParsecT s st m Char
spaceChar ParsecT Sources ParserState m ()
-> ParsecT Sources ParserState m [Char]
-> ParsecT Sources ParserState m ()
forall a b.
ParsecT Sources ParserState m a
-> ParsecT Sources ParserState m b
-> ParsecT Sources ParserState m a
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
<* [Char] -> ParsecT Sources ParserState m [Char]
forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
[Char] -> ParsecT s u m [Char]
string [Char]
"%nohtml" ParsecT Sources ParserState m ()
-> ParsecT Sources ParserState m [Char]
-> ParsecT Sources ParserState m ()
forall a b.
ParsecT Sources ParserState m a
-> ParsecT Sources ParserState m b
-> ParsecT Sources ParserState m a
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
<* ParsecT Sources ParserState m Char
-> ParsecT Sources ParserState m [Char]
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m [a]
many ParsecT Sources ParserState m Char
forall s (m :: * -> *) st.
(Stream s m Char, UpdateSourcePos s Char) =>
ParsecT s st m Char
spaceChar
ParsecT Sources ParserState m ()
-> ParsecT Sources ParserState m Char
-> ParsecT Sources ParserState m ()
forall a b.
ParsecT Sources ParserState m a
-> ParsecT Sources ParserState m b
-> ParsecT Sources ParserState m a
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
<* ParsecT Sources ParserState m Char
-> ParsecT Sources ParserState m Char
forall s (m :: * -> *) t u a.
Stream s m t =>
ParsecT s u m a -> ParsecT s u m a
lookAhead ParsecT Sources ParserState m Char
forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
ParsecT s u m Char
newline
templatePh :: PandocMonad m => VwParser m ()
templatePh :: forall (m :: * -> *). PandocMonad m => VwParser m ()
templatePh = ParsecT Sources ParserState m ()
-> ParsecT Sources ParserState m ()
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try (ParsecT Sources ParserState m ()
-> ParsecT Sources ParserState m ())
-> ParsecT Sources ParserState m ()
-> ParsecT Sources ParserState m ()
forall a b. (a -> b) -> a -> b
$
() ()
-> ParsecT Sources ParserState m [Char]
-> ParsecT Sources ParserState m ()
forall a b.
a
-> ParsecT Sources ParserState m b
-> ParsecT Sources ParserState m a
forall (f :: * -> *) a b. Functor f => a -> f b -> f a
<$ ParsecT Sources ParserState m Char
-> ParsecT Sources ParserState m [Char]
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m [a]
many ParsecT Sources ParserState m Char
forall s (m :: * -> *) st.
(Stream s m Char, UpdateSourcePos s Char) =>
ParsecT s st m Char
spaceChar ParsecT Sources ParserState m ()
-> ParsecT Sources ParserState m [Char]
-> ParsecT Sources ParserState m ()
forall a b.
ParsecT Sources ParserState m a
-> ParsecT Sources ParserState m b
-> ParsecT Sources ParserState m a
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
<* [Char] -> ParsecT Sources ParserState m [Char]
forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
[Char] -> ParsecT s u m [Char]
string [Char]
"%template" ParsecT Sources ParserState m ()
-> ParsecT Sources ParserState m [Char]
-> ParsecT Sources ParserState m ()
forall a b.
ParsecT Sources ParserState m a
-> ParsecT Sources ParserState m b
-> ParsecT Sources ParserState m a
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
<* ParsecT Sources ParserState m Char
-> ParsecT Sources ParserState m [Char]
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m [a]
many ([Char] -> ParsecT Sources ParserState m Char
forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
[Char] -> ParsecT s u m Char
noneOf [Char]
"\n")
ParsecT Sources ParserState m ()
-> ParsecT Sources ParserState m Char
-> ParsecT Sources ParserState m ()
forall a b.
ParsecT Sources ParserState m a
-> ParsecT Sources ParserState m b
-> ParsecT Sources ParserState m a
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
<* ParsecT Sources ParserState m Char
-> ParsecT Sources ParserState m Char
forall s (m :: * -> *) t u a.
Stream s m t =>
ParsecT s u m a -> ParsecT s u m a
lookAhead ParsecT Sources ParserState m Char
forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
ParsecT s u m Char
newline
inline :: PandocMonad m => VwParser m Inlines
inline :: forall (m :: * -> *). PandocMonad m => VwParser m (Many Inline)
inline = [ParsecT Sources ParserState m (Many Inline)]
-> ParsecT Sources ParserState m (Many Inline)
forall s (m :: * -> *) t u a.
Stream s m t =>
[ParsecT s u m a] -> ParsecT s u m a
choice ([ParsecT Sources ParserState m (Many Inline)]
-> ParsecT Sources ParserState m (Many Inline))
-> [ParsecT Sources ParserState m (Many Inline)]
-> ParsecT Sources ParserState m (Many Inline)
forall a b. (a -> b) -> a -> b
$ VwParser m () -> ParsecT Sources ParserState m (Many Inline)
forall (m :: * -> *).
PandocMonad m =>
VwParser m () -> VwParser m (Many Inline)
whitespace VwParser m ()
forall (m :: * -> *). PandocMonad m => VwParser m ()
endlinePParsecT Sources ParserState m (Many Inline)
-> [ParsecT Sources ParserState m (Many Inline)]
-> [ParsecT Sources ParserState m (Many Inline)]
forall a. a -> [a] -> [a]
:[ParsecT Sources ParserState m (Many Inline)]
forall (m :: * -> *). PandocMonad m => [VwParser m (Many Inline)]
inlineList
inlineList :: PandocMonad m => [VwParser m Inlines]
inlineList :: forall (m :: * -> *). PandocMonad m => [VwParser m (Many Inline)]
inlineList = [ VwParser m (Many Inline)
forall (m :: * -> *). PandocMonad m => VwParser m (Many Inline)
bareURL
, VwParser m (Many Inline)
forall (m :: * -> *). PandocMonad m => VwParser m (Many Inline)
todoMark
, VwParser m (Many Inline)
forall (m :: * -> *). PandocMonad m => VwParser m (Many Inline)
str
, VwParser m (Many Inline)
forall (m :: * -> *). PandocMonad m => VwParser m (Many Inline)
strong
, VwParser m (Many Inline)
forall (m :: * -> *). PandocMonad m => VwParser m (Many Inline)
emph
, VwParser m (Many Inline)
forall (m :: * -> *). PandocMonad m => VwParser m (Many Inline)
strikeout
, VwParser m (Many Inline)
forall (m :: * -> *). PandocMonad m => VwParser m (Many Inline)
code
, VwParser m (Many Inline)
forall (m :: * -> *). PandocMonad m => VwParser m (Many Inline)
link
, VwParser m (Many Inline)
forall (m :: * -> *). PandocMonad m => VwParser m (Many Inline)
image
, VwParser m (Many Inline)
forall (m :: * -> *). PandocMonad m => VwParser m (Many Inline)
inlineMath
, VwParser m (Many Inline)
forall (m :: * -> *). PandocMonad m => VwParser m (Many Inline)
tag
, VwParser m (Many Inline)
forall (m :: * -> *). PandocMonad m => VwParser m (Many Inline)
superscript
, VwParser m (Many Inline)
forall (m :: * -> *). PandocMonad m => VwParser m (Many Inline)
subscript
, VwParser m (Many Inline)
forall (m :: * -> *). PandocMonad m => VwParser m (Many Inline)
special
]
inline' :: PandocMonad m => VwParser m Inlines
inline' :: forall (m :: * -> *). PandocMonad m => VwParser m (Many Inline)
inline' = [ParsecT Sources ParserState m (Many Inline)]
-> ParsecT Sources ParserState m (Many Inline)
forall s (m :: * -> *) t u a.
Stream s m t =>
[ParsecT s u m a] -> ParsecT s u m a
choice ([ParsecT Sources ParserState m (Many Inline)]
-> ParsecT Sources ParserState m (Many Inline))
-> [ParsecT Sources ParserState m (Many Inline)]
-> ParsecT Sources ParserState m (Many Inline)
forall a b. (a -> b) -> a -> b
$ ParsecT Sources ParserState m (Many Inline)
forall (m :: * -> *). PandocMonad m => VwParser m (Many Inline)
whitespace'ParsecT Sources ParserState m (Many Inline)
-> [ParsecT Sources ParserState m (Many Inline)]
-> [ParsecT Sources ParserState m (Many Inline)]
forall a. a -> [a] -> [a]
:[ParsecT Sources ParserState m (Many Inline)]
forall (m :: * -> *). PandocMonad m => [VwParser m (Many Inline)]
inlineList
inlineBQ :: PandocMonad m => VwParser m Inlines
inlineBQ :: forall (m :: * -> *). PandocMonad m => VwParser m (Many Inline)
inlineBQ = [ParsecT Sources ParserState m (Many Inline)]
-> ParsecT Sources ParserState m (Many Inline)
forall s (m :: * -> *) t u a.
Stream s m t =>
[ParsecT s u m a] -> ParsecT s u m a
choice ([ParsecT Sources ParserState m (Many Inline)]
-> ParsecT Sources ParserState m (Many Inline))
-> [ParsecT Sources ParserState m (Many Inline)]
-> ParsecT Sources ParserState m (Many Inline)
forall a b. (a -> b) -> a -> b
$ VwParser m () -> ParsecT Sources ParserState m (Many Inline)
forall (m :: * -> *).
PandocMonad m =>
VwParser m () -> VwParser m (Many Inline)
whitespace VwParser m ()
forall (m :: * -> *). PandocMonad m => VwParser m ()
endlineBQParsecT Sources ParserState m (Many Inline)
-> [ParsecT Sources ParserState m (Many Inline)]
-> [ParsecT Sources ParserState m (Many Inline)]
forall a. a -> [a] -> [a]
:[ParsecT Sources ParserState m (Many Inline)]
forall (m :: * -> *). PandocMonad m => [VwParser m (Many Inline)]
inlineList
inlineML :: PandocMonad m => VwParser m Inlines
inlineML :: forall (m :: * -> *). PandocMonad m => VwParser m (Many Inline)
inlineML = [ParsecT Sources ParserState m (Many Inline)]
-> ParsecT Sources ParserState m (Many Inline)
forall s (m :: * -> *) t u a.
Stream s m t =>
[ParsecT s u m a] -> ParsecT s u m a
choice ([ParsecT Sources ParserState m (Many Inline)]
-> ParsecT Sources ParserState m (Many Inline))
-> [ParsecT Sources ParserState m (Many Inline)]
-> ParsecT Sources ParserState m (Many Inline)
forall a b. (a -> b) -> a -> b
$ VwParser m () -> ParsecT Sources ParserState m (Many Inline)
forall (m :: * -> *).
PandocMonad m =>
VwParser m () -> VwParser m (Many Inline)
whitespace VwParser m ()
forall (m :: * -> *). PandocMonad m => VwParser m ()
endlineMLParsecT Sources ParserState m (Many Inline)
-> [ParsecT Sources ParserState m (Many Inline)]
-> [ParsecT Sources ParserState m (Many Inline)]
forall a. a -> [a] -> [a]
:[ParsecT Sources ParserState m (Many Inline)]
forall (m :: * -> *). PandocMonad m => [VwParser m (Many Inline)]
inlineList
str :: PandocMonad m => VwParser m Inlines
str :: forall (m :: * -> *). PandocMonad m => VwParser m (Many Inline)
str = Text -> Many Inline
B.str (Text -> Many Inline)
-> ParsecT Sources ParserState m Text
-> ParsecT Sources ParserState m (Many Inline)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ParsecT Sources ParserState m Char
-> ParsecT Sources ParserState m Text
forall s (m :: * -> *) t st.
Stream s m t =>
ParsecT s st m Char -> ParsecT s st m Text
many1Char ([Char] -> ParsecT Sources ParserState m Char
forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
[Char] -> ParsecT s u m Char
noneOf ([Char] -> ParsecT Sources ParserState m Char)
-> [Char] -> ParsecT Sources ParserState m Char
forall a b. (a -> b) -> a -> b
$ [Char]
spaceChars [Char] -> [Char] -> [Char]
forall a. [a] -> [a] -> [a]
++ [Char]
specialChars)
whitespace :: PandocMonad m => VwParser m () -> VwParser m Inlines
whitespace :: forall (m :: * -> *).
PandocMonad m =>
VwParser m () -> VwParser m (Many Inline)
whitespace VwParser m ()
endline = Many Inline
B.space Many Inline
-> VwParser m () -> ParsecT Sources ParserState m (Many Inline)
forall a b.
a
-> ParsecT Sources ParserState m b
-> ParsecT Sources ParserState m a
forall (f :: * -> *) a b. Functor f => a -> f b -> f a
<$ (ParsecT Sources ParserState m Char -> VwParser m ()
forall s (m :: * -> *) t u a.
Stream s m t =>
ParsecT s u m a -> ParsecT s u m ()
skipMany1 ParsecT Sources ParserState m Char
forall s (m :: * -> *) st.
(Stream s m Char, UpdateSourcePos s Char) =>
ParsecT s st m Char
spaceChar VwParser m () -> VwParser m () -> VwParser m ()
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|>
VwParser m () -> VwParser m ()
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try (ParsecT Sources ParserState m Char
forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
ParsecT s u m Char
newline ParsecT Sources ParserState m Char
-> VwParser m () -> VwParser m ()
forall a b.
ParsecT Sources ParserState m a
-> ParsecT Sources ParserState m b
-> ParsecT Sources ParserState m b
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> (VwParser m ()
forall (m :: * -> *). PandocMonad m => VwParser m ()
comment VwParser m () -> VwParser m () -> VwParser m ()
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> VwParser m ()
forall (m :: * -> *). PandocMonad m => VwParser m ()
placeholder)))
ParsecT Sources ParserState m (Many Inline)
-> ParsecT Sources ParserState m (Many Inline)
-> ParsecT Sources ParserState m (Many Inline)
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> Many Inline
B.softbreak Many Inline
-> VwParser m () -> ParsecT Sources ParserState m (Many Inline)
forall a b.
a
-> ParsecT Sources ParserState m b
-> ParsecT Sources ParserState m a
forall (f :: * -> *) a b. Functor f => a -> f b -> f a
<$ VwParser m ()
endline
whitespace' :: PandocMonad m => VwParser m Inlines
whitespace' :: forall (m :: * -> *). PandocMonad m => VwParser m (Many Inline)
whitespace' = Many Inline
B.space Many Inline
-> ParsecT Sources ParserState m ()
-> ParsecT Sources ParserState m (Many Inline)
forall a b.
a
-> ParsecT Sources ParserState m b
-> ParsecT Sources ParserState m a
forall (f :: * -> *) a b. Functor f => a -> f b -> f a
<$ ParsecT Sources ParserState m Char
-> ParsecT Sources ParserState m ()
forall s (m :: * -> *) t u a.
Stream s m t =>
ParsecT s u m a -> ParsecT s u m ()
skipMany1 ParsecT Sources ParserState m Char
forall s (m :: * -> *) st.
(Stream s m Char, UpdateSourcePos s Char) =>
ParsecT s st m Char
spaceChar
special :: PandocMonad m => VwParser m Inlines
special :: forall (m :: * -> *). PandocMonad m => VwParser m (Many Inline)
special = Text -> Many Inline
B.str (Text -> Many Inline)
-> ParsecT Sources ParserState m Text
-> ParsecT Sources ParserState m (Many Inline)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Int
-> ParsecT Sources ParserState m Char
-> ParsecT Sources ParserState m Text
forall s (m :: * -> *) st.
(Stream s m Char, UpdateSourcePos s Char, Monad m) =>
Int -> ParsecT s st m Char -> ParsecT s st m Text
countChar Int
1 ([Char] -> ParsecT Sources ParserState m Char
forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
[Char] -> ParsecT s u m Char
oneOf [Char]
specialChars)
bareURL :: PandocMonad m => VwParser m Inlines
bareURL :: forall (m :: * -> *). PandocMonad m => VwParser m (Many Inline)
bareURL = ParsecT Sources ParserState m (Many Inline)
-> ParsecT Sources ParserState m (Many Inline)
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try (ParsecT Sources ParserState m (Many Inline)
-> ParsecT Sources ParserState m (Many Inline))
-> ParsecT Sources ParserState m (Many Inline)
-> ParsecT Sources ParserState m (Many Inline)
forall a b. (a -> b) -> a -> b
$ do
(orig, src) <- ParsecT Sources ParserState m (Text, Text)
forall s (m :: * -> *) st.
(Stream s m Char, UpdateSourcePos s Char) =>
ParsecT s st m (Text, Text)
uri ParsecT Sources ParserState m (Text, Text)
-> ParsecT Sources ParserState m (Text, Text)
-> ParsecT Sources ParserState m (Text, Text)
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> ParsecT Sources ParserState m (Text, Text)
forall s (m :: * -> *) st.
(Stream s m Char, UpdateSourcePos s Char) =>
ParsecT s st m (Text, Text)
emailAddress
return $ B.link src "" (B.str orig)
strong :: PandocMonad m => VwParser m Inlines
strong :: forall (m :: * -> *). PandocMonad m => VwParser m (Many Inline)
strong = ParsecT Sources ParserState m (Many Inline)
-> ParsecT Sources ParserState m (Many Inline)
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try (ParsecT Sources ParserState m (Many Inline)
-> ParsecT Sources ParserState m (Many Inline))
-> ParsecT Sources ParserState m (Many Inline)
-> ParsecT Sources ParserState m (Many Inline)
forall a b. (a -> b) -> a -> b
$ do
Char -> ParsecT Sources ParserState m Char
forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
Char -> ParsecT s u m Char
char Char
'*'
ParsecT Sources ParserState m Char
-> ParsecT Sources ParserState m ()
forall s (m :: * -> *) t a u.
(Stream s m t, Show a) =>
ParsecT s u m a -> ParsecT s u m ()
notFollowedBy ([Char] -> ParsecT Sources ParserState m Char
forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
[Char] -> ParsecT s u m Char
oneOf [Char]
spaceChars)
contents <- [Many Inline] -> Many Inline
forall a. Monoid a => [a] -> a
mconcat ([Many Inline] -> Many Inline)
-> ParsecT Sources ParserState m [Many Inline]
-> ParsecT Sources ParserState m (Many Inline)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ParsecT Sources ParserState m (Many Inline)
-> ParsecT Sources ParserState m ()
-> ParsecT Sources ParserState m [Many Inline]
forall end s (m :: * -> *) t st a.
(Show end, Stream s m t) =>
ParsecT s st m a -> ParsecT s st m end -> ParsecT s st m [a]
many1Till ParsecT Sources ParserState m (Many Inline)
forall (m :: * -> *). PandocMonad m => VwParser m (Many Inline)
inline'
(ParsecT Sources ParserState m ()
-> ParsecT Sources ParserState m ()
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try (Char -> ParsecT Sources ParserState m Char
forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
Char -> ParsecT s u m Char
char Char
'*' ParsecT Sources ParserState m Char
-> ParsecT Sources ParserState m ()
-> ParsecT Sources ParserState m ()
forall a b.
ParsecT Sources ParserState m a
-> ParsecT Sources ParserState m b
-> ParsecT Sources ParserState m b
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> ParsecT Sources ParserState m Char
-> ParsecT Sources 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 Sources ParserState m Char
forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
ParsecT s u m Char
alphaNum))
guard $ lastMay (toList contents) /= Just Space
return $ B.spanWith (makeId contents, [], []) mempty <> B.strong contents
makeId :: Inlines -> Text
makeId :: Many Inline -> Text
makeId Many Inline
i = [Text] -> Text
T.concat (Inline -> Text
forall a. Walkable Inline a => a -> Text
stringify (Inline -> Text) -> [Inline] -> [Text]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Many Inline -> [Inline]
forall a. Many a -> [a]
toList Many Inline
i)
emph :: PandocMonad m => VwParser m Inlines
emph :: forall (m :: * -> *). PandocMonad m => VwParser m (Many Inline)
emph = ParsecT Sources ParserState m (Many Inline)
-> ParsecT Sources ParserState m (Many Inline)
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try (ParsecT Sources ParserState m (Many Inline)
-> ParsecT Sources ParserState m (Many Inline))
-> ParsecT Sources ParserState m (Many Inline)
-> ParsecT Sources ParserState m (Many Inline)
forall a b. (a -> b) -> a -> b
$ do
Char -> ParsecT Sources ParserState m Char
forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
Char -> ParsecT s u m Char
char Char
'_'
ParsecT Sources ParserState m Char
-> ParsecT Sources ParserState m ()
forall s (m :: * -> *) t a u.
(Stream s m t, Show a) =>
ParsecT s u m a -> ParsecT s u m ()
notFollowedBy ([Char] -> ParsecT Sources ParserState m Char
forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
[Char] -> ParsecT s u m Char
oneOf [Char]
spaceChars)
contents <- [Many Inline] -> Many Inline
forall a. Monoid a => [a] -> a
mconcat ([Many Inline] -> Many Inline)
-> ParsecT Sources ParserState m [Many Inline]
-> ParsecT Sources ParserState m (Many Inline)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ParsecT Sources ParserState m (Many Inline)
-> ParsecT Sources ParserState m ()
-> ParsecT Sources ParserState m [Many Inline]
forall end s (m :: * -> *) t st a.
(Show end, Stream s m t) =>
ParsecT s st m a -> ParsecT s st m end -> ParsecT s st m [a]
many1Till ParsecT Sources ParserState m (Many Inline)
forall (m :: * -> *). PandocMonad m => VwParser m (Many Inline)
inline'
(ParsecT Sources ParserState m ()
-> ParsecT Sources ParserState m ()
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try (Char -> ParsecT Sources ParserState m Char
forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
Char -> ParsecT s u m Char
char Char
'_' ParsecT Sources ParserState m Char
-> ParsecT Sources ParserState m ()
-> ParsecT Sources ParserState m ()
forall a b.
ParsecT Sources ParserState m a
-> ParsecT Sources ParserState m b
-> ParsecT Sources ParserState m b
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> ParsecT Sources ParserState m Char
-> ParsecT Sources 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 Sources ParserState m Char
forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
ParsecT s u m Char
alphaNum))
guard $ lastMay (toList contents) /= Just Space
return $ B.emph contents
strikeout :: PandocMonad m => VwParser m Inlines
strikeout :: forall (m :: * -> *). PandocMonad m => VwParser m (Many Inline)
strikeout = ParsecT Sources ParserState m (Many Inline)
-> ParsecT Sources ParserState m (Many Inline)
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try (ParsecT Sources ParserState m (Many Inline)
-> ParsecT Sources ParserState m (Many Inline))
-> ParsecT Sources ParserState m (Many Inline)
-> ParsecT Sources ParserState m (Many Inline)
forall a b. (a -> b) -> a -> b
$ do
[Char] -> ParsecT Sources ParserState m [Char]
forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
[Char] -> ParsecT s u m [Char]
string [Char]
"~~"
contents <- [Many Inline] -> Many Inline
forall a. Monoid a => [a] -> a
mconcat ([Many Inline] -> Many Inline)
-> ParsecT Sources ParserState m [Many Inline]
-> ParsecT Sources ParserState m (Many Inline)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$>ParsecT Sources ParserState m (Many Inline)
-> ParsecT Sources ParserState m [Char]
-> ParsecT Sources ParserState m [Many Inline]
forall end s (m :: * -> *) t st a.
(Show end, Stream s m t) =>
ParsecT s st m a -> ParsecT s st m end -> ParsecT s st m [a]
many1Till ParsecT Sources ParserState m (Many Inline)
forall (m :: * -> *). PandocMonad m => VwParser m (Many Inline)
inline' ([Char] -> ParsecT Sources ParserState m [Char]
forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
[Char] -> ParsecT s u m [Char]
string [Char]
"~~")
return $ B.strikeout contents
code :: PandocMonad m => VwParser m Inlines
code :: forall (m :: * -> *). PandocMonad m => VwParser m (Many Inline)
code = ParsecT Sources ParserState m (Many Inline)
-> ParsecT Sources ParserState m (Many Inline)
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try (ParsecT Sources ParserState m (Many Inline)
-> ParsecT Sources ParserState m (Many Inline))
-> ParsecT Sources ParserState m (Many Inline)
-> ParsecT Sources ParserState m (Many Inline)
forall a b. (a -> b) -> a -> b
$ do
Char -> ParsecT Sources ParserState m Char
forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
Char -> ParsecT s u m Char
char Char
'`'
contents <- ParsecT Sources ParserState m Char
-> ParsecT Sources ParserState m Char
-> ParsecT Sources ParserState m Text
forall end s (m :: * -> *) t st.
(Show end, Stream s m t) =>
ParsecT s st m Char -> ParsecT s st m end -> ParsecT s st m Text
many1TillChar ([Char] -> ParsecT Sources ParserState m Char
forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
[Char] -> ParsecT s u m Char
noneOf [Char]
"\n") (Char -> ParsecT Sources ParserState m Char
forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
Char -> ParsecT s u m Char
char Char
'`')
return $ B.code contents
superscript :: PandocMonad m => VwParser m Inlines
superscript :: forall (m :: * -> *). PandocMonad m => VwParser m (Many Inline)
superscript = ParsecT Sources ParserState m (Many Inline)
-> ParsecT Sources ParserState m (Many Inline)
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try (ParsecT Sources ParserState m (Many Inline)
-> ParsecT Sources ParserState m (Many Inline))
-> ParsecT Sources ParserState m (Many Inline)
-> ParsecT Sources ParserState m (Many Inline)
forall a b. (a -> b) -> a -> b
$
Many Inline -> Many Inline
B.superscript (Many Inline -> Many Inline)
-> ([Many Inline] -> Many Inline) -> [Many Inline] -> Many Inline
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [Many Inline] -> Many Inline
forall a. Monoid a => [a] -> a
mconcat ([Many Inline] -> Many Inline)
-> ParsecT Sources ParserState m [Many Inline]
-> ParsecT Sources ParserState m (Many Inline)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (Char -> ParsecT Sources ParserState m Char
forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
Char -> ParsecT s u m Char
char Char
'^' ParsecT Sources ParserState m Char
-> ParsecT Sources ParserState m [Many Inline]
-> ParsecT Sources ParserState m [Many Inline]
forall a b.
ParsecT Sources ParserState m a
-> ParsecT Sources ParserState m b
-> ParsecT Sources ParserState m b
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> ParsecT Sources ParserState m (Many Inline)
-> ParsecT Sources ParserState m Char
-> ParsecT Sources ParserState m [Many Inline]
forall end s (m :: * -> *) t st a.
(Show end, Stream s m t) =>
ParsecT s st m a -> ParsecT s st m end -> ParsecT s st m [a]
many1Till ParsecT Sources ParserState m (Many Inline)
forall (m :: * -> *). PandocMonad m => VwParser m (Many Inline)
inline' (Char -> ParsecT Sources ParserState m Char
forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
Char -> ParsecT s u m Char
char Char
'^'))
subscript :: PandocMonad m => VwParser m Inlines
subscript :: forall (m :: * -> *). PandocMonad m => VwParser m (Many Inline)
subscript = ParsecT Sources ParserState m (Many Inline)
-> ParsecT Sources ParserState m (Many Inline)
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try (ParsecT Sources ParserState m (Many Inline)
-> ParsecT Sources ParserState m (Many Inline))
-> ParsecT Sources ParserState m (Many Inline)
-> ParsecT Sources ParserState m (Many Inline)
forall a b. (a -> b) -> a -> b
$
Many Inline -> Many Inline
B.subscript (Many Inline -> Many Inline)
-> ([Many Inline] -> Many Inline) -> [Many Inline] -> Many Inline
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [Many Inline] -> Many Inline
forall a. Monoid a => [a] -> a
mconcat ([Many Inline] -> Many Inline)
-> ParsecT Sources ParserState m [Many Inline]
-> ParsecT Sources ParserState m (Many Inline)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ([Char] -> ParsecT Sources ParserState m [Char]
forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
[Char] -> ParsecT s u m [Char]
string [Char]
",,"
ParsecT Sources ParserState m [Char]
-> ParsecT Sources ParserState m [Many Inline]
-> ParsecT Sources ParserState m [Many Inline]
forall a b.
ParsecT Sources ParserState m a
-> ParsecT Sources ParserState m b
-> ParsecT Sources ParserState m b
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> ParsecT Sources ParserState m (Many Inline)
-> ParsecT Sources ParserState m [Char]
-> ParsecT Sources ParserState m [Many Inline]
forall end s (m :: * -> *) t st a.
(Show end, Stream s m t) =>
ParsecT s st m a -> ParsecT s st m end -> ParsecT s st m [a]
many1Till ParsecT Sources ParserState m (Many Inline)
forall (m :: * -> *). PandocMonad m => VwParser m (Many Inline)
inline' (ParsecT Sources ParserState m [Char]
-> ParsecT Sources ParserState m [Char]
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try (ParsecT Sources ParserState m [Char]
-> ParsecT Sources ParserState m [Char])
-> ParsecT Sources ParserState m [Char]
-> ParsecT Sources ParserState m [Char]
forall a b. (a -> b) -> a -> b
$ [Char] -> ParsecT Sources ParserState m [Char]
forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
[Char] -> ParsecT s u m [Char]
string [Char]
",,"))
link :: PandocMonad m => VwParser m Inlines
link :: forall (m :: * -> *). PandocMonad m => VwParser m (Many Inline)
link = ParsecT Sources ParserState m (Many Inline)
-> ParsecT Sources ParserState m (Many Inline)
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try (ParsecT Sources ParserState m (Many Inline)
-> ParsecT Sources ParserState m (Many Inline))
-> ParsecT Sources ParserState m (Many Inline)
-> ParsecT Sources ParserState m (Many Inline)
forall a b. (a -> b) -> a -> b
$ do
[Char] -> ParsecT Sources ParserState m [Char]
forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
[Char] -> ParsecT s u m [Char]
string [Char]
"[["
contents <- ParsecT Sources ParserState m Text
-> ParsecT Sources ParserState m Text
forall s (m :: * -> *) t u a.
Stream s m t =>
ParsecT s u m a -> ParsecT s u m a
lookAhead (ParsecT Sources ParserState m Text
-> ParsecT Sources ParserState m Text)
-> ParsecT Sources ParserState m Text
-> ParsecT Sources ParserState m Text
forall a b. (a -> b) -> a -> b
$ ParsecT Sources ParserState m Char
-> ParsecT Sources ParserState m [Char]
-> ParsecT Sources ParserState m Text
forall s (m :: * -> *) t st a.
Stream s m t =>
ParsecT s st m Char -> ParsecT s st m a -> ParsecT s st m Text
manyTillChar ParsecT Sources ParserState m Char
forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
ParsecT s u m Char
anyChar ([Char] -> ParsecT Sources ParserState m [Char]
forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
[Char] -> ParsecT s u m [Char]
string [Char]
"]]")
if T.any (== '|') contents
then do
url <- manyTillChar anyChar $ char '|'
lab <- mconcat <$> manyTill inline (string "]]")
return $ B.linkWith (attr url) (procLink url) "" lab
else do
manyTill anyChar (string "]]")
return $ B.linkWith (attr contents) (procLink contents) "" (B.str contents)
where
attr :: Text -> Attr
attr Text
t | Text -> Bool
isURI Text
t = Attr
B.nullAttr
| Bool
otherwise = (Text
forall a. Monoid a => a
mempty, [Text
"wikilink"], [(Text, Text)]
forall a. Monoid a => a
mempty)
image :: PandocMonad m => VwParser m Inlines
image :: forall (m :: * -> *). PandocMonad m => VwParser m (Many Inline)
image = ParsecT Sources ParserState m (Many Inline)
-> ParsecT Sources ParserState m (Many Inline)
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try (ParsecT Sources ParserState m (Many Inline)
-> ParsecT Sources ParserState m (Many Inline))
-> ParsecT Sources ParserState m (Many Inline)
-> ParsecT Sources ParserState m (Many Inline)
forall a b. (a -> b) -> a -> b
$ do
[Char] -> ParsecT Sources ParserState m [Char]
forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
[Char] -> ParsecT s u m [Char]
string [Char]
"{{"
contentText <- ParsecT Sources ParserState m [Char]
-> ParsecT Sources ParserState m [Char]
forall s (m :: * -> *) t u a.
Stream s m t =>
ParsecT s u m a -> ParsecT s u m a
lookAhead (ParsecT Sources ParserState m [Char]
-> ParsecT Sources ParserState m [Char])
-> ParsecT Sources ParserState m [Char]
-> ParsecT Sources ParserState m [Char]
forall a b. (a -> b) -> a -> b
$ ParsecT Sources ParserState m Char
-> ParsecT Sources ParserState m [Char]
-> ParsecT Sources 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 ([Char] -> ParsecT Sources ParserState m Char
forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
[Char] -> ParsecT s u m Char
noneOf [Char]
"\n") (ParsecT Sources ParserState m [Char]
-> ParsecT Sources ParserState m [Char]
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try (ParsecT Sources ParserState m [Char]
-> ParsecT Sources ParserState m [Char])
-> ParsecT Sources ParserState m [Char]
-> ParsecT Sources ParserState m [Char]
forall a b. (a -> b) -> a -> b
$ [Char] -> ParsecT Sources ParserState m [Char]
forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
[Char] -> ParsecT s u m [Char]
string [Char]
"}}")
images $ length $ filter (== '|') contentText
images :: PandocMonad m => Int -> VwParser m Inlines
images :: forall (m :: * -> *).
PandocMonad m =>
Int -> VwParser m (Many Inline)
images Int
k
| Int
k Int -> Int -> Bool
forall a. Eq a => a -> a -> Bool
== Int
0 = do
imgurl <- ParsecT Sources ParserState m Char
-> ParsecT Sources ParserState m [Char]
-> ParsecT Sources ParserState m Text
forall s (m :: * -> *) t st a.
Stream s m t =>
ParsecT s st m Char -> ParsecT s st m a -> ParsecT s st m Text
manyTillChar ParsecT Sources ParserState m Char
forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
ParsecT s u m Char
anyChar (ParsecT Sources ParserState m [Char]
-> ParsecT Sources ParserState m [Char]
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try (ParsecT Sources ParserState m [Char]
-> ParsecT Sources ParserState m [Char])
-> ParsecT Sources ParserState m [Char]
-> ParsecT Sources ParserState m [Char]
forall a b. (a -> b) -> a -> b
$ [Char] -> ParsecT Sources ParserState m [Char]
forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
[Char] -> ParsecT s u m [Char]
string [Char]
"}}")
return $ B.image (procImgurl imgurl) "" (B.str "")
| Int
k Int -> Int -> Bool
forall a. Eq a => a -> a -> Bool
== Int
1 = do
imgurl <- ParsecT Sources ParserState m Char
-> ParsecT Sources ParserState m Char
-> ParsecT Sources ParserState m Text
forall s (m :: * -> *) t st a.
Stream s m t =>
ParsecT s st m Char -> ParsecT s st m a -> ParsecT s st m Text
manyTillChar ParsecT Sources ParserState m Char
forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
ParsecT s u m Char
anyChar (Char -> ParsecT Sources ParserState m Char
forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
Char -> ParsecT s u m Char
char Char
'|')
alt <- mconcat <$> manyTill inline (try $ string "}}")
return $ B.image (procImgurl imgurl) "" alt
| Int
k Int -> Int -> Bool
forall a. Eq a => a -> a -> Bool
== Int
2 = do
imgurl <- ParsecT Sources ParserState m Char
-> ParsecT Sources ParserState m Char
-> ParsecT Sources ParserState m Text
forall s (m :: * -> *) t st a.
Stream s m t =>
ParsecT s st m Char -> ParsecT s st m a -> ParsecT s st m Text
manyTillChar ParsecT Sources ParserState m Char
forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
ParsecT s u m Char
anyChar (Char -> ParsecT Sources ParserState m Char
forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
Char -> ParsecT s u m Char
char Char
'|')
alt <- mconcat <$> manyTill inline (char '|')
attrText <- manyTillChar anyChar (try $ string "}}")
return $ B.imageWith (makeAttr attrText) (procImgurl imgurl) "" alt
| Bool
otherwise = do
imgurl <- ParsecT Sources ParserState m Char
-> ParsecT Sources ParserState m Char
-> ParsecT Sources ParserState m Text
forall s (m :: * -> *) t st a.
Stream s m t =>
ParsecT s st m Char -> ParsecT s st m a -> ParsecT s st m Text
manyTillChar ParsecT Sources ParserState m Char
forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
ParsecT s u m Char
anyChar (Char -> ParsecT Sources ParserState m Char
forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
Char -> ParsecT s u m Char
char Char
'|')
alt <- mconcat <$> manyTill inline (char '|')
attrText <- manyTillChar anyChar (char '|')
manyTill anyChar (try $ string "}}")
return $ B.imageWith (makeAttr attrText) (procImgurl imgurl) "" alt
procLink' :: Text -> Text
procLink' :: Text -> Text
procLink' Text
s
| Int -> Text -> Text
T.take Int
6 Text
s Text -> Text -> Bool
forall a. Eq a => a -> a -> Bool
== Text
"local:" = Text
"file" Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Int -> Text -> Text
T.drop Int
5 Text
s
| Int -> Text -> Text
T.take Int
6 Text
s Text -> Text -> Bool
forall a. Eq a => a -> a -> Bool
== Text
"diary:" = Text
"diary/" Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Int -> Text -> Text
T.drop Int
6 Text
s
| (Text -> Bool) -> [Text] -> Bool
forall (t :: * -> *) a. Foldable t => (a -> Bool) -> t a -> Bool
any (Text -> Text -> Bool
`T.isPrefixOf` Text
s) [ Text
"http:", Text
"https:", Text
"ftp:", Text
"file:", Text
"mailto:",
Text
"news:", Text
"telnet:" ]
= Text
s
| Text
s Text -> Text -> Bool
forall a. Eq a => a -> a -> Bool
== Text
"" = Text
""
| HasCallStack => Text -> Char
Text -> Char
T.last Text
s Char -> Char -> Bool
forall a. Eq a => a -> a -> Bool
== Char
'/' = Text
s
| Bool
otherwise = Text
s
procLink :: Text -> Text
procLink :: Text -> Text
procLink Text
s = Text -> Text
procLink' Text
x Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
y
where (Text
x, Text
y) = (Char -> Bool) -> Text -> (Text, Text)
T.break (Char -> Char -> Bool
forall a. Eq a => a -> a -> Bool
==Char
'#') Text
s
procImgurl :: Text -> Text
procImgurl :: Text -> Text
procImgurl Text
s = if Int -> Text -> Text
T.take Int
6 Text
s Text -> Text -> Bool
forall a. Eq a => a -> a -> Bool
== Text
"local:" then Text
"file" Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Int -> Text -> Text
T.drop Int
5 Text
s else Text
s
inlineMath :: PandocMonad m => VwParser m Inlines
inlineMath :: forall (m :: * -> *). PandocMonad m => VwParser m (Many Inline)
inlineMath = ParsecT Sources ParserState m (Many Inline)
-> ParsecT Sources ParserState m (Many Inline)
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try (ParsecT Sources ParserState m (Many Inline)
-> ParsecT Sources ParserState m (Many Inline))
-> ParsecT Sources ParserState m (Many Inline)
-> ParsecT Sources ParserState m (Many Inline)
forall a b. (a -> b) -> a -> b
$
Text -> Many Inline
B.math (Text -> Many Inline)
-> ParsecT Sources ParserState m Char
-> ParsecT Sources ParserState m (Text -> Many Inline)
forall a b.
a
-> ParsecT Sources ParserState m b
-> ParsecT Sources ParserState m a
forall (f :: * -> *) a b. Functor f => a -> f b -> f a
<$ Char -> ParsecT Sources ParserState m Char
forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
Char -> ParsecT s u m Char
char Char
'$' ParsecT Sources ParserState m (Text -> Many Inline)
-> ParsecT Sources ParserState m Text
-> ParsecT Sources ParserState m (Many Inline)
forall a b.
ParsecT Sources ParserState m (a -> b)
-> ParsecT Sources ParserState m a
-> ParsecT Sources ParserState m b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> ParsecT Sources ParserState m Char
-> ParsecT Sources ParserState m Char
-> ParsecT Sources ParserState m Text
forall end s (m :: * -> *) t st.
(Show end, Stream s m t) =>
ParsecT s st m Char -> ParsecT s st m end -> ParsecT s st m Text
many1TillChar ([Char] -> ParsecT Sources ParserState m Char
forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
[Char] -> ParsecT s u m Char
noneOf [Char]
"\n") (Char -> ParsecT Sources ParserState m Char
forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
Char -> ParsecT s u m Char
char Char
'$')
tag :: PandocMonad m => VwParser m Inlines
tag :: forall (m :: * -> *). PandocMonad m => VwParser m (Many Inline)
tag = ParsecT Sources ParserState m (Many Inline)
-> ParsecT Sources ParserState m (Many Inline)
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try (ParsecT Sources ParserState m (Many Inline)
-> ParsecT Sources ParserState m (Many Inline))
-> ParsecT Sources ParserState m (Many Inline)
-> ParsecT Sources ParserState m (Many Inline)
forall a b. (a -> b) -> a -> b
$ do
Char -> ParsecT Sources ParserState m Char
forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
Char -> ParsecT s u m Char
char Char
':'
s <- ParsecT Sources ParserState m Char
-> ParsecT Sources ParserState m Char
-> ParsecT Sources ParserState m Text
forall s (m :: * -> *) t st a.
Stream s m t =>
ParsecT s st m Char -> ParsecT s st m a -> ParsecT s st m Text
manyTillChar ([Char] -> ParsecT Sources ParserState m Char
forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
[Char] -> ParsecT s u m Char
noneOf [Char]
spaceChars) (ParsecT Sources ParserState m Char
-> ParsecT Sources ParserState m Char
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try (Char -> ParsecT Sources ParserState m Char
forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
Char -> ParsecT s u m Char
char Char
':' ParsecT Sources ParserState m Char
-> ParsecT Sources ParserState m Char
-> ParsecT Sources ParserState m Char
forall a b.
ParsecT Sources ParserState m a
-> ParsecT Sources ParserState m b
-> ParsecT Sources ParserState m b
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> ParsecT Sources ParserState m Char
-> ParsecT Sources ParserState m Char
forall s (m :: * -> *) t u a.
Stream s m t =>
ParsecT s u m a -> ParsecT s u m a
lookAhead ParsecT Sources ParserState m Char
forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
ParsecT s u m Char
space))
guard $ not $ "::" `T.isInfixOf` (":" <> s <> ":")
case splitTextBy (==':') s of
[] -> [Char] -> ParsecT Sources ParserState m (Many Inline)
forall a. HasCallStack => [Char] -> ParsecT Sources ParserState m a
forall (m :: * -> *) a.
(MonadFail m, HasCallStack) =>
[Char] -> m a
fail [Char]
"tag doesn't contain :"
(Text
x:[Text]
xs) -> Many Inline -> ParsecT Sources ParserState m (Many Inline)
forall a. a -> ParsecT Sources ParserState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (Many Inline -> ParsecT Sources ParserState m (Many Inline))
-> Many Inline -> ParsecT Sources ParserState m (Many Inline)
forall a b. (a -> b) -> a -> b
$ [Many Inline] -> Many Inline
forall a. Monoid a => [a] -> a
mconcat ([Many Inline] -> Many Inline) -> [Many Inline] -> Many Inline
forall a b. (a -> b) -> a -> b
$ Text -> Many Inline
makeTagSpan' Text
x Many Inline -> [Many Inline] -> [Many Inline]
forall a. a -> [a] -> [a]
: (Text -> Many Inline
makeTagSpan (Text -> Many Inline) -> [Text] -> [Many Inline]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> [Text]
xs)
todoMark :: PandocMonad m => VwParser m Inlines
todoMark :: forall (m :: * -> *). PandocMonad m => VwParser m (Many Inline)
todoMark = ParsecT Sources ParserState m (Many Inline)
-> ParsecT Sources ParserState m (Many Inline)
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try (ParsecT Sources ParserState m (Many Inline)
-> ParsecT Sources ParserState m (Many Inline))
-> ParsecT Sources ParserState m (Many Inline)
-> ParsecT Sources ParserState m (Many Inline)
forall a b. (a -> b) -> a -> b
$ do
[Char] -> ParsecT Sources ParserState m [Char]
forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
[Char] -> ParsecT s u m [Char]
string [Char]
"TODO:"
Many Inline -> ParsecT Sources ParserState m (Many Inline)
forall a. a -> ParsecT Sources ParserState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (Many Inline -> ParsecT Sources ParserState m (Many Inline))
-> Many Inline -> ParsecT Sources ParserState m (Many Inline)
forall a b. (a -> b) -> a -> b
$ Attr -> Many Inline -> Many Inline
B.spanWith (Text
"", [Text
"todo"], []) (Text -> Many Inline
B.str Text
"TODO:")
endlineP :: PandocMonad m => VwParser m ()
endlineP :: forall (m :: * -> *). PandocMonad m => VwParser m ()
endlineP = () ()
-> ParsecT Sources ParserState m Char
-> ParsecT Sources ParserState m ()
forall a b.
a
-> ParsecT Sources ParserState m b
-> ParsecT Sources ParserState m a
forall (f :: * -> *) a b. Functor f => a -> f b -> f a
<$ ParsecT Sources ParserState m Char
-> ParsecT Sources ParserState m Char
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try (ParsecT Sources ParserState m Char
forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
ParsecT s u m Char
newline ParsecT Sources ParserState m Char
-> ParsecT Sources ParserState m ()
-> ParsecT Sources ParserState m Char
forall a b.
ParsecT Sources ParserState m a
-> ParsecT Sources ParserState m b
-> ParsecT Sources ParserState m a
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
<* ParsecT Sources ParserState m ()
forall (m :: * -> *). PandocMonad m => VwParser m ()
nFBTTBSB ParsecT Sources ParserState m Char
-> ParsecT Sources ParserState m ()
-> ParsecT Sources ParserState m Char
forall a b.
ParsecT Sources ParserState m a
-> ParsecT Sources ParserState m b
-> ParsecT Sources ParserState m a
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
<* ParsecT Sources ParserState m Blocks
-> ParsecT Sources 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 Sources ParserState m Blocks
forall (m :: * -> *). PandocMonad m => VwParser m Blocks
blockQuote)
endlineBQ :: PandocMonad m => VwParser m ()
endlineBQ :: forall (m :: * -> *). PandocMonad m => VwParser m ()
endlineBQ = () ()
-> ParsecT Sources ParserState m Char
-> ParsecT Sources ParserState m ()
forall a b.
a
-> ParsecT Sources ParserState m b
-> ParsecT Sources ParserState m a
forall (f :: * -> *) a b. Functor f => a -> f b -> f a
<$ ParsecT Sources ParserState m Char
-> ParsecT Sources ParserState m Char
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try (ParsecT Sources ParserState m Char
forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
ParsecT s u m Char
newline ParsecT Sources ParserState m Char
-> ParsecT Sources ParserState m ()
-> ParsecT Sources ParserState m Char
forall a b.
ParsecT Sources ParserState m a
-> ParsecT Sources ParserState m b
-> ParsecT Sources ParserState m a
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
<* ParsecT Sources ParserState m ()
forall (m :: * -> *). PandocMonad m => VwParser m ()
nFBTTBSB ParsecT Sources ParserState m Char
-> ParsecT Sources ParserState m [Char]
-> ParsecT Sources ParserState m Char
forall a b.
ParsecT Sources ParserState m a
-> ParsecT Sources ParserState m b
-> ParsecT Sources ParserState m a
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
<* [Char] -> ParsecT Sources ParserState m [Char]
forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
[Char] -> ParsecT s u m [Char]
string [Char]
" ")
endlineML :: PandocMonad m => VwParser m ()
endlineML :: forall (m :: * -> *). PandocMonad m => VwParser m ()
endlineML = () ()
-> ParsecT Sources ParserState m Char
-> ParsecT Sources ParserState m ()
forall a b.
a
-> ParsecT Sources ParserState m b
-> ParsecT Sources ParserState m a
forall (f :: * -> *) a b. Functor f => a -> f b -> f a
<$ ParsecT Sources ParserState m Char
-> ParsecT Sources ParserState m Char
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try (ParsecT Sources ParserState m Char
forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
ParsecT s u m Char
newline ParsecT Sources ParserState m Char
-> ParsecT Sources ParserState m ()
-> ParsecT Sources ParserState m Char
forall a b.
ParsecT Sources ParserState m a
-> ParsecT Sources ParserState m b
-> ParsecT Sources ParserState m a
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
<* ParsecT Sources ParserState m ()
forall (m :: * -> *). PandocMonad m => VwParser m ()
nFBTTBSB ParsecT Sources ParserState m Char
-> ParsecT Sources ParserState m [Char]
-> ParsecT Sources ParserState m Char
forall a b.
ParsecT Sources ParserState m a
-> ParsecT Sources ParserState m b
-> ParsecT Sources ParserState m a
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
<* ParsecT Sources ParserState m Char
-> ParsecT Sources ParserState m [Char]
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m [a]
many1 ParsecT Sources ParserState m Char
forall s (m :: * -> *) st.
(Stream s m Char, UpdateSourcePos s Char) =>
ParsecT s st m Char
spaceChar)
nFBTTBSB :: PandocMonad m => VwParser m ()
nFBTTBSB :: forall (m :: * -> *). PandocMonad m => VwParser m ()
nFBTTBSB =
ParsecT Sources ParserState m Char
-> ParsecT Sources 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 Sources ParserState m Char
forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
ParsecT s u m Char
newline ParsecT Sources ParserState m ()
-> ParsecT Sources ParserState m ()
-> ParsecT Sources ParserState m ()
forall a b.
ParsecT Sources ParserState m a
-> ParsecT Sources ParserState m b
-> ParsecT Sources ParserState m a
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
<*
ParsecT Sources ParserState m Blocks
-> ParsecT Sources 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 Sources ParserState m Blocks
forall (m :: * -> *). PandocMonad m => VwParser m Blocks
hrule ParsecT Sources ParserState m ()
-> ParsecT Sources ParserState m ()
-> ParsecT Sources ParserState m ()
forall a b.
ParsecT Sources ParserState m a
-> ParsecT Sources ParserState m b
-> ParsecT Sources ParserState m a
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
<*
ParsecT Sources ParserState m [Blocks]
-> ParsecT Sources 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 Sources ParserState m [Blocks]
forall (m :: * -> *). PandocMonad m => VwParser m [Blocks]
tableRow ParsecT Sources ParserState m ()
-> ParsecT Sources ParserState m ()
-> ParsecT Sources ParserState m ()
forall a b.
ParsecT Sources ParserState m a
-> ParsecT Sources ParserState m b
-> ParsecT Sources ParserState m a
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
<*
ParsecT Sources ParserState m Blocks
-> ParsecT Sources 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 Sources ParserState m Blocks
forall (m :: * -> *). PandocMonad m => VwParser m Blocks
header ParsecT Sources ParserState m ()
-> ParsecT Sources ParserState m ()
-> ParsecT Sources ParserState m ()
forall a b.
ParsecT Sources ParserState m a
-> ParsecT Sources ParserState m b
-> ParsecT Sources ParserState m a
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
<*
ParsecT Sources ParserState m (Int, Text)
-> ParsecT Sources 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 Sources ParserState m (Int, Text)
forall (m :: * -> *). PandocMonad m => VwParser m (Int, Text)
listStart ParsecT Sources ParserState m ()
-> ParsecT Sources ParserState m ()
-> ParsecT Sources ParserState m ()
forall a b.
ParsecT Sources ParserState m a
-> ParsecT Sources ParserState m b
-> ParsecT Sources ParserState m a
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
<*
ParsecT Sources ParserState m Blocks
-> ParsecT Sources 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 Sources ParserState m Blocks
forall (m :: * -> *). PandocMonad m => VwParser m Blocks
preformatted ParsecT Sources ParserState m ()
-> ParsecT Sources ParserState m ()
-> ParsecT Sources ParserState m ()
forall a b.
ParsecT Sources ParserState m a
-> ParsecT Sources ParserState m b
-> ParsecT Sources ParserState m a
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
<*
ParsecT Sources ParserState m Blocks
-> ParsecT Sources 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 Sources ParserState m Blocks
forall (m :: * -> *). PandocMonad m => VwParser m Blocks
displayMath ParsecT Sources ParserState m ()
-> ParsecT Sources ParserState m ()
-> ParsecT Sources ParserState m ()
forall a b.
ParsecT Sources ParserState m a
-> ParsecT Sources ParserState m b
-> ParsecT Sources ParserState m a
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
<*
ParsecT Sources ParserState m ()
-> ParsecT Sources 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 Sources ParserState m ()
forall (m :: * -> *). PandocMonad m => VwParser m ()
hasDefMarker
hasDefMarker :: PandocMonad m => VwParser m ()
hasDefMarker :: forall (m :: * -> *). PandocMonad m => VwParser m ()
hasDefMarker = () ()
-> ParsecT Sources ParserState m [Char]
-> ParsecT Sources ParserState m ()
forall a b.
a
-> ParsecT Sources ParserState m b
-> ParsecT Sources ParserState m a
forall (f :: * -> *) a b. Functor f => a -> f b -> f a
<$ ParsecT Sources ParserState m Char
-> ParsecT Sources ParserState m Char
-> ParsecT Sources 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 ([Char] -> ParsecT Sources ParserState m Char
forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
[Char] -> ParsecT s u m Char
noneOf [Char]
"\n") ([Char] -> ParsecT Sources ParserState m [Char]
forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
[Char] -> ParsecT s u m [Char]
string [Char]
"::" ParsecT Sources ParserState m [Char]
-> ParsecT Sources ParserState m Char
-> ParsecT Sources ParserState m Char
forall a b.
ParsecT Sources ParserState m a
-> ParsecT Sources ParserState m b
-> ParsecT Sources ParserState m b
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> [Char] -> ParsecT Sources ParserState m Char
forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
[Char] -> ParsecT s u m Char
oneOf [Char]
spaceChars)
makeTagSpan' :: Text -> Inlines
makeTagSpan' :: Text -> Many Inline
makeTagSpan' Text
s = Attr -> Many Inline -> Many Inline
B.spanWith (Char -> Text -> Text
T.cons Char
'-' Text
s, [], []) (Text -> Many Inline
B.str Text
"") Many Inline -> Many Inline -> Many Inline
forall a. Semigroup a => a -> a -> a
<>
Attr -> Many Inline -> Many Inline
B.spanWith (Text
s, [Text
"tag"], []) (Text -> Many Inline
B.str Text
s)
makeTagSpan :: Text -> Inlines
makeTagSpan :: Text -> Many Inline
makeTagSpan Text
s = Many Inline
B.space Many Inline -> Many Inline -> Many Inline
forall a. Semigroup a => a -> a -> a
<> Text -> Many Inline
makeTagSpan' Text
s
mathTagParser :: PandocMonad m => VwParser m Text
mathTagParser :: forall (m :: * -> *). PandocMonad m => VwParser m Text
mathTagParser = do
s <- ParsecT Sources ParserState m Text
-> ParsecT Sources ParserState m Text
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try (ParsecT Sources ParserState m Text
-> ParsecT Sources ParserState m Text)
-> ParsecT Sources ParserState m Text
-> ParsecT Sources ParserState m Text
forall a b. (a -> b) -> a -> b
$ ParsecT Sources ParserState m Text
-> ParsecT Sources ParserState m Text
forall s (m :: * -> *) t u a.
Stream s m t =>
ParsecT s u m a -> ParsecT s u m a
lookAhead (Char -> ParsecT Sources ParserState m Char
forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
Char -> ParsecT s u m Char
char Char
'%' ParsecT Sources ParserState m Char
-> ParsecT Sources ParserState m Text
-> ParsecT Sources ParserState m Text
forall a b.
ParsecT Sources ParserState m a
-> ParsecT Sources ParserState m b
-> ParsecT Sources ParserState m b
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> ParsecT Sources ParserState m Char
-> ParsecT Sources ParserState m Char
-> ParsecT Sources ParserState m Text
forall s (m :: * -> *) t st a.
Stream s m t =>
ParsecT s st m Char -> ParsecT s st m a -> ParsecT s st m Text
manyTillChar ([Char] -> ParsecT Sources ParserState m Char
forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
[Char] -> ParsecT s u m Char
noneOf [Char]
spaceChars)
(ParsecT Sources ParserState m Char
-> ParsecT Sources ParserState m Char
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try (ParsecT Sources ParserState m Char
-> ParsecT Sources ParserState m Char)
-> ParsecT Sources ParserState m Char
-> ParsecT Sources ParserState m Char
forall a b. (a -> b) -> a -> b
$ Char -> ParsecT Sources ParserState m Char
forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
Char -> ParsecT s u m Char
char Char
'%' ParsecT Sources ParserState m Char
-> ParsecT Sources ParserState m [Char]
-> ParsecT Sources ParserState m [Char]
forall a b.
ParsecT Sources ParserState m a
-> ParsecT Sources ParserState m b
-> ParsecT Sources ParserState m b
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> ParsecT Sources ParserState m Char
-> ParsecT Sources ParserState m [Char]
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m [a]
many ([Char] -> ParsecT Sources ParserState m Char
forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
[Char] -> ParsecT s u m Char
noneOf ([Char] -> ParsecT Sources ParserState m Char)
-> [Char] -> ParsecT Sources ParserState m Char
forall a b. (a -> b) -> a -> b
$ Char
'%'Char -> [Char] -> [Char]
forall a. a -> [a] -> [a]
:[Char]
spaceChars) ParsecT Sources ParserState m [Char]
-> ParsecT Sources ParserState m Char
-> ParsecT Sources ParserState m Char
forall a b.
ParsecT Sources ParserState m a
-> ParsecT Sources ParserState m b
-> ParsecT Sources ParserState m b
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> ParsecT Sources ParserState m Char
forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
ParsecT s u m Char
space))
char '%' >> textStr s >> char '%'
return $ mathTagLaTeX s