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