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