{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE OverloadedStrings #-}
module Text.Pandoc.Readers.TikiWiki ( readTikiWiki
) where
import Control.Monad
import Control.Monad.Except (throwError)
import qualified Data.Foldable as F
import Data.List (dropWhileEnd)
import Data.Maybe (fromMaybe)
import Data.Text (Text)
import qualified Data.Text as T
import qualified Text.Pandoc.Builder as B
import Text.Pandoc.Class.CommonState (CommonState (..))
import Text.Pandoc.Class.PandocMonad (PandocMonad (..))
import Text.Pandoc.Definition
import Text.Pandoc.Logging (Verbosity (..))
import Text.Pandoc.Options
import Text.Pandoc.Parsing hiding (enclosed)
import Text.Pandoc.Shared (safeRead)
import Text.Pandoc.XML (fromEntities)
import Text.Printf (printf)
readTikiWiki :: (PandocMonad m, ToSources a)
=> ReaderOptions
-> a
-> m Pandoc
readTikiWiki :: forall (m :: * -> *) a.
(PandocMonad m, ToSources a) =>
ReaderOptions -> a -> m Pandoc
readTikiWiki ReaderOptions
opts a
s = do
let sources :: Sources
sources = Int -> Sources -> Sources
ensureFinalNewlines Int
2 (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 => TikiWikiParser m Pandoc
parseTikiWiki 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
d -> Pandoc -> m Pandoc
forall a. a -> m a
forall (m :: * -> *) a. Monad m => a -> m a
return Pandoc
d
type TikiWikiParser = ParsecT Sources ParserState
tryMsg :: Text -> TikiWikiParser m a -> TikiWikiParser m a
tryMsg :: forall (m :: * -> *) a.
Text -> TikiWikiParser m a -> TikiWikiParser m a
tryMsg Text
msg TikiWikiParser m a
p = TikiWikiParser m a -> TikiWikiParser m a
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try TikiWikiParser m a
p TikiWikiParser m a -> String -> TikiWikiParser m a
forall s u (m :: * -> *) a.
ParsecT s u m a -> String -> ParsecT s u m a
<?> Text -> String
T.unpack Text
msg
skip :: TikiWikiParser m a -> TikiWikiParser m ()
skip :: forall (m :: * -> *) a. TikiWikiParser m a -> TikiWikiParser m ()
skip TikiWikiParser m a
parser = TikiWikiParser m a -> ParsecT Sources ParserState m ()
forall (f :: * -> *) a. Functor f => f a -> f ()
Control.Monad.void TikiWikiParser m a
parser
parseTikiWiki :: PandocMonad m => TikiWikiParser m Pandoc
parseTikiWiki :: forall (m :: * -> *). PandocMonad m => TikiWikiParser m Pandoc
parseTikiWiki = 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 => TikiWikiParser m Blocks
block
spaces
eof
return $ B.doc bs
block :: PandocMonad m => TikiWikiParser m B.Blocks
block :: forall (m :: * -> *). PandocMonad m => TikiWikiParser m Blocks
block = do
verbosity <- (CommonState -> Verbosity)
-> ParsecT Sources ParserState m Verbosity
forall a. (CommonState -> a) -> ParsecT Sources ParserState m a
forall (m :: * -> *) a. PandocMonad m => (CommonState -> a) -> m a
getsCommonState CommonState -> Verbosity
stVerbosity
pos <- getPosition
res <- mempty <$ skipMany1 blankline
<|> blockElements
<|> para
skipMany blankline
when (verbosity >= INFO) $
trace (T.pack $ printf "line %d: %s" (sourceLine pos) (take 60 $ show $ B.toList res))
return res
blockElements :: PandocMonad m => TikiWikiParser m B.Blocks
blockElements :: forall (m :: * -> *). PandocMonad m => TikiWikiParser m Blocks
blockElements = [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 => TikiWikiParser m Blocks
table
, ParsecT Sources ParserState m Blocks
forall (m :: * -> *). PandocMonad m => TikiWikiParser m Blocks
hr
, ParsecT Sources ParserState m Blocks
forall (m :: * -> *). PandocMonad m => TikiWikiParser m Blocks
header
, ParsecT Sources ParserState m Blocks
forall (m :: * -> *). PandocMonad m => TikiWikiParser m Blocks
mixedList
, ParsecT Sources ParserState m Blocks
forall (m :: * -> *). PandocMonad m => TikiWikiParser m Blocks
definitionList
, ParsecT Sources ParserState m Blocks
forall (m :: * -> *). PandocMonad m => TikiWikiParser m Blocks
codeMacro
]
hr :: PandocMonad m => TikiWikiParser m B.Blocks
hr :: forall (m :: * -> *). PandocMonad m => TikiWikiParser m Blocks
hr = 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
String -> ParsecT Sources ParserState m String
forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
String -> ParsecT s u m String
string String
"----"
ParsecT Sources ParserState m Char
-> ParsecT Sources ParserState m String
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
forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
ParsecT s u m Char
newline
Blocks -> ParsecT Sources ParserState m Blocks
forall a. a -> ParsecT Sources ParserState m a
forall (m :: * -> *) a. Monad m => a -> m a
return Blocks
B.horizontalRule
header :: PandocMonad m => TikiWikiParser m B.Blocks
= Text -> TikiWikiParser m Blocks -> TikiWikiParser m Blocks
forall (m :: * -> *) a.
Text -> TikiWikiParser m a -> TikiWikiParser m a
tryMsg Text
"header" (TikiWikiParser m Blocks -> TikiWikiParser m Blocks)
-> TikiWikiParser m Blocks -> TikiWikiParser m Blocks
forall a b. (a -> b) -> a -> b
$ do
level <- (String -> Int)
-> ParsecT Sources ParserState m String
-> ParsecT Sources ParserState m Int
forall a b.
(a -> b)
-> ParsecT Sources ParserState m a
-> ParsecT Sources ParserState m b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap String -> Int
forall a. [a] -> Int
forall (t :: * -> *) a. Foldable t => t a -> Int
length (ParsecT Sources ParserState m Char
-> ParsecT Sources ParserState m String
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
'!'))
guard $ level <= 6
skipSpaces
content <- B.trimInlines . mconcat <$> manyTill inline newline
attr <- registerHeader nullAttr content
return $ B.headerWith attr level content
tableRow :: PandocMonad m => TikiWikiParser m [B.Blocks]
tableRow :: forall (m :: * -> *). PandocMonad m => TikiWikiParser 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
row <- ParsecT Sources ParserState m Inlines
-> ParsecT Sources ParserState m String
-> ParsecT Sources ParserState m [Inlines]
forall s (m :: * -> *) t u a end.
Stream s m t =>
ParsecT s u m a -> ParsecT s u m end -> ParsecT s u m [a]
sepBy1 (ParsecT Sources ParserState m Char
-> ParsecT Sources ParserState m String
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m [a]
many1 (String -> ParsecT Sources ParserState m Char
forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
String -> ParsecT s u m Char
noneOf String
"\n|") ParsecT Sources ParserState m String
-> (String -> ParsecT Sources ParserState m Inlines)
-> ParsecT Sources ParserState m Inlines
forall a b.
ParsecT Sources ParserState m a
-> (a -> ParsecT Sources ParserState m b)
-> ParsecT Sources ParserState m b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= Text -> ParsecT Sources ParserState m Inlines
forall {m :: * -> *}.
PandocMonad m =>
Text -> ParsecT Sources ParserState m Inlines
parseColumn (Text -> ParsecT Sources ParserState m Inlines)
-> (String -> Text)
-> String
-> ParsecT Sources ParserState m Inlines
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> Text
T.pack) (ParsecT Sources ParserState m String
-> ParsecT Sources ParserState m String
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try (ParsecT Sources ParserState m String
-> ParsecT Sources ParserState m String)
-> ParsecT Sources ParserState m String
-> ParsecT Sources ParserState m String
forall a b. (a -> b) -> a -> b
$ String -> ParsecT Sources ParserState m String
forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
String -> ParsecT s u m String
string String
"|" ParsecT Sources ParserState m String
-> ParsecT Sources ParserState m ()
-> ParsecT Sources ParserState m String
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 ()
forall s (m :: * -> *) t a u.
(Stream s m t, Show a) =>
ParsecT s u m a -> ParsecT s u m ()
notFollowedBy (String -> ParsecT Sources ParserState m Char
forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
String -> ParsecT s u m Char
oneOf String
"|\n"))
return $ map B.plain row
where
parseColumn :: Text -> ParsecT Sources ParserState m Inlines
parseColumn Text
x = do
parsed <- ParsecT Sources ParserState m [Inlines]
-> Text -> ParsecT Sources ParserState m [Inlines]
forall (m :: * -> *) st r.
Monad m =>
ParsecT Sources st m r -> Text -> ParsecT Sources st m r
parseFromString (ParsecT Sources ParserState m Inlines
-> ParsecT Sources ParserState m [Inlines]
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m [a]
many1 ParsecT Sources ParserState m Inlines
forall (m :: * -> *). PandocMonad m => TikiWikiParser m Inlines
inline) Text
x
return $ mconcat parsed
table :: PandocMonad m => TikiWikiParser m B.Blocks
table :: forall (m :: * -> *). PandocMonad m => TikiWikiParser 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
String -> ParsecT Sources ParserState m String
forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
String -> ParsecT s u m String
string String
"||"
rows <- ParsecT Sources ParserState m [Blocks]
-> ParsecT Sources ParserState m String
-> ParsecT Sources ParserState m [[Blocks]]
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]
sepBy1 ParsecT Sources ParserState m [Blocks]
forall (m :: * -> *). PandocMonad m => TikiWikiParser m [Blocks]
tableRow (ParsecT Sources ParserState m String
-> ParsecT Sources ParserState m String
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try (ParsecT Sources ParserState m String
-> ParsecT Sources ParserState m String)
-> ParsecT Sources ParserState m String
-> ParsecT Sources ParserState m String
forall a b. (a -> b) -> a -> b
$ String -> ParsecT Sources ParserState m String
forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
String -> ParsecT s u m String
string String
"\n" ParsecT Sources ParserState m String
-> ParsecT Sources ParserState m String
-> ParsecT Sources ParserState m String
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> (String -> ParsecT Sources ParserState m String
forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
String -> ParsecT s u m String
string String
"||" ParsecT Sources ParserState m String
-> ParsecT Sources ParserState m ()
-> ParsecT Sources ParserState m String
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 String
-> 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 (String -> ParsecT Sources ParserState m String
forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
String -> ParsecT s u m String
string String
"\n")))
string "||"
newline
return $ B.simpleTable (headers rows) rows
where
headers :: [t a] -> [Blocks]
headers [] = []
headers (t a
r:[t a]
_) = Int -> Blocks -> [Blocks]
forall a. Int -> a -> [a]
replicate (t a -> Int
forall a. t a -> Int
forall (t :: * -> *) a. Foldable t => t a -> Int
length t a
r) ((Inlines -> Blocks
B.plain (Inlines -> Blocks) -> (Text -> Inlines) -> Text -> Blocks
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Text -> Inlines
B.str) Text
"")
para :: PandocMonad m => TikiWikiParser m B.Blocks
para :: forall (m :: * -> *). PandocMonad m => TikiWikiParser m Blocks
para = ([Inlines] -> Blocks)
-> ParsecT Sources ParserState m [Inlines]
-> ParsecT Sources ParserState m Blocks
forall a b.
(a -> b)
-> ParsecT Sources ParserState m a
-> ParsecT Sources ParserState m b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (Inlines -> Blocks
result (Inlines -> Blocks)
-> ([Inlines] -> Inlines) -> [Inlines] -> Blocks
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [Inlines] -> Inlines
forall a. Monoid a => [a] -> a
mconcat) ( ParsecT Sources ParserState m Inlines
-> ParsecT Sources ParserState m ()
-> ParsecT Sources ParserState m [Inlines]
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 Inlines
forall (m :: * -> *). PandocMonad m => TikiWikiParser m Inlines
inline ParsecT Sources ParserState m ()
endOfParaElement)
where
endOfParaElement :: ParsecT Sources ParserState m ()
endOfParaElement = 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 (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 ()
forall {u}. ParsecT Sources u m ()
endOfInput 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 {u}. ParsecT Sources u m ()
endOfPara 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 ()
newBlockElement
endOfInput :: ParsecT Sources u m ()
endOfInput = ParsecT Sources u m () -> ParsecT Sources u m ()
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try (ParsecT Sources u m () -> ParsecT Sources u m ())
-> ParsecT Sources u m () -> ParsecT Sources u m ()
forall a b. (a -> b) -> a -> b
$ ParsecT Sources u m Char -> ParsecT Sources u m ()
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m ()
skipMany ParsecT Sources u m Char
forall s (m :: * -> *) st.
(Stream s m Char, UpdateSourcePos s Char) =>
ParsecT s st m Char
blankline ParsecT Sources u m ()
-> ParsecT Sources u m () -> ParsecT Sources u m ()
forall a b.
ParsecT Sources u m a
-> ParsecT Sources u m b -> ParsecT Sources u m b
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> ParsecT Sources u m ()
forall s (m :: * -> *) st.
(Stream s m Char, UpdateSourcePos s Char) =>
ParsecT s st m ()
skipSpaces ParsecT Sources u m ()
-> ParsecT Sources u m () -> ParsecT Sources u m ()
forall a b.
ParsecT Sources u m a
-> ParsecT Sources u m b -> ParsecT Sources u m b
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> ParsecT Sources u m ()
forall s (m :: * -> *) t u.
(Stream s m t, Show t) =>
ParsecT s u m ()
eof
endOfPara :: ParsecT Sources u m ()
endOfPara = ParsecT Sources u m () -> ParsecT Sources u m ()
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try (ParsecT Sources u m () -> ParsecT Sources u m ())
-> ParsecT Sources u m () -> ParsecT Sources u m ()
forall a b. (a -> b) -> a -> b
$ ParsecT Sources u m Char
forall s (m :: * -> *) st.
(Stream s m Char, UpdateSourcePos s Char) =>
ParsecT s st m Char
blankline ParsecT Sources u m Char
-> ParsecT Sources u m () -> ParsecT Sources u m ()
forall a b.
ParsecT Sources u m a
-> ParsecT Sources u m b -> ParsecT Sources u m b
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> ParsecT Sources u m Char -> ParsecT Sources u m ()
forall s (m :: * -> *) t u a.
Stream s m t =>
ParsecT s u m a -> ParsecT s u m ()
skipMany1 ParsecT Sources u m Char
forall s (m :: * -> *) st.
(Stream s m Char, UpdateSourcePos s Char) =>
ParsecT s st m Char
blankline
newBlockElement :: ParsecT Sources ParserState m ()
newBlockElement = 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
forall s (m :: * -> *) st.
(Stream s m Char, UpdateSourcePos s Char) =>
ParsecT s st m Char
blankline 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 (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> ParsecT Sources ParserState m Blocks
-> ParsecT Sources ParserState m ()
forall (m :: * -> *) a. TikiWikiParser m a -> TikiWikiParser m ()
skip ParsecT Sources ParserState m Blocks
forall (m :: * -> *). PandocMonad m => TikiWikiParser m Blocks
blockElements
result :: Inlines -> Blocks
result Inlines
content = if (Inline -> Bool) -> Inlines -> Bool
forall (t :: * -> *) a. Foldable t => (a -> Bool) -> t a -> Bool
F.all (Inline -> Inline -> Bool
forall a. Eq a => a -> a -> Bool
==Inline
Space) Inlines
content
then Blocks
forall a. Monoid a => a
mempty
else Inlines -> Blocks
B.para (Inlines -> Blocks) -> Inlines -> Blocks
forall a b. (a -> b) -> a -> b
$ Inlines -> Inlines
B.trimInlines Inlines
content
definitionList :: PandocMonad m => TikiWikiParser m B.Blocks
definitionList :: forall (m :: * -> *). PandocMonad m => TikiWikiParser m Blocks
definitionList = Text -> TikiWikiParser m Blocks -> TikiWikiParser m Blocks
forall (m :: * -> *) a.
Text -> TikiWikiParser m a -> TikiWikiParser m a
tryMsg Text
"definitionList" (TikiWikiParser m Blocks -> TikiWikiParser m Blocks)
-> TikiWikiParser m Blocks -> TikiWikiParser m Blocks
forall a b. (a -> b) -> a -> b
$ do
elements <-ParsecT Sources ParserState m (Inlines, [Blocks])
-> ParsecT Sources ParserState m [(Inlines, [Blocks])]
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m [a]
many1 ParsecT Sources ParserState m (Inlines, [Blocks])
forall (m :: * -> *).
PandocMonad m =>
TikiWikiParser m (Inlines, [Blocks])
parseDefinitionListItem
return $ B.definitionList elements
where
parseDefinitionListItem :: PandocMonad m => TikiWikiParser m (B.Inlines, [B.Blocks])
parseDefinitionListItem :: forall (m :: * -> *).
PandocMonad m =>
TikiWikiParser m (Inlines, [Blocks])
parseDefinitionListItem = do
ParsecT Sources ParserState m ()
forall s (m :: * -> *) st.
(Stream s m Char, UpdateSourcePos s Char) =>
ParsecT s st m ()
skipSpaces 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
>> 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 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 s (m :: * -> *) st.
(Stream s m Char, UpdateSourcePos s Char) =>
ParsecT s st m ()
skipSpaces
term <- ParsecT Sources ParserState m Inlines
-> ParsecT Sources ParserState m Char
-> ParsecT Sources ParserState m [Inlines]
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 Inlines
forall (m :: * -> *). PandocMonad m => TikiWikiParser m Inlines
inline (ParsecT Sources ParserState m Char
-> ParsecT Sources ParserState m [Inlines])
-> ParsecT Sources ParserState m Char
-> ParsecT Sources ParserState m [Inlines]
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 ()
-> 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 s (m :: * -> *) st.
(Stream s m Char, UpdateSourcePos s Char) =>
ParsecT s st m ()
skipSpaces
line <- listItemLine 1
return (mconcat term, [B.plain line])
data ListType = None | Numbered | Bullet deriving (Eq ListType
Eq ListType =>
(ListType -> ListType -> Ordering)
-> (ListType -> ListType -> Bool)
-> (ListType -> ListType -> Bool)
-> (ListType -> ListType -> Bool)
-> (ListType -> ListType -> Bool)
-> (ListType -> ListType -> ListType)
-> (ListType -> ListType -> ListType)
-> Ord ListType
ListType -> ListType -> Bool
ListType -> ListType -> Ordering
ListType -> ListType -> ListType
forall a.
Eq a =>
(a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
$ccompare :: ListType -> ListType -> Ordering
compare :: ListType -> ListType -> Ordering
$c< :: ListType -> ListType -> Bool
< :: ListType -> ListType -> Bool
$c<= :: ListType -> ListType -> Bool
<= :: ListType -> ListType -> Bool
$c> :: ListType -> ListType -> Bool
> :: ListType -> ListType -> Bool
$c>= :: ListType -> ListType -> Bool
>= :: ListType -> ListType -> Bool
$cmax :: ListType -> ListType -> ListType
max :: ListType -> ListType -> ListType
$cmin :: ListType -> ListType -> ListType
min :: ListType -> ListType -> ListType
Ord, ListType -> ListType -> Bool
(ListType -> ListType -> Bool)
-> (ListType -> ListType -> Bool) -> Eq ListType
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: ListType -> ListType -> Bool
== :: ListType -> ListType -> Bool
$c/= :: ListType -> ListType -> Bool
/= :: ListType -> ListType -> Bool
Eq, Int -> ListType -> String -> String
[ListType] -> String -> String
ListType -> String
(Int -> ListType -> String -> String)
-> (ListType -> String)
-> ([ListType] -> String -> String)
-> Show ListType
forall a.
(Int -> a -> String -> String)
-> (a -> String) -> ([a] -> String -> String) -> Show a
$cshowsPrec :: Int -> ListType -> String -> String
showsPrec :: Int -> ListType -> String -> String
$cshow :: ListType -> String
show :: ListType -> String
$cshowList :: [ListType] -> String -> String
showList :: [ListType] -> String -> String
Show)
data ListNesting = LN { ListNesting -> ListType
lntype :: ListType, ListNesting -> Int
lnnest :: Int } deriving (Eq ListNesting
Eq ListNesting =>
(ListNesting -> ListNesting -> Ordering)
-> (ListNesting -> ListNesting -> Bool)
-> (ListNesting -> ListNesting -> Bool)
-> (ListNesting -> ListNesting -> Bool)
-> (ListNesting -> ListNesting -> Bool)
-> (ListNesting -> ListNesting -> ListNesting)
-> (ListNesting -> ListNesting -> ListNesting)
-> Ord ListNesting
ListNesting -> ListNesting -> Bool
ListNesting -> ListNesting -> Ordering
ListNesting -> ListNesting -> ListNesting
forall a.
Eq a =>
(a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
$ccompare :: ListNesting -> ListNesting -> Ordering
compare :: ListNesting -> ListNesting -> Ordering
$c< :: ListNesting -> ListNesting -> Bool
< :: ListNesting -> ListNesting -> Bool
$c<= :: ListNesting -> ListNesting -> Bool
<= :: ListNesting -> ListNesting -> Bool
$c> :: ListNesting -> ListNesting -> Bool
> :: ListNesting -> ListNesting -> Bool
$c>= :: ListNesting -> ListNesting -> Bool
>= :: ListNesting -> ListNesting -> Bool
$cmax :: ListNesting -> ListNesting -> ListNesting
max :: ListNesting -> ListNesting -> ListNesting
$cmin :: ListNesting -> ListNesting -> ListNesting
min :: ListNesting -> ListNesting -> ListNesting
Ord, ListNesting -> ListNesting -> Bool
(ListNesting -> ListNesting -> Bool)
-> (ListNesting -> ListNesting -> Bool) -> Eq ListNesting
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: ListNesting -> ListNesting -> Bool
== :: ListNesting -> ListNesting -> Bool
$c/= :: ListNesting -> ListNesting -> Bool
/= :: ListNesting -> ListNesting -> Bool
Eq, Int -> ListNesting -> String -> String
[ListNesting] -> String -> String
ListNesting -> String
(Int -> ListNesting -> String -> String)
-> (ListNesting -> String)
-> ([ListNesting] -> String -> String)
-> Show ListNesting
forall a.
(Int -> a -> String -> String)
-> (a -> String) -> ([a] -> String -> String) -> Show a
$cshowsPrec :: Int -> ListNesting -> String -> String
showsPrec :: Int -> ListNesting -> String -> String
$cshow :: ListNesting -> String
show :: ListNesting -> String
$cshowList :: [ListNesting] -> String -> String
showList :: [ListNesting] -> String -> String
Show)
mixedList :: PandocMonad m => TikiWikiParser m B.Blocks
mixedList :: forall (m :: * -> *). PandocMonad m => TikiWikiParser 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
items <- ParsecT Sources ParserState m [(ListNesting, Blocks)]
-> ParsecT Sources ParserState m [(ListNesting, Blocks)]
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try (ParsecT Sources ParserState m [(ListNesting, Blocks)]
-> ParsecT Sources ParserState m [(ListNesting, Blocks)])
-> ParsecT Sources ParserState m [(ListNesting, Blocks)]
-> ParsecT Sources ParserState m [(ListNesting, Blocks)]
forall a b. (a -> b) -> a -> b
$ ParsecT Sources ParserState m (ListNesting, Blocks)
-> ParsecT Sources ParserState m [(ListNesting, Blocks)]
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m [a]
many1 ParsecT Sources ParserState m (ListNesting, Blocks)
forall (m :: * -> *).
PandocMonad m =>
TikiWikiParser m (ListNesting, Blocks)
listItem
return $ mconcat $ fixListNesting $ spanFoldUpList (LN None 0) items
fixListNesting :: [B.Blocks] -> [B.Blocks]
fixListNesting :: [Blocks] -> [Blocks]
fixListNesting [] = []
fixListNesting [Blocks
first] = [Blocks -> Blocks
recurseOnList Blocks
first]
fixListNesting (Blocks
first:Blocks
second:[Blocks]
rest) =
case Blocks -> [Block]
forall a. Many a -> [a]
B.toList Blocks
second of
(BulletList [[Block]]
_ : [Block]
_) -> [Blocks] -> [Blocks]
fixListNesting ([Blocks] -> [Blocks]) -> [Blocks] -> [Blocks]
forall a b. (a -> b) -> a -> b
$ Blocks -> Blocks -> Blocks
forall a. Monoid a => a -> a -> a
mappend (Blocks -> Blocks
recurseOnList Blocks
first) (Blocks -> Blocks
recurseOnList Blocks
second) Blocks -> [Blocks] -> [Blocks]
forall a. a -> [a] -> [a]
: [Blocks]
rest
(OrderedList ListAttributes
_ [[Block]]
_ : [Block]
_) -> [Blocks] -> [Blocks]
fixListNesting ([Blocks] -> [Blocks]) -> [Blocks] -> [Blocks]
forall a b. (a -> b) -> a -> b
$ Blocks -> Blocks -> Blocks
forall a. Monoid a => a -> a -> a
mappend (Blocks -> Blocks
recurseOnList Blocks
first) (Blocks -> Blocks
recurseOnList Blocks
second) Blocks -> [Blocks] -> [Blocks]
forall a. a -> [a] -> [a]
: [Blocks]
rest
[Block]
_ -> Blocks -> Blocks
recurseOnList Blocks
first Blocks -> [Blocks] -> [Blocks]
forall a. a -> [a] -> [a]
: [Blocks] -> [Blocks]
fixListNesting (Blocks
secondBlocks -> [Blocks] -> [Blocks]
forall a. a -> [a] -> [a]
:[Blocks]
rest)
recurseOnList :: B.Blocks -> B.Blocks
recurseOnList :: Blocks -> Blocks
recurseOnList Blocks
items
| [Block] -> Int
forall a. [a] -> Int
forall (t :: * -> *) a. Foldable t => t a -> Int
length (Blocks -> [Block]
forall a. Many a -> [a]
B.toList Blocks
items) Int -> Int -> Bool
forall a. Eq a => a -> a -> Bool
== Int
1 =
case Blocks -> [Block]
forall a. Many a -> [a]
B.toList Blocks
items of
(BulletList [[Block]]
listItems : [Block]
_) -> [Blocks] -> Blocks
B.bulletList ([Blocks] -> Blocks) -> [Blocks] -> Blocks
forall a b. (a -> b) -> a -> b
$ [Blocks] -> [Blocks]
fixListNesting ([Blocks] -> [Blocks]) -> [Blocks] -> [Blocks]
forall a b. (a -> b) -> a -> b
$ ([Block] -> Blocks) -> [[Block]] -> [Blocks]
forall a b. (a -> b) -> [a] -> [b]
map [Block] -> Blocks
forall a. [a] -> Many a
B.fromList [[Block]]
listItems
(OrderedList ListAttributes
_ [[Block]]
listItems : [Block]
_) -> [Blocks] -> Blocks
B.orderedList ([Blocks] -> Blocks) -> [Blocks] -> Blocks
forall a b. (a -> b) -> a -> b
$ [Blocks] -> [Blocks]
fixListNesting ([Blocks] -> [Blocks]) -> [Blocks] -> [Blocks]
forall a b. (a -> b) -> a -> b
$ ([Block] -> Blocks) -> [[Block]] -> [Blocks]
forall a b. (a -> b) -> [a] -> [b]
map [Block] -> Blocks
forall a. [a] -> Many a
B.fromList [[Block]]
listItems
[Block]
_ -> Blocks
items
| Bool
otherwise = Blocks
items
spanFoldUpList :: ListNesting -> [(ListNesting, B.Blocks)] -> [B.Blocks]
spanFoldUpList :: ListNesting -> [(ListNesting, Blocks)] -> [Blocks]
spanFoldUpList ListNesting
_ [] = []
spanFoldUpList ListNesting
ln [(ListNesting, Blocks)
first] =
ListNesting -> ListNesting -> [Blocks] -> [Blocks]
listWrap ListNesting
ln ((ListNesting, Blocks) -> ListNesting
forall a b. (a, b) -> a
fst (ListNesting, Blocks)
first) [(ListNesting, Blocks) -> Blocks
forall a b. (a, b) -> b
snd (ListNesting, Blocks)
first]
spanFoldUpList ListNesting
ln ((ListNesting, Blocks)
first:[(ListNesting, Blocks)]
rest) =
let ([(ListNesting, Blocks)]
span1, [(ListNesting, Blocks)]
span2) = ((ListNesting, Blocks) -> Bool)
-> [(ListNesting, Blocks)]
-> ([(ListNesting, Blocks)], [(ListNesting, Blocks)])
forall a. (a -> Bool) -> [a] -> ([a], [a])
span (ListNesting -> (ListNesting, Blocks) -> Bool
splitListNesting ((ListNesting, Blocks) -> ListNesting
forall a b. (a, b) -> a
fst (ListNesting, Blocks)
first)) [(ListNesting, Blocks)]
rest
newTree1 :: [Blocks]
newTree1 = ListNesting -> ListNesting -> [Blocks] -> [Blocks]
listWrap ListNesting
ln ((ListNesting, Blocks) -> ListNesting
forall a b. (a, b) -> a
fst (ListNesting, Blocks)
first) ([Blocks] -> [Blocks]) -> [Blocks] -> [Blocks]
forall a b. (a -> b) -> a -> b
$ (ListNesting, Blocks) -> Blocks
forall a b. (a, b) -> b
snd (ListNesting, Blocks)
first Blocks -> [Blocks] -> [Blocks]
forall a. a -> [a] -> [a]
: ListNesting -> [(ListNesting, Blocks)] -> [Blocks]
spanFoldUpList ((ListNesting, Blocks) -> ListNesting
forall a b. (a, b) -> a
fst (ListNesting, Blocks)
first) [(ListNesting, Blocks)]
span1
newTree2 :: [Blocks]
newTree2 = ListNesting -> [(ListNesting, Blocks)] -> [Blocks]
spanFoldUpList ListNesting
ln [(ListNesting, Blocks)]
span2
in
[Blocks]
newTree1 [Blocks] -> [Blocks] -> [Blocks]
forall a. [a] -> [a] -> [a]
++ [Blocks]
newTree2
splitListNesting :: ListNesting -> (ListNesting, B.Blocks) -> Bool
splitListNesting :: ListNesting -> (ListNesting, Blocks) -> Bool
splitListNesting ListNesting
ln1 (ListNesting
ln2, Blocks
_)
| ListNesting -> Int
lnnest ListNesting
ln1 Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
< ListNesting -> Int
lnnest ListNesting
ln2 =
Bool
True
| ListNesting
ln1 ListNesting -> ListNesting -> Bool
forall a. Eq a => a -> a -> Bool
== ListNesting
ln2 =
Bool
True
| Bool
otherwise =
Bool
False
listWrap :: ListNesting -> ListNesting -> [B.Blocks] -> [B.Blocks]
listWrap :: ListNesting -> ListNesting -> [Blocks] -> [Blocks]
listWrap ListNesting
upperLN ListNesting
curLN [Blocks]
retTree =
if ListNesting
upperLN ListNesting -> ListNesting -> Bool
forall a. Eq a => a -> a -> Bool
== ListNesting
curLN then
[Blocks]
retTree
else
case ListNesting -> ListType
lntype ListNesting
curLN of
ListType
None -> []
ListType
Bullet -> [[Blocks] -> Blocks
B.bulletList [Blocks]
retTree]
ListType
Numbered -> [[Blocks] -> Blocks
B.orderedList [Blocks]
retTree]
listItem :: PandocMonad m => TikiWikiParser m (ListNesting, B.Blocks)
listItem :: forall (m :: * -> *).
PandocMonad m =>
TikiWikiParser m (ListNesting, Blocks)
listItem = [ParsecT Sources ParserState m (ListNesting, Blocks)]
-> ParsecT Sources ParserState m (ListNesting, 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 (ListNesting, Blocks)
forall (m :: * -> *).
PandocMonad m =>
TikiWikiParser m (ListNesting, Blocks)
bulletItem
, ParsecT Sources ParserState m (ListNesting, Blocks)
forall (m :: * -> *).
PandocMonad m =>
TikiWikiParser m (ListNesting, Blocks)
numberedItem
]
bulletItem :: PandocMonad m => TikiWikiParser m (ListNesting, B.Blocks)
bulletItem :: forall (m :: * -> *).
PandocMonad m =>
TikiWikiParser m (ListNesting, Blocks)
bulletItem = ParsecT Sources ParserState m (ListNesting, Blocks)
-> ParsecT Sources ParserState m (ListNesting, Blocks)
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try (ParsecT Sources ParserState m (ListNesting, Blocks)
-> ParsecT Sources ParserState m (ListNesting, Blocks))
-> ParsecT Sources ParserState m (ListNesting, Blocks)
-> ParsecT Sources ParserState m (ListNesting, Blocks)
forall a b. (a -> b) -> a -> b
$ do
prefix <- ParsecT Sources ParserState m Char
-> ParsecT Sources ParserState m String
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 String)
-> ParsecT Sources ParserState m Char
-> ParsecT Sources ParserState m String
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
'*'
many $ char ' '
content <- listItemLine (length prefix)
return (LN Bullet (length prefix), B.plain content)
numberedItem :: PandocMonad m => TikiWikiParser m (ListNesting, B.Blocks)
numberedItem :: forall (m :: * -> *).
PandocMonad m =>
TikiWikiParser m (ListNesting, Blocks)
numberedItem = ParsecT Sources ParserState m (ListNesting, Blocks)
-> ParsecT Sources ParserState m (ListNesting, Blocks)
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try (ParsecT Sources ParserState m (ListNesting, Blocks)
-> ParsecT Sources ParserState m (ListNesting, Blocks))
-> ParsecT Sources ParserState m (ListNesting, Blocks)
-> ParsecT Sources ParserState m (ListNesting, Blocks)
forall a b. (a -> b) -> a -> b
$ do
prefix <- ParsecT Sources ParserState m Char
-> ParsecT Sources ParserState m String
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 String)
-> ParsecT Sources ParserState m Char
-> ParsecT Sources ParserState m String
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
'#'
many $ char ' '
content <- listItemLine (length prefix)
return (LN Numbered (length prefix), B.plain content)
listItemLine :: PandocMonad m => Int -> TikiWikiParser m B.Inlines
listItemLine :: forall (m :: * -> *).
PandocMonad m =>
Int -> TikiWikiParser m Inlines
listItemLine Int
nest = ParsecT Sources ParserState m Text
forall {st}. ParsecT Sources st m Text
lineContent ParsecT Sources ParserState m Text
-> (Text -> ParsecT Sources ParserState m Inlines)
-> ParsecT Sources ParserState m Inlines
forall a b.
ParsecT Sources ParserState m a
-> (a -> ParsecT Sources ParserState m b)
-> ParsecT Sources ParserState m b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= Text -> ParsecT Sources ParserState m Inlines
forall {m :: * -> *}.
PandocMonad m =>
Text -> ParsecT Sources ParserState m Inlines
parseContent
where
lineContent :: ParsecT Sources st m Text
lineContent = do
content <- ParsecT Sources st m Text
forall (m :: * -> *) st. Monad m => ParsecT Sources st m Text
anyLine
continuation <- optionMaybe listContinuation
return $ filterSpaces content <> "\n" <> Data.Maybe.fromMaybe "" continuation
filterSpaces :: Text -> Text
filterSpaces = (Char -> Bool) -> Text -> Text
T.dropWhileEnd (Char -> Char -> Bool
forall a. Eq a => a -> a -> Bool
== Char
' ')
listContinuation :: ParsecT Sources st m Text
listContinuation = String -> ParsecT Sources st m String
forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
String -> ParsecT s u m String
string (Int -> Char -> String
forall a. Int -> a -> [a]
replicate Int
nest Char
'+') ParsecT Sources st m String
-> ParsecT Sources st m Text -> ParsecT Sources st m Text
forall a b.
ParsecT Sources st m a
-> ParsecT Sources st m b -> ParsecT Sources st m b
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> ParsecT Sources st m Text
lineContent
parseContent :: Text -> ParsecT Sources ParserState m Inlines
parseContent Text
x = do
parsed <- ParsecT Sources ParserState m [Inlines]
-> Text -> ParsecT Sources ParserState m [Inlines]
forall (m :: * -> *) st r.
Monad m =>
ParsecT Sources st m r -> Text -> ParsecT Sources st m r
parseFromString (ParsecT Sources ParserState m Inlines
-> ParsecT Sources ParserState m [Inlines]
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m [a]
many1 ParsecT Sources ParserState m Inlines
forall (m :: * -> *). PandocMonad m => TikiWikiParser m Inlines
inline) Text
x
return $ mconcat $ dropWhileEnd (== B.space) parsed
mungeAttrs :: [(Text, Text)] -> (Text, [Text], [(Text, Text)])
mungeAttrs :: [(Text, Text)] -> Attr
mungeAttrs [(Text, Text)]
rawAttrs = (Text
"", [Text]
classes, [(Text, Text)]
rawAttrs)
where
color :: Text
color = Text -> Maybe Text -> Text
forall a. a -> Maybe a -> a
fromMaybe Text
"" (Maybe Text -> Text) -> Maybe Text -> Text
forall a b. (a -> b) -> a -> b
$ Text -> [(Text, Text)] -> Maybe Text
forall a b. Eq a => a -> [(a, b)] -> Maybe b
lookup Text
"colors" [(Text, Text)]
rawAttrs
lnRaw :: Text
lnRaw = Text -> Maybe Text -> Text
forall a. a -> Maybe a -> a
fromMaybe Text
"1" (Maybe Text -> Text) -> Maybe Text -> Text
forall a b. (a -> b) -> a -> b
$ Text -> [(Text, Text)] -> Maybe Text
forall a b. Eq a => a -> [(a, b)] -> Maybe b
lookup Text
"ln" [(Text, Text)]
rawAttrs
ln :: Text
ln = if Text
lnRaw Text -> Text -> Bool
forall a. Eq a => a -> a -> Bool
== Text
"0" then
Text
""
else
Text
"numberLines"
classes :: [Text]
classes = (Text -> Bool) -> [Text] -> [Text]
forall a. (a -> Bool) -> [a] -> [a]
filter (Text -> Text -> Bool
forall a. Eq a => a -> a -> Bool
/= Text
"") [Text
color, Text
ln]
codeMacro :: PandocMonad m => TikiWikiParser m B.Blocks
codeMacro :: forall (m :: * -> *). PandocMonad m => TikiWikiParser m Blocks
codeMacro = 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
String -> ParsecT Sources ParserState m String
forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
String -> ParsecT s u m String
string String
"{CODE("
rawAttrs <- TikiWikiParser m [(Text, Text)]
forall (m :: * -> *).
PandocMonad m =>
TikiWikiParser m [(Text, Text)]
macroAttrs
string ")}"
body <- T.pack <$> manyTill anyChar (try (string "{CODE}"))
newline
if not (null rawAttrs)
then
return $ B.codeBlockWith (mungeAttrs rawAttrs) body
else
return $ B.codeBlock body
inline :: PandocMonad m => TikiWikiParser m B.Inlines
inline :: forall (m :: * -> *). PandocMonad m => TikiWikiParser m Inlines
inline = [ParsecT Sources ParserState m Inlines]
-> ParsecT Sources ParserState m Inlines
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 Inlines
forall (m :: * -> *). PandocMonad m => TikiWikiParser m Inlines
whitespace
, ParsecT Sources ParserState m Inlines
forall (m :: * -> *). PandocMonad m => TikiWikiParser m Inlines
noparse
, ParsecT Sources ParserState m Inlines
forall (m :: * -> *). PandocMonad m => TikiWikiParser m Inlines
strong
, ParsecT Sources ParserState m Inlines
forall (m :: * -> *). PandocMonad m => TikiWikiParser m Inlines
emph
, ParsecT Sources ParserState m Inlines
forall (m :: * -> *). PandocMonad m => TikiWikiParser m Inlines
nbsp
, ParsecT Sources ParserState m Inlines
forall (m :: * -> *). PandocMonad m => TikiWikiParser m Inlines
image
, ParsecT Sources ParserState m Inlines
forall (m :: * -> *). PandocMonad m => TikiWikiParser m Inlines
htmlComment
, ParsecT Sources ParserState m Inlines
forall (m :: * -> *). PandocMonad m => TikiWikiParser m Inlines
strikeout
, ParsecT Sources ParserState m Inlines
forall (m :: * -> *). PandocMonad m => TikiWikiParser m Inlines
code
, ParsecT Sources ParserState m Inlines
forall (m :: * -> *). PandocMonad m => TikiWikiParser m Inlines
wikiLink
, ParsecT Sources ParserState m Inlines
forall (m :: * -> *). PandocMonad m => TikiWikiParser m Inlines
notExternalLink
, ParsecT Sources ParserState m Inlines
forall (m :: * -> *). PandocMonad m => TikiWikiParser m Inlines
externalLink
, ParsecT Sources ParserState m Inlines
forall (m :: * -> *). PandocMonad m => TikiWikiParser m Inlines
superTag
, ParsecT Sources ParserState m Inlines
forall (m :: * -> *). PandocMonad m => TikiWikiParser m Inlines
superMacro
, ParsecT Sources ParserState m Inlines
forall (m :: * -> *). PandocMonad m => TikiWikiParser m Inlines
subTag
, ParsecT Sources ParserState m Inlines
forall (m :: * -> *). PandocMonad m => TikiWikiParser m Inlines
subMacro
, ParsecT Sources ParserState m Inlines
forall (m :: * -> *). PandocMonad m => TikiWikiParser m Inlines
escapedChar
, ParsecT Sources ParserState m Inlines
forall (m :: * -> *). PandocMonad m => TikiWikiParser m Inlines
colored
, ParsecT Sources ParserState m Inlines
forall (m :: * -> *). PandocMonad m => TikiWikiParser m Inlines
centered
, ParsecT Sources ParserState m Inlines
forall (m :: * -> *). PandocMonad m => TikiWikiParser m Inlines
underlined
, ParsecT Sources ParserState m Inlines
forall (m :: * -> *). PandocMonad m => TikiWikiParser m Inlines
boxed
, ParsecT Sources ParserState m Inlines
forall (m :: * -> *). PandocMonad m => TikiWikiParser m Inlines
breakChars
, ParsecT Sources ParserState m Inlines
forall (m :: * -> *). PandocMonad m => TikiWikiParser m Inlines
str
, ParsecT Sources ParserState m Inlines
forall (m :: * -> *). PandocMonad m => TikiWikiParser m Inlines
symbol
] ParsecT Sources ParserState m Inlines
-> String -> ParsecT Sources ParserState m Inlines
forall s u (m :: * -> *) a.
ParsecT s u m a -> String -> ParsecT s u m a
<?> String
"inline"
whitespace :: PandocMonad m => TikiWikiParser m B.Inlines
whitespace :: forall (m :: * -> *). PandocMonad m => TikiWikiParser m Inlines
whitespace = ParsecT Sources ParserState m Inlines
lb ParsecT Sources ParserState m Inlines
-> ParsecT Sources ParserState m Inlines
-> ParsecT Sources ParserState m Inlines
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> ParsecT Sources ParserState m Inlines
forall {u}. ParsecT Sources u m Inlines
regsp
where lb :: ParsecT Sources ParserState m Inlines
lb = ParsecT Sources ParserState m Inlines
-> ParsecT Sources ParserState m Inlines
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try (ParsecT Sources ParserState m Inlines
-> ParsecT Sources ParserState m Inlines)
-> ParsecT Sources ParserState m Inlines
-> ParsecT Sources ParserState m Inlines
forall a b. (a -> b) -> a -> b
$ ParsecT Sources ParserState m Char
-> ParsecT Sources ParserState m ()
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m ()
skipMany 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 Inlines
-> ParsecT Sources ParserState m Inlines
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 Inlines
forall (m :: * -> *). PandocMonad m => TikiWikiParser m Inlines
linebreak ParsecT Sources ParserState m Inlines
-> ParsecT Sources ParserState m Inlines
-> ParsecT Sources ParserState m Inlines
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
>> Inlines -> ParsecT Sources ParserState m Inlines
forall a. a -> ParsecT Sources ParserState m a
forall (m :: * -> *) a. Monad m => a -> m a
return Inlines
B.space
regsp :: ParsecT Sources u m Inlines
regsp = ParsecT Sources u m Inlines -> ParsecT Sources u m Inlines
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try (ParsecT Sources u m Inlines -> ParsecT Sources u m Inlines)
-> ParsecT Sources u m Inlines -> ParsecT Sources u m Inlines
forall a b. (a -> b) -> a -> b
$ ParsecT Sources u m Char -> ParsecT Sources u m ()
forall s (m :: * -> *) t u a.
Stream s m t =>
ParsecT s u m a -> ParsecT s u m ()
skipMany1 ParsecT Sources u m Char
forall s (m :: * -> *) st.
(Stream s m Char, UpdateSourcePos s Char) =>
ParsecT s st m Char
spaceChar ParsecT Sources u m ()
-> ParsecT Sources u m Inlines -> ParsecT Sources u m Inlines
forall a b.
ParsecT Sources u m a
-> ParsecT Sources u m b -> ParsecT Sources u m b
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> Inlines -> ParsecT Sources u m Inlines
forall a. a -> ParsecT Sources u m a
forall (m :: * -> *) a. Monad m => a -> m a
return Inlines
B.space
nbsp :: PandocMonad m => TikiWikiParser m B.Inlines
nbsp :: forall (m :: * -> *). PandocMonad m => TikiWikiParser m Inlines
nbsp = ParsecT Sources ParserState m Inlines
-> ParsecT Sources ParserState m Inlines
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try (ParsecT Sources ParserState m Inlines
-> ParsecT Sources ParserState m Inlines)
-> ParsecT Sources ParserState m Inlines
-> ParsecT Sources ParserState m Inlines
forall a b. (a -> b) -> a -> b
$ do
String -> ParsecT Sources ParserState m String
forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
String -> ParsecT s u m String
string String
"~hs~"
Inlines -> ParsecT Sources ParserState m Inlines
forall a. a -> ParsecT Sources ParserState m a
forall (m :: * -> *) a. Monad m => a -> m a
return (Inlines -> ParsecT Sources ParserState m Inlines)
-> Inlines -> ParsecT Sources ParserState m Inlines
forall a b. (a -> b) -> a -> b
$ Text -> Inlines
B.str Text
" NOT SUPPORTED BEGIN: ~hs~ (non-breaking space) :END "
htmlComment :: PandocMonad m => TikiWikiParser m B.Inlines
= ParsecT Sources ParserState m Inlines
-> ParsecT Sources ParserState m Inlines
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try (ParsecT Sources ParserState m Inlines
-> ParsecT Sources ParserState m Inlines)
-> ParsecT Sources ParserState m Inlines
-> ParsecT Sources ParserState m Inlines
forall a b. (a -> b) -> a -> b
$ do
String -> ParsecT Sources ParserState m String
forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
String -> ParsecT s u m String
string String
"~hc~"
inner <- (String -> Text)
-> ParsecT Sources ParserState m String
-> ParsecT Sources ParserState m Text
forall a b.
(a -> b)
-> ParsecT Sources ParserState m a
-> ParsecT Sources ParserState m b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap String -> Text
T.pack (ParsecT Sources ParserState m String
-> ParsecT Sources ParserState m Text)
-> ParsecT Sources ParserState m String
-> ParsecT Sources ParserState m Text
forall a b. (a -> b) -> a -> b
$ ParsecT Sources ParserState m Char
-> ParsecT Sources ParserState m String
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 String)
-> ParsecT Sources ParserState m Char
-> ParsecT Sources ParserState m String
forall a b. (a -> b) -> a -> b
$ String -> ParsecT Sources ParserState m Char
forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
String -> ParsecT s u m Char
noneOf String
"~"
string "~/hc~"
return $ B.str $ " NOT SUPPORTED: ~hc~ (html comment opener) BEGIN: " <> inner <> " ~/hc~ :END "
linebreak :: PandocMonad m => TikiWikiParser m B.Inlines
linebreak :: forall (m :: * -> *). PandocMonad m => TikiWikiParser m Inlines
linebreak = 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 ()
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 ()
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 Inlines
-> ParsecT Sources ParserState m Inlines
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 Inlines
forall {u}. ParsecT Sources u m Inlines
lastNewline ParsecT Sources ParserState m Inlines
-> ParsecT Sources ParserState m Inlines
-> ParsecT Sources ParserState m Inlines
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> ParsecT Sources ParserState m Inlines
innerNewline)
where lastNewline :: ParsecT Sources u m Inlines
lastNewline = ParsecT Sources u m ()
forall s (m :: * -> *) t u.
(Stream s m t, Show t) =>
ParsecT s u m ()
eof ParsecT Sources u m ()
-> ParsecT Sources u m Inlines -> ParsecT Sources u m Inlines
forall a b.
ParsecT Sources u m a
-> ParsecT Sources u m b -> ParsecT Sources u m b
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> Inlines -> ParsecT Sources u m Inlines
forall a. a -> ParsecT Sources u m a
forall (m :: * -> *) a. Monad m => a -> m a
return Inlines
forall a. Monoid a => a
mempty
innerNewline :: ParsecT Sources ParserState m Inlines
innerNewline = Inlines -> ParsecT Sources ParserState m Inlines
forall a. a -> ParsecT Sources ParserState m a
forall (m :: * -> *) a. Monad m => a -> m a
return Inlines
B.space
between :: (Monoid c, PandocMonad m, Show b) => TikiWikiParser m a -> TikiWikiParser m b -> (TikiWikiParser m b -> TikiWikiParser m c) -> TikiWikiParser m c
between :: forall c (m :: * -> *) b a.
(Monoid c, PandocMonad m, Show b) =>
TikiWikiParser m a
-> TikiWikiParser m b
-> (TikiWikiParser m b -> TikiWikiParser m c)
-> TikiWikiParser m c
between TikiWikiParser m a
start TikiWikiParser m b
end TikiWikiParser m b -> TikiWikiParser m c
p =
[c] -> c
forall a. Monoid a => [a] -> a
mconcat ([c] -> c)
-> ParsecT Sources ParserState m [c] -> TikiWikiParser m c
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ParsecT Sources ParserState m [c]
-> ParsecT Sources ParserState m [c]
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try (TikiWikiParser m a
start TikiWikiParser m a
-> 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 Inlines
-> 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 Inlines
forall (m :: * -> *). PandocMonad m => TikiWikiParser m Inlines
whitespace ParsecT Sources ParserState m ()
-> ParsecT Sources ParserState m [c]
-> ParsecT Sources ParserState m [c]
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
>> TikiWikiParser m c
-> TikiWikiParser m b -> ParsecT Sources ParserState m [c]
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 (TikiWikiParser m b -> TikiWikiParser m c
p TikiWikiParser m b
end) TikiWikiParser m b
end)
enclosed :: (Monoid b, PandocMonad m, Show a) => TikiWikiParser m a -> (TikiWikiParser m a -> TikiWikiParser m b) -> TikiWikiParser m b
enclosed :: forall b (m :: * -> *) a.
(Monoid b, PandocMonad m, Show a) =>
TikiWikiParser m a
-> (TikiWikiParser m a -> TikiWikiParser m b) -> TikiWikiParser m b
enclosed TikiWikiParser m a
sep TikiWikiParser m a -> TikiWikiParser m b
p = TikiWikiParser m a
-> TikiWikiParser m a
-> (TikiWikiParser m a -> TikiWikiParser m b)
-> TikiWikiParser m b
forall c (m :: * -> *) b a.
(Monoid c, PandocMonad m, Show b) =>
TikiWikiParser m a
-> TikiWikiParser m b
-> (TikiWikiParser m b -> TikiWikiParser m c)
-> TikiWikiParser m c
between TikiWikiParser m a
sep (TikiWikiParser m a -> TikiWikiParser m a
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try (TikiWikiParser m a -> TikiWikiParser m a)
-> TikiWikiParser m a -> TikiWikiParser m a
forall a b. (a -> b) -> a -> b
$ TikiWikiParser m a
sep TikiWikiParser m a
-> ParsecT Sources ParserState m () -> TikiWikiParser m a
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 ()
endMarker) TikiWikiParser m a -> TikiWikiParser m b
p
where
endMarker :: ParsecT Sources ParserState m ()
endMarker = 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 (ParsecT Sources ParserState m ()
-> ParsecT Sources ParserState m ())
-> ParsecT Sources ParserState m ()
-> ParsecT Sources ParserState m ()
forall a b. (a -> b) -> a -> b
$ TikiWikiParser m Inlines -> ParsecT Sources ParserState m ()
forall (m :: * -> *) a. TikiWikiParser m a -> TikiWikiParser m ()
skip TikiWikiParser m Inlines
forall {u}. ParsecT Sources u m Inlines
endSpace 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
<|> TikiWikiParser m Char -> ParsecT Sources ParserState m ()
forall (m :: * -> *) a. TikiWikiParser m a -> TikiWikiParser m ()
skip (String -> TikiWikiParser m Char
forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
String -> ParsecT s u m Char
oneOf String
".,!?:)|'_") 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 s (m :: * -> *) t u.
(Stream s m t, Show t) =>
ParsecT s u m ()
eof
endSpace :: ParsecT Sources u m Inlines
endSpace = (ParsecT Sources u m Char
forall s (m :: * -> *) st.
(Stream s m Char, UpdateSourcePos s Char) =>
ParsecT s st m Char
spaceChar ParsecT Sources u m Char
-> ParsecT Sources u m Char -> ParsecT Sources u m Char
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> ParsecT Sources u m Char
forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
ParsecT s u m Char
newline) ParsecT Sources u m Char
-> ParsecT Sources u m Inlines -> ParsecT Sources u m Inlines
forall a b.
ParsecT Sources u m a
-> ParsecT Sources u m b -> ParsecT Sources u m b
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> Inlines -> ParsecT Sources u m Inlines
forall a. a -> ParsecT Sources u m a
forall (m :: * -> *) a. Monad m => a -> m a
return Inlines
B.space
nestedInlines :: (Show a, PandocMonad m) => TikiWikiParser m a -> TikiWikiParser m B.Inlines
nestedInlines :: forall a (m :: * -> *).
(Show a, PandocMonad m) =>
TikiWikiParser m a -> TikiWikiParser m Inlines
nestedInlines TikiWikiParser m a
end = ParsecT Sources ParserState m Inlines
innerSpace ParsecT Sources ParserState m Inlines
-> ParsecT Sources ParserState m Inlines
-> ParsecT Sources ParserState m Inlines
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> ParsecT Sources ParserState m Inlines
nestedInline
where
innerSpace :: ParsecT Sources ParserState m Inlines
innerSpace = ParsecT Sources ParserState m Inlines
-> ParsecT Sources ParserState m Inlines
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try (ParsecT Sources ParserState m Inlines
-> ParsecT Sources ParserState m Inlines)
-> ParsecT Sources ParserState m Inlines
-> ParsecT Sources ParserState m Inlines
forall a b. (a -> b) -> a -> b
$ ParsecT Sources ParserState m Inlines
forall (m :: * -> *). PandocMonad m => TikiWikiParser m Inlines
whitespace ParsecT Sources ParserState m Inlines
-> ParsecT Sources ParserState m ()
-> ParsecT Sources ParserState m Inlines
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
<* TikiWikiParser m a -> 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 TikiWikiParser m a
end
nestedInline :: ParsecT Sources ParserState m Inlines
nestedInline = ParsecT Sources ParserState m Inlines
-> 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 Inlines
forall (m :: * -> *). PandocMonad m => TikiWikiParser m Inlines
whitespace ParsecT Sources ParserState m ()
-> ParsecT Sources ParserState m Inlines
-> ParsecT Sources ParserState m Inlines
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 Inlines
forall (m :: * -> *). PandocMonad m => TikiWikiParser m Inlines
inline
image :: PandocMonad m => TikiWikiParser m B.Inlines
image :: forall (m :: * -> *). PandocMonad m => TikiWikiParser m Inlines
image = ParsecT Sources ParserState m Inlines
-> ParsecT Sources ParserState m Inlines
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try (ParsecT Sources ParserState m Inlines
-> ParsecT Sources ParserState m Inlines)
-> ParsecT Sources ParserState m Inlines
-> ParsecT Sources ParserState m Inlines
forall a b. (a -> b) -> a -> b
$ do
String -> ParsecT Sources ParserState m String
forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
String -> ParsecT s u m String
string String
"{img "
rawAttrs <- ParsecT Sources ParserState m (Text, Text)
-> ParsecT Sources ParserState m ()
-> ParsecT Sources ParserState m [(Text, Text)]
forall s (m :: * -> *) t u a end.
Stream s m t =>
ParsecT s u m a -> ParsecT s u m end -> ParsecT s u m [a]
sepEndBy1 ParsecT Sources ParserState m (Text, Text)
forall (m :: * -> *).
PandocMonad m =>
TikiWikiParser m (Text, Text)
imageAttr ParsecT Sources ParserState m ()
forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
ParsecT s u m ()
spaces
string "}"
let src = Text -> Maybe Text -> Text
forall a. a -> Maybe a -> a
fromMaybe Text
"" (Maybe Text -> Text) -> Maybe Text -> Text
forall a b. (a -> b) -> a -> b
$ Text -> [(Text, Text)] -> Maybe Text
forall a b. Eq a => a -> [(a, b)] -> Maybe b
lookup Text
"src" [(Text, Text)]
rawAttrs
let title = Text -> Maybe Text -> Text
forall a. a -> Maybe a -> a
fromMaybe Text
src (Maybe Text -> Text) -> Maybe Text -> Text
forall a b. (a -> b) -> a -> b
$ Text -> [(Text, Text)] -> Maybe Text
forall a b. Eq a => a -> [(a, b)] -> Maybe b
lookup Text
"desc" [(Text, Text)]
rawAttrs
let alt = Text -> Maybe Text -> Text
forall a. a -> Maybe a -> a
fromMaybe Text
title (Maybe Text -> Text) -> Maybe Text -> Text
forall a b. (a -> b) -> a -> b
$ Text -> [(Text, Text)] -> Maybe Text
forall a b. Eq a => a -> [(a, b)] -> Maybe b
lookup Text
"alt" [(Text, Text)]
rawAttrs
let classes = ((Text, Text) -> Text) -> [(Text, Text)] -> [Text]
forall a b. (a -> b) -> [a] -> [b]
map (Text, Text) -> Text
forall a b. (a, b) -> a
fst ([(Text, Text)] -> [Text]) -> [(Text, Text)] -> [Text]
forall a b. (a -> b) -> a -> b
$ ((Text, Text) -> Bool) -> [(Text, Text)] -> [(Text, Text)]
forall a. (a -> Bool) -> [a] -> [a]
filter (\(Text
_,Text
b) -> Text
b Text -> Text -> Bool
forall a. Eq a => a -> a -> Bool
== Text
"" Bool -> Bool -> Bool
|| Text
b Text -> Text -> Bool
forall a. Eq a => a -> a -> Bool
== Text
"y") [(Text, Text)]
rawAttrs
if not (T.null src)
then
return $ B.imageWith ("", classes, rawAttrs) src title (B.str alt)
else
return $ B.str $ " NOT SUPPORTED: image without src attribute BEGIN: {img " <> printAttrs rawAttrs <> "} :END "
where
printAttrs :: [(Text, Text)] -> Text
printAttrs [(Text, Text)]
attrs = [Text] -> Text
T.unwords ([Text] -> Text) -> [Text] -> Text
forall a b. (a -> b) -> a -> b
$ ((Text, Text) -> Text) -> [(Text, Text)] -> [Text]
forall a b. (a -> b) -> [a] -> [b]
map (\(Text
a, Text
b) -> Text
a Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
"=\"" Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
b Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
"\"") [(Text, Text)]
attrs
imageAttr :: PandocMonad m => TikiWikiParser m (Text, Text)
imageAttr :: forall (m :: * -> *).
PandocMonad m =>
TikiWikiParser m (Text, Text)
imageAttr = 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
try (ParsecT Sources ParserState m (Text, Text)
-> ParsecT Sources ParserState m (Text, Text))
-> ParsecT Sources ParserState m (Text, Text)
-> ParsecT Sources ParserState m (Text, Text)
forall a b. (a -> b) -> a -> b
$ do
key <- ParsecT Sources ParserState m Char
-> ParsecT Sources ParserState m String
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m [a]
many1 (String -> ParsecT Sources ParserState m Char
forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
String -> ParsecT s u m Char
noneOf String
"=} \t\n")
char '='
optional $ char '"'
value <- many1 (noneOf "}\"\n")
optional $ char '"'
optional $ char ','
return (T.pack key, T.pack value)
strong :: PandocMonad m => TikiWikiParser m B.Inlines
strong :: forall (m :: * -> *). PandocMonad m => TikiWikiParser m Inlines
strong = ParsecT Sources ParserState m Inlines
-> ParsecT Sources ParserState m Inlines
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try (ParsecT Sources ParserState m Inlines
-> ParsecT Sources ParserState m Inlines)
-> ParsecT Sources ParserState m Inlines
-> ParsecT Sources ParserState m Inlines
forall a b. (a -> b) -> a -> b
$ (Inlines -> Inlines)
-> ParsecT Sources ParserState m Inlines
-> ParsecT Sources ParserState m Inlines
forall a b.
(a -> b)
-> ParsecT Sources ParserState m a
-> ParsecT Sources ParserState m b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap Inlines -> Inlines
B.strong (TikiWikiParser m String
-> (TikiWikiParser m String
-> ParsecT Sources ParserState m Inlines)
-> ParsecT Sources ParserState m Inlines
forall b (m :: * -> *) a.
(Monoid b, PandocMonad m, Show a) =>
TikiWikiParser m a
-> (TikiWikiParser m a -> TikiWikiParser m b) -> TikiWikiParser m b
enclosed (String -> TikiWikiParser m String
forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
String -> ParsecT s u m String
string String
"__") TikiWikiParser m String -> ParsecT Sources ParserState m Inlines
forall a (m :: * -> *).
(Show a, PandocMonad m) =>
TikiWikiParser m a -> TikiWikiParser m Inlines
nestedInlines)
emph :: PandocMonad m => TikiWikiParser m B.Inlines
emph :: forall (m :: * -> *). PandocMonad m => TikiWikiParser m Inlines
emph = ParsecT Sources ParserState m Inlines
-> ParsecT Sources ParserState m Inlines
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try (ParsecT Sources ParserState m Inlines
-> ParsecT Sources ParserState m Inlines)
-> ParsecT Sources ParserState m Inlines
-> ParsecT Sources ParserState m Inlines
forall a b. (a -> b) -> a -> b
$ (Inlines -> Inlines)
-> ParsecT Sources ParserState m Inlines
-> ParsecT Sources ParserState m Inlines
forall a b.
(a -> b)
-> ParsecT Sources ParserState m a
-> ParsecT Sources ParserState m b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap Inlines -> Inlines
B.emph (TikiWikiParser m String
-> (TikiWikiParser m String
-> ParsecT Sources ParserState m Inlines)
-> ParsecT Sources ParserState m Inlines
forall b (m :: * -> *) a.
(Monoid b, PandocMonad m, Show a) =>
TikiWikiParser m a
-> (TikiWikiParser m a -> TikiWikiParser m b) -> TikiWikiParser m b
enclosed (String -> TikiWikiParser m String
forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
String -> ParsecT s u m String
string String
"''") TikiWikiParser m String -> ParsecT Sources ParserState m Inlines
forall a (m :: * -> *).
(Show a, PandocMonad m) =>
TikiWikiParser m a -> TikiWikiParser m Inlines
nestedInlines)
escapedChar :: PandocMonad m => TikiWikiParser m B.Inlines
escapedChar :: forall (m :: * -> *). PandocMonad m => TikiWikiParser m Inlines
escapedChar = ParsecT Sources ParserState m Inlines
-> ParsecT Sources ParserState m Inlines
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try (ParsecT Sources ParserState m Inlines
-> ParsecT Sources ParserState m Inlines)
-> ParsecT Sources ParserState m Inlines
-> ParsecT Sources ParserState m Inlines
forall a b. (a -> b) -> a -> b
$ do
String -> ParsecT Sources ParserState m String
forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
String -> ParsecT s u m String
string String
"~"
mNumber <- Text -> Maybe Int
forall (m :: * -> *) a. (MonadPlus m, Read a) => Text -> m a
safeRead (Text -> Maybe Int) -> (String -> Text) -> String -> Maybe Int
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> Text
T.pack (String -> Maybe Int)
-> ParsecT Sources ParserState m String
-> ParsecT Sources ParserState m (Maybe Int)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ParsecT Sources ParserState m Char
-> ParsecT Sources ParserState m String
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m [a]
many1 ParsecT Sources ParserState m Char
forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
ParsecT s u m Char
digit
string "~"
return $ B.str $
case mNumber of
Just Int
number -> Char -> Text
T.singleton (Char -> Text) -> Char -> Text
forall a b. (a -> b) -> a -> b
$ Int -> Char
forall a. Enum a => Int -> a
toEnum (Int
number :: Int)
Maybe Int
Nothing -> Text
""
centered :: PandocMonad m => TikiWikiParser m B.Inlines
centered :: forall (m :: * -> *). PandocMonad m => TikiWikiParser m Inlines
centered = ParsecT Sources ParserState m Inlines
-> ParsecT Sources ParserState m Inlines
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try (ParsecT Sources ParserState m Inlines
-> ParsecT Sources ParserState m Inlines)
-> ParsecT Sources ParserState m Inlines
-> ParsecT Sources ParserState m Inlines
forall a b. (a -> b) -> a -> b
$ do
String -> ParsecT Sources ParserState m String
forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
String -> ParsecT s u m String
string String
"::"
inner <- (String -> Text)
-> ParsecT Sources ParserState m String
-> ParsecT Sources ParserState m Text
forall a b.
(a -> b)
-> ParsecT Sources ParserState m a
-> ParsecT Sources ParserState m b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap String -> Text
T.pack (ParsecT Sources ParserState m String
-> ParsecT Sources ParserState m Text)
-> ParsecT Sources ParserState m String
-> ParsecT Sources ParserState m Text
forall a b. (a -> b) -> a -> b
$ ParsecT Sources ParserState m Char
-> ParsecT Sources ParserState m String
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 String)
-> ParsecT Sources ParserState m Char
-> ParsecT Sources ParserState m String
forall a b. (a -> b) -> a -> b
$ String -> ParsecT Sources ParserState m Char
forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
String -> ParsecT s u m Char
noneOf String
":\n"
string "::"
return $ B.str $ " NOT SUPPORTED: :: (centered) BEGIN: ::" <> inner <> ":: :END "
colored :: PandocMonad m => TikiWikiParser m B.Inlines
colored :: forall (m :: * -> *). PandocMonad m => TikiWikiParser m Inlines
colored = ParsecT Sources ParserState m Inlines
-> ParsecT Sources ParserState m Inlines
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try (ParsecT Sources ParserState m Inlines
-> ParsecT Sources ParserState m Inlines)
-> ParsecT Sources ParserState m Inlines
-> ParsecT Sources ParserState m Inlines
forall a b. (a -> b) -> a -> b
$ do
String -> ParsecT Sources ParserState m String
forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
String -> ParsecT s u m String
string String
"~~"
inner <- (String -> Text)
-> ParsecT Sources ParserState m String
-> ParsecT Sources ParserState m Text
forall a b.
(a -> b)
-> ParsecT Sources ParserState m a
-> ParsecT Sources ParserState m b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap String -> Text
T.pack (ParsecT Sources ParserState m String
-> ParsecT Sources ParserState m Text)
-> ParsecT Sources ParserState m String
-> ParsecT Sources ParserState m Text
forall a b. (a -> b) -> a -> b
$ ParsecT Sources ParserState m Char
-> ParsecT Sources ParserState m String
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 String)
-> ParsecT Sources ParserState m Char
-> ParsecT Sources ParserState m String
forall a b. (a -> b) -> a -> b
$ String -> ParsecT Sources ParserState m Char
forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
String -> ParsecT s u m Char
noneOf String
"~\n"
string "~~"
return $ B.str $ " NOT SUPPORTED: ~~ (colored) BEGIN: ~~" <> inner <> "~~ :END "
underlined :: PandocMonad m => TikiWikiParser m B.Inlines
underlined :: forall (m :: * -> *). PandocMonad m => TikiWikiParser m Inlines
underlined = ParsecT Sources ParserState m Inlines
-> ParsecT Sources ParserState m Inlines
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try (ParsecT Sources ParserState m Inlines
-> ParsecT Sources ParserState m Inlines)
-> ParsecT Sources ParserState m Inlines
-> ParsecT Sources ParserState m Inlines
forall a b. (a -> b) -> a -> b
$ Inlines -> Inlines
B.underline (Inlines -> Inlines)
-> ParsecT Sources ParserState m Inlines
-> ParsecT Sources ParserState m Inlines
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> TikiWikiParser m String
-> (TikiWikiParser m String
-> ParsecT Sources ParserState m Inlines)
-> ParsecT Sources ParserState m Inlines
forall b (m :: * -> *) a.
(Monoid b, PandocMonad m, Show a) =>
TikiWikiParser m a
-> (TikiWikiParser m a -> TikiWikiParser m b) -> TikiWikiParser m b
enclosed (String -> TikiWikiParser m String
forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
String -> ParsecT s u m String
string String
"===") TikiWikiParser m String -> ParsecT Sources ParserState m Inlines
forall a (m :: * -> *).
(Show a, PandocMonad m) =>
TikiWikiParser m a -> TikiWikiParser m Inlines
nestedInlines
boxed :: PandocMonad m => TikiWikiParser m B.Inlines
boxed :: forall (m :: * -> *). PandocMonad m => TikiWikiParser m Inlines
boxed = ParsecT Sources ParserState m Inlines
-> ParsecT Sources ParserState m Inlines
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try (ParsecT Sources ParserState m Inlines
-> ParsecT Sources ParserState m Inlines)
-> ParsecT Sources ParserState m Inlines
-> ParsecT Sources ParserState m Inlines
forall a b. (a -> b) -> a -> b
$ do
String -> ParsecT Sources ParserState m String
forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
String -> ParsecT s u m String
string String
"^"
inner <- (String -> Text)
-> ParsecT Sources ParserState m String
-> ParsecT Sources ParserState m Text
forall a b.
(a -> b)
-> ParsecT Sources ParserState m a
-> ParsecT Sources ParserState m b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap String -> Text
T.pack (ParsecT Sources ParserState m String
-> ParsecT Sources ParserState m Text)
-> ParsecT Sources ParserState m String
-> ParsecT Sources ParserState m Text
forall a b. (a -> b) -> a -> b
$ ParsecT Sources ParserState m Char
-> ParsecT Sources ParserState m String
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 String)
-> ParsecT Sources ParserState m Char
-> ParsecT Sources ParserState m String
forall a b. (a -> b) -> a -> b
$ String -> ParsecT Sources ParserState m Char
forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
String -> ParsecT s u m Char
noneOf String
"^\n"
string "^"
return $ B.str $ " NOT SUPPORTED: ^ (boxed) BEGIN: ^" <> inner <> "^ :END "
strikeout :: PandocMonad m => TikiWikiParser m B.Inlines
strikeout :: forall (m :: * -> *). PandocMonad m => TikiWikiParser m Inlines
strikeout = ParsecT Sources ParserState m Inlines
-> ParsecT Sources ParserState m Inlines
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try (ParsecT Sources ParserState m Inlines
-> ParsecT Sources ParserState m Inlines)
-> ParsecT Sources ParserState m Inlines
-> ParsecT Sources ParserState m Inlines
forall a b. (a -> b) -> a -> b
$ (Inlines -> Inlines)
-> ParsecT Sources ParserState m Inlines
-> ParsecT Sources ParserState m Inlines
forall a b.
(a -> b)
-> ParsecT Sources ParserState m a
-> ParsecT Sources ParserState m b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap Inlines -> Inlines
B.strikeout (TikiWikiParser m String
-> (TikiWikiParser m String
-> ParsecT Sources ParserState m Inlines)
-> ParsecT Sources ParserState m Inlines
forall b (m :: * -> *) a.
(Monoid b, PandocMonad m, Show a) =>
TikiWikiParser m a
-> (TikiWikiParser m a -> TikiWikiParser m b) -> TikiWikiParser m b
enclosed (String -> TikiWikiParser m String
forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
String -> ParsecT s u m String
string String
"--") TikiWikiParser m String -> ParsecT Sources ParserState m Inlines
forall a (m :: * -> *).
(Show a, PandocMonad m) =>
TikiWikiParser m a -> TikiWikiParser m Inlines
nestedInlines)
nestedString :: (Show a, PandocMonad m) => TikiWikiParser m a -> TikiWikiParser m Text
nestedString :: forall a (m :: * -> *).
(Show a, PandocMonad m) =>
TikiWikiParser m a -> TikiWikiParser m Text
nestedString TikiWikiParser m a
end = ParsecT Sources ParserState m Text
innerSpace 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
<|> 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 ParsecT Sources ParserState m Char
forall s (m :: * -> *) st.
(Stream s m Char, UpdateSourcePos s Char) =>
ParsecT s st m Char
nonspaceChar
where
innerSpace :: ParsecT Sources ParserState m Text
innerSpace = 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
$ String -> Text
T.pack (String -> Text)
-> ParsecT Sources ParserState m String
-> ParsecT Sources ParserState m Text
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ParsecT Sources ParserState m Char
-> ParsecT Sources ParserState m String
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 ParsecT Sources ParserState m Text
-> ParsecT Sources ParserState m ()
-> ParsecT Sources ParserState m Text
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
<* TikiWikiParser m a -> 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 TikiWikiParser m a
end
breakChars :: PandocMonad m => TikiWikiParser m B.Inlines
breakChars :: forall (m :: * -> *). PandocMonad m => TikiWikiParser m Inlines
breakChars = ParsecT Sources ParserState m Inlines
-> ParsecT Sources ParserState m Inlines
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try (ParsecT Sources ParserState m Inlines
-> ParsecT Sources ParserState m Inlines)
-> ParsecT Sources ParserState m Inlines
-> ParsecT Sources ParserState m Inlines
forall a b. (a -> b) -> a -> b
$ String -> ParsecT Sources ParserState m String
forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
String -> ParsecT s u m String
string String
"%%%" ParsecT Sources ParserState m String
-> ParsecT Sources ParserState m Inlines
-> ParsecT Sources ParserState m Inlines
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
>> Inlines -> ParsecT Sources ParserState m Inlines
forall a. a -> ParsecT Sources ParserState m a
forall (m :: * -> *) a. Monad m => a -> m a
return Inlines
B.linebreak
superTag :: PandocMonad m => TikiWikiParser m B.Inlines
superTag :: forall (m :: * -> *). PandocMonad m => TikiWikiParser m Inlines
superTag = ParsecT Sources ParserState m Inlines
-> ParsecT Sources ParserState m Inlines
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try (ParsecT Sources ParserState m Inlines
-> ParsecT Sources ParserState m Inlines)
-> ParsecT Sources ParserState m Inlines
-> ParsecT Sources ParserState m Inlines
forall a b. (a -> b) -> a -> b
$ (Text -> Inlines)
-> ParsecT Sources ParserState m Text
-> ParsecT Sources ParserState m Inlines
forall a b.
(a -> b)
-> ParsecT Sources ParserState m a
-> ParsecT Sources ParserState m b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (Inlines -> Inlines
B.superscript (Inlines -> Inlines) -> (Text -> Inlines) -> Text -> Inlines
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Text -> Inlines
B.text (Text -> Inlines) -> (Text -> Text) -> Text -> Inlines
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Text -> Text
fromEntities) ( TikiWikiParser m String
-> TikiWikiParser m String
-> (TikiWikiParser m String -> ParsecT Sources ParserState m Text)
-> ParsecT Sources ParserState m Text
forall c (m :: * -> *) b a.
(Monoid c, PandocMonad m, Show b) =>
TikiWikiParser m a
-> TikiWikiParser m b
-> (TikiWikiParser m b -> TikiWikiParser m c)
-> TikiWikiParser m c
between (String -> TikiWikiParser m String
forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
String -> ParsecT s u m String
string String
"{TAG(tag=>sup)}") (String -> TikiWikiParser m String
forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
String -> ParsecT s u m String
string String
"{TAG}") TikiWikiParser m String -> ParsecT Sources ParserState m Text
forall a (m :: * -> *).
(Show a, PandocMonad m) =>
TikiWikiParser m a -> TikiWikiParser m Text
nestedString)
superMacro :: PandocMonad m => TikiWikiParser m B.Inlines
superMacro :: forall (m :: * -> *). PandocMonad m => TikiWikiParser m Inlines
superMacro = ParsecT Sources ParserState m Inlines
-> ParsecT Sources ParserState m Inlines
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try (ParsecT Sources ParserState m Inlines
-> ParsecT Sources ParserState m Inlines)
-> ParsecT Sources ParserState m Inlines
-> ParsecT Sources ParserState m Inlines
forall a b. (a -> b) -> a -> b
$ do
String -> ParsecT Sources ParserState m String
forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
String -> ParsecT s u m String
string String
"{SUP("
ParsecT Sources ParserState m Char
-> ParsecT Sources ParserState m String
-> ParsecT Sources ParserState m String
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 (String -> ParsecT Sources ParserState m String
forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
String -> ParsecT s u m String
string String
")}")
body <- ParsecT Sources ParserState m Char
-> ParsecT Sources ParserState m String
-> ParsecT Sources ParserState m String
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 (String -> ParsecT Sources ParserState m String
forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
String -> ParsecT s u m String
string String
"{SUP}")
return $ B.superscript $ B.text $ T.pack body
subTag :: PandocMonad m => TikiWikiParser m B.Inlines
subTag :: forall (m :: * -> *). PandocMonad m => TikiWikiParser m Inlines
subTag = ParsecT Sources ParserState m Inlines
-> ParsecT Sources ParserState m Inlines
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try (ParsecT Sources ParserState m Inlines
-> ParsecT Sources ParserState m Inlines)
-> ParsecT Sources ParserState m Inlines
-> ParsecT Sources ParserState m Inlines
forall a b. (a -> b) -> a -> b
$ (Text -> Inlines)
-> ParsecT Sources ParserState m Text
-> ParsecT Sources ParserState m Inlines
forall a b.
(a -> b)
-> ParsecT Sources ParserState m a
-> ParsecT Sources ParserState m b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (Inlines -> Inlines
B.subscript (Inlines -> Inlines) -> (Text -> Inlines) -> Text -> Inlines
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Text -> Inlines
B.text (Text -> Inlines) -> (Text -> Text) -> Text -> Inlines
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Text -> Text
fromEntities) ( TikiWikiParser m String
-> TikiWikiParser m String
-> (TikiWikiParser m String -> ParsecT Sources ParserState m Text)
-> ParsecT Sources ParserState m Text
forall c (m :: * -> *) b a.
(Monoid c, PandocMonad m, Show b) =>
TikiWikiParser m a
-> TikiWikiParser m b
-> (TikiWikiParser m b -> TikiWikiParser m c)
-> TikiWikiParser m c
between (String -> TikiWikiParser m String
forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
String -> ParsecT s u m String
string String
"{TAG(tag=>sub)}") (String -> TikiWikiParser m String
forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
String -> ParsecT s u m String
string String
"{TAG}") TikiWikiParser m String -> ParsecT Sources ParserState m Text
forall a (m :: * -> *).
(Show a, PandocMonad m) =>
TikiWikiParser m a -> TikiWikiParser m Text
nestedString)
subMacro :: PandocMonad m => TikiWikiParser m B.Inlines
subMacro :: forall (m :: * -> *). PandocMonad m => TikiWikiParser m Inlines
subMacro = ParsecT Sources ParserState m Inlines
-> ParsecT Sources ParserState m Inlines
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try (ParsecT Sources ParserState m Inlines
-> ParsecT Sources ParserState m Inlines)
-> ParsecT Sources ParserState m Inlines
-> ParsecT Sources ParserState m Inlines
forall a b. (a -> b) -> a -> b
$ do
String -> ParsecT Sources ParserState m String
forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
String -> ParsecT s u m String
string String
"{SUB("
ParsecT Sources ParserState m Char
-> ParsecT Sources ParserState m String
-> ParsecT Sources ParserState m String
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 (String -> ParsecT Sources ParserState m String
forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
String -> ParsecT s u m String
string String
")}")
body <- ParsecT Sources ParserState m Char
-> ParsecT Sources ParserState m String
-> ParsecT Sources ParserState m String
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 (String -> ParsecT Sources ParserState m String
forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
String -> ParsecT s u m String
string String
"{SUB}")
return $ B.subscript $ B.text $ T.pack body
code :: PandocMonad m => TikiWikiParser m B.Inlines
code :: forall (m :: * -> *). PandocMonad m => TikiWikiParser m Inlines
code = ParsecT Sources ParserState m Inlines
-> ParsecT Sources ParserState m Inlines
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try (ParsecT Sources ParserState m Inlines
-> ParsecT Sources ParserState m Inlines)
-> ParsecT Sources ParserState m Inlines
-> ParsecT Sources ParserState m Inlines
forall a b. (a -> b) -> a -> b
$ (Text -> Inlines)
-> ParsecT Sources ParserState m Text
-> ParsecT Sources ParserState m Inlines
forall a b.
(a -> b)
-> ParsecT Sources ParserState m a
-> ParsecT Sources ParserState m b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (Text -> Inlines
B.code (Text -> Inlines) -> (Text -> Text) -> Text -> Inlines
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Text -> Text
fromEntities) ( TikiWikiParser m String
-> TikiWikiParser m String
-> (TikiWikiParser m String -> ParsecT Sources ParserState m Text)
-> ParsecT Sources ParserState m Text
forall c (m :: * -> *) b a.
(Monoid c, PandocMonad m, Show b) =>
TikiWikiParser m a
-> TikiWikiParser m b
-> (TikiWikiParser m b -> TikiWikiParser m c)
-> TikiWikiParser m c
between (String -> TikiWikiParser m String
forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
String -> ParsecT s u m String
string String
"-+") (String -> TikiWikiParser m String
forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
String -> ParsecT s u m String
string String
"+-") TikiWikiParser m String -> ParsecT Sources ParserState m Text
forall a (m :: * -> *).
(Show a, PandocMonad m) =>
TikiWikiParser m a -> TikiWikiParser m Text
nestedString)
macroAttr :: PandocMonad m => TikiWikiParser m (Text, Text)
macroAttr :: forall (m :: * -> *).
PandocMonad m =>
TikiWikiParser m (Text, Text)
macroAttr = 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
try (ParsecT Sources ParserState m (Text, Text)
-> ParsecT Sources ParserState m (Text, Text))
-> ParsecT Sources ParserState m (Text, Text)
-> ParsecT Sources ParserState m (Text, Text)
forall a b. (a -> b) -> a -> b
$ do
key <- ParsecT Sources ParserState m Char
-> ParsecT Sources ParserState m String
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m [a]
many1 (String -> ParsecT Sources ParserState m Char
forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
String -> ParsecT s u m Char
noneOf String
"=)")
char '='
optional $ char '"'
value <- many1 (noneOf " )\"")
optional $ char '"'
return (T.pack key, T.pack value)
macroAttrs :: PandocMonad m => TikiWikiParser m [(Text, Text)]
macroAttrs :: forall (m :: * -> *).
PandocMonad m =>
TikiWikiParser m [(Text, Text)]
macroAttrs = 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
try (ParsecT Sources ParserState m [(Text, Text)]
-> ParsecT Sources ParserState m [(Text, Text)])
-> ParsecT Sources ParserState m [(Text, Text)]
-> ParsecT Sources ParserState m [(Text, Text)]
forall a b. (a -> b) -> a -> b
$ ParsecT Sources ParserState m (Text, Text)
-> ParsecT Sources ParserState m ()
-> ParsecT Sources ParserState m [(Text, Text)]
forall s (m :: * -> *) t u a end.
Stream s m t =>
ParsecT s u m a -> ParsecT s u m end -> ParsecT s u m [a]
sepEndBy ParsecT Sources ParserState m (Text, Text)
forall (m :: * -> *).
PandocMonad m =>
TikiWikiParser m (Text, Text)
macroAttr ParsecT Sources ParserState m ()
forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
ParsecT s u m ()
spaces
noparse :: PandocMonad m => TikiWikiParser m B.Inlines
noparse :: forall (m :: * -> *). PandocMonad m => TikiWikiParser m Inlines
noparse = ParsecT Sources ParserState m Inlines
-> ParsecT Sources ParserState m Inlines
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try (ParsecT Sources ParserState m Inlines
-> ParsecT Sources ParserState m Inlines)
-> ParsecT Sources ParserState m Inlines
-> ParsecT Sources ParserState m Inlines
forall a b. (a -> b) -> a -> b
$ do
String -> ParsecT Sources ParserState m String
forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
String -> ParsecT s u m String
string String
"~np~"
body <- ParsecT Sources ParserState m Char
-> ParsecT Sources ParserState m String
-> ParsecT Sources ParserState m String
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 (String -> ParsecT Sources ParserState m String
forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
String -> ParsecT s u m String
string String
"~/np~")
return $ B.str $ T.pack body
str :: PandocMonad m => TikiWikiParser m B.Inlines
str :: forall (m :: * -> *). PandocMonad m => TikiWikiParser m Inlines
str = (Text -> Inlines)
-> ParsecT Sources ParserState m Text
-> ParsecT Sources ParserState m Inlines
forall a b.
(a -> b)
-> ParsecT Sources ParserState m a
-> ParsecT Sources ParserState m b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap Text -> Inlines
B.str (String -> Text
T.pack (String -> Text)
-> ParsecT Sources ParserState m String
-> ParsecT Sources ParserState m Text
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ParsecT Sources ParserState m Char
-> ParsecT Sources ParserState m String
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m [a]
many1 ParsecT Sources ParserState m Char
forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
ParsecT s u m Char
alphaNum 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
<|> ParsecT Sources ParserState m Text
forall s (m :: * -> *) st.
(Stream s m Char, UpdateSourcePos s Char) =>
ParsecT s st m Text
characterReference)
symbol :: PandocMonad m => TikiWikiParser m B.Inlines
symbol :: forall (m :: * -> *). PandocMonad m => TikiWikiParser m Inlines
symbol = (Text -> Inlines)
-> ParsecT Sources ParserState m Text
-> ParsecT Sources ParserState m Inlines
forall a b.
(a -> b)
-> ParsecT Sources ParserState m a
-> ParsecT Sources ParserState m b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap Text -> Inlines
B.str (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 ParsecT Sources ParserState m Char
forall s (m :: * -> *) st.
(Stream s m Char, UpdateSourcePos s Char) =>
ParsecT s st m Char
nonspaceChar)
notExternalLink :: PandocMonad m => TikiWikiParser m B.Inlines
notExternalLink :: forall (m :: * -> *). PandocMonad m => TikiWikiParser m Inlines
notExternalLink = ParsecT Sources ParserState m Inlines
-> ParsecT Sources ParserState m Inlines
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try (ParsecT Sources ParserState m Inlines
-> ParsecT Sources ParserState m Inlines)
-> ParsecT Sources ParserState m Inlines
-> ParsecT Sources ParserState m Inlines
forall a b. (a -> b) -> a -> b
$ do
start <- String -> ParsecT Sources ParserState m String
forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
String -> ParsecT s u m String
string String
"[["
body <- many (noneOf "\n[]")
end <- string "]"
return $ B.text $ T.pack $ start ++ body ++ end
makeLink :: PandocMonad m => Text -> Text -> Text -> TikiWikiParser m B.Inlines
makeLink :: forall (m :: * -> *).
PandocMonad m =>
Text -> Text -> Text -> TikiWikiParser m Inlines
makeLink Text
start Text
middle Text
end = ParsecT Sources ParserState m Inlines
-> ParsecT Sources ParserState m Inlines
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try (ParsecT Sources ParserState m Inlines
-> ParsecT Sources ParserState m Inlines)
-> ParsecT Sources ParserState m Inlines
-> ParsecT Sources ParserState m Inlines
forall a b. (a -> b) -> a -> b
$ do
st <- ParsecT Sources ParserState m ParserState
forall (m :: * -> *) s u. Monad m => ParsecT s u m u
getState
guard $ stateAllowLinks st
setState $ st{ stateAllowLinks = False }
(url, title, anchor) <- wikiLinkText start middle end
parsedTitle <- parseFromString (many1 inline) title
setState $ st{ stateAllowLinks = True }
return $ B.link (url <> anchor) "" $ mconcat parsedTitle
wikiLinkText :: PandocMonad m => Text -> Text -> Text -> TikiWikiParser m (Text, Text, Text)
wikiLinkText :: forall (m :: * -> *).
PandocMonad m =>
Text -> Text -> Text -> TikiWikiParser m (Text, Text, Text)
wikiLinkText Text
start Text
middle Text
end = do
String -> ParsecT Sources ParserState m String
forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
String -> ParsecT s u m String
string (Text -> String
T.unpack Text
start)
url <- String -> Text
T.pack (String -> Text)
-> ParsecT Sources ParserState m String
-> ParsecT Sources ParserState m Text
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ParsecT Sources ParserState m Char
-> ParsecT Sources ParserState m String
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m [a]
many1 (String -> ParsecT Sources ParserState m Char
forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
String -> ParsecT s u m Char
noneOf (String -> ParsecT Sources ParserState m Char)
-> String -> ParsecT Sources ParserState m Char
forall a b. (a -> b) -> a -> b
$ Text -> String
T.unpack Text
middle String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
"\n")
seg1 <- option url linkContent
seg2 <- option "" linkContent
string (T.unpack end)
if seg2 /= ""
then
return (url, seg2, seg1)
else
return (url, seg1, "")
where
linkContent :: ParsecT Sources u m Text
linkContent = do
Char -> ParsecT Sources u m Char
forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
Char -> ParsecT s u m Char
char Char
'|'
String -> Text
T.pack (String -> Text)
-> ParsecT Sources u m String -> ParsecT Sources u m Text
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ParsecT Sources u m Char -> ParsecT Sources u m String
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m [a]
many (String -> ParsecT Sources u m Char
forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
String -> ParsecT s u m Char
noneOf (String -> ParsecT Sources u m Char)
-> String -> ParsecT Sources u m Char
forall a b. (a -> b) -> a -> b
$ Text -> String
T.unpack Text
middle)
externalLink :: PandocMonad m => TikiWikiParser m B.Inlines
externalLink :: forall (m :: * -> *). PandocMonad m => TikiWikiParser m Inlines
externalLink = Text -> Text -> Text -> TikiWikiParser m Inlines
forall (m :: * -> *).
PandocMonad m =>
Text -> Text -> Text -> TikiWikiParser m Inlines
makeLink Text
"[" Text
"]|" Text
"]"
wikiLink :: PandocMonad m => TikiWikiParser m B.Inlines
wikiLink :: forall (m :: * -> *). PandocMonad m => TikiWikiParser m Inlines
wikiLink = Text -> Text -> Text -> TikiWikiParser m Inlines
forall (m :: * -> *).
PandocMonad m =>
Text -> Text -> Text -> TikiWikiParser m Inlines
makeLink Text
"((" Text
")|" Text
"))"