{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE TupleSections #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE ViewPatterns #-}
module Text.Pandoc.Readers.Markdown (
readMarkdown,
yamlToMeta,
yamlToRefs ) where
import Control.Monad
import Control.Monad.Except (throwError)
import Data.Bifunctor (second)
import Data.Char (isAlphaNum, isPunctuation, isSpace)
import Data.List (transpose, elemIndex, sortOn, foldl')
import qualified Data.Map as M
import Data.Maybe
import qualified Data.Set as Set
import Data.Text (Text)
import qualified Data.Text as T
import qualified Data.ByteString as BS
import System.FilePath (addExtension, takeExtension, takeDirectory)
import qualified System.FilePath.Windows as Windows
import qualified System.FilePath.Posix as Posix
import Text.DocLayout (realLength)
import Text.HTML.TagSoup hiding (Row)
import Text.Pandoc.Builder (Blocks, Inlines)
import qualified Text.Pandoc.Builder as B
import Text.Pandoc.Class.PandocMonad (PandocMonad (..), report)
import Text.Pandoc.Definition as Pandoc
import Text.Pandoc.Emoji (emojiToInline)
import Text.Pandoc.Error
import Safe.Foldable (maximumBounded)
import Text.Pandoc.Logging
import Text.Pandoc.Options
import Text.Pandoc.Walk (walk)
import Text.Pandoc.Parsing hiding (tableCaption)
import Text.Pandoc.Readers.HTML (htmlInBalanced, htmlTag, isBlockTag,
isCommentTag, isInlineTag, isTextTag)
import Text.Pandoc.Readers.LaTeX (applyMacros, rawLaTeXBlock, rawLaTeXInline)
import Text.Pandoc.Shared
import Text.Pandoc.URI (escapeURI, isURI)
import Text.Pandoc.XML (fromEntities)
import Text.Pandoc.Readers.Metadata (yamlBsToMeta, yamlBsToRefs, yamlMetaBlock)
type MarkdownParser m = ParsecT Sources ParserState m
type F = Future ParserState
readMarkdown :: (PandocMonad m, ToSources a)
=> ReaderOptions
-> a
-> m Pandoc
readMarkdown :: forall (m :: * -> *) a.
(PandocMonad m, ToSources a) =>
ReaderOptions -> a -> m Pandoc
readMarkdown ReaderOptions
opts a
s = do
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 => MarkdownParser m Pandoc
parseMarkdown forall a. Default a => a
def{ stateOptions :: ReaderOptions
stateOptions = ReaderOptions
opts }
(Int -> Sources -> Sources
ensureFinalNewlines Int
3 (forall a. ToSources a => a -> Sources
toSources a
s))
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
yamlToMeta :: PandocMonad m
=> ReaderOptions
-> Maybe FilePath
-> BS.ByteString
-> m Meta
yamlToMeta :: forall (m :: * -> *).
PandocMonad m =>
ReaderOptions -> Maybe FilePath -> ByteString -> m Meta
yamlToMeta ReaderOptions
opts Maybe FilePath
mbfp ByteString
bstr = do
let parser :: ParsecT Sources ParserState m Meta
parser = do
SourcePos
oldPos <- forall (m :: * -> *) s u. Monad m => ParsecT s u m SourcePos
getPosition
forall (m :: * -> *) s u. Monad m => SourcePos -> ParsecT s u m ()
setPosition forall a b. (a -> b) -> a -> b
$ FilePath -> SourcePos
initialPos (forall a. a -> Maybe a -> a
fromMaybe FilePath
"" Maybe FilePath
mbfp)
Future ParserState Meta
meta <- forall (m :: * -> *) st.
(PandocMonad m, HasLastStrPosition st) =>
ParsecT Sources st m (Future st MetaValue)
-> ByteString -> ParsecT Sources st m (Future st Meta)
yamlBsToMeta (forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap forall a. ToMetaValue a => a -> MetaValue
B.toMetaValue forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall (m :: * -> *). PandocMonad m => MarkdownParser m (F Blocks)
parseBlocks) ByteString
bstr
forall (m :: * -> *). PandocMonad m => MarkdownParser m ()
checkNotes
forall (m :: * -> *) s u. Monad m => SourcePos -> ParsecT s u m ()
setPosition SourcePos
oldPos
ParserState
st <- forall (m :: * -> *) s u. Monad m => ParsecT s u m u
getState
let result :: Meta
result = forall s a. Future s a -> s -> a
runF Future ParserState Meta
meta ParserState
st
forall (m :: * -> *) st s.
(PandocMonad m, HasLogMessages st) =>
ParsecT s st m ()
reportLogMessages
forall (m :: * -> *) a. Monad m => a -> m a
return Meta
result
Either PandocError Meta
parsed <- forall (m :: * -> *) t st a.
(Monad m, ToSources t) =>
ParsecT Sources st m a -> st -> t -> m (Either PandocError a)
readWithM ParsecT Sources ParserState m Meta
parser forall a. Default a => a
def{ stateOptions :: ReaderOptions
stateOptions = ReaderOptions
opts } (Text
"" :: Text)
case Either PandocError Meta
parsed of
Right Meta
result -> forall (m :: * -> *) a. Monad m => a -> m a
return Meta
result
Left PandocError
e -> forall e (m :: * -> *) a. MonadError e m => e -> m a
throwError PandocError
e
yamlToRefs :: PandocMonad m
=> (Text -> Bool)
-> ReaderOptions
-> Maybe FilePath
-> BS.ByteString
-> m [MetaValue]
yamlToRefs :: forall (m :: * -> *).
PandocMonad m =>
(Text -> Bool)
-> ReaderOptions -> Maybe FilePath -> ByteString -> m [MetaValue]
yamlToRefs Text -> Bool
idpred ReaderOptions
opts Maybe FilePath
mbfp ByteString
bstr = do
let parser :: ParsecT Sources ParserState m [MetaValue]
parser = do
case Maybe FilePath
mbfp of
Maybe FilePath
Nothing -> forall (m :: * -> *) a. Monad m => a -> m a
return ()
Just FilePath
fp -> forall (m :: * -> *) s u. Monad m => SourcePos -> ParsecT s u m ()
setPosition forall a b. (a -> b) -> a -> b
$ FilePath -> SourcePos
initialPos FilePath
fp
Future ParserState [MetaValue]
refs <- forall (m :: * -> *) st.
(PandocMonad m, HasLastStrPosition st) =>
ParsecT Sources st m (Future st MetaValue)
-> (Text -> Bool)
-> ByteString
-> ParsecT Sources st m (Future st [MetaValue])
yamlBsToRefs (forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap forall a. ToMetaValue a => a -> MetaValue
B.toMetaValue forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall (m :: * -> *). PandocMonad m => MarkdownParser m (F Blocks)
parseBlocks) Text -> Bool
idpred ByteString
bstr
forall (m :: * -> *). PandocMonad m => MarkdownParser m ()
checkNotes
ParserState
st <- forall (m :: * -> *) s u. Monad m => ParsecT s u m u
getState
let result :: [MetaValue]
result = forall s a. Future s a -> s -> a
runF Future ParserState [MetaValue]
refs ParserState
st
forall (m :: * -> *) st s.
(PandocMonad m, HasLogMessages st) =>
ParsecT s st m ()
reportLogMessages
forall (m :: * -> *) a. Monad m => a -> m a
return [MetaValue]
result
Either PandocError [MetaValue]
parsed <- forall (m :: * -> *) t st a.
(Monad m, ToSources t) =>
ParsecT Sources st m a -> st -> t -> m (Either PandocError a)
readWithM ParsecT Sources ParserState m [MetaValue]
parser forall a. Default a => a
def{ stateOptions :: ReaderOptions
stateOptions = ReaderOptions
opts } (Text
"" :: Text)
case Either PandocError [MetaValue]
parsed of
Right [MetaValue]
result -> forall (m :: * -> *) a. Monad m => a -> m a
return [MetaValue]
result
Left PandocError
e -> forall e (m :: * -> *) a. MonadError e m => e -> m a
throwError PandocError
e
isBulletListMarker :: Char -> Bool
isBulletListMarker :: Char -> Bool
isBulletListMarker Char
'*' = Bool
True
isBulletListMarker Char
'+' = Bool
True
isBulletListMarker Char
'-' = Bool
True
isBulletListMarker Char
_ = Bool
False
isHruleChar :: Char -> Bool
isHruleChar :: Char -> Bool
isHruleChar Char
'*' = Bool
True
isHruleChar Char
'-' = Bool
True
isHruleChar Char
'_' = Bool
True
isHruleChar Char
_ = Bool
False
setextHChars :: [Char]
setextHChars :: FilePath
setextHChars = FilePath
"=-"
isBlank :: Char -> Bool
isBlank :: Char -> Bool
isBlank Char
' ' = Bool
True
isBlank Char
'\t' = Bool
True
isBlank Char
'\n' = Bool
True
isBlank Char
_ = Bool
False
inList :: PandocMonad m => MarkdownParser m ()
inList :: forall (m :: * -> *). PandocMonad m => MarkdownParser m ()
inList = do
ParserContext
ctx <- ParserState -> ParserContext
stateParserContext forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall (m :: * -> *) s u. Monad m => ParsecT s u m u
getState
forall (f :: * -> *). Alternative f => Bool -> f ()
guard (ParserContext
ctx forall a. Eq a => a -> a -> Bool
== ParserContext
ListItemState)
spnl :: PandocMonad m => ParsecT Sources st m ()
spnl :: forall (m :: * -> *) st. PandocMonad m => ParsecT Sources st m ()
spnl = 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
forall s (m :: * -> *) t u a.
Stream s m t =>
ParsecT s u m a -> ParsecT s u m ()
optional forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
ParsecT s u m Char
newline
forall s (m :: * -> *) st.
(Stream s m Char, UpdateSourcePos s Char) =>
ParsecT s st m ()
skipSpaces
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
'\n')
spnl' :: PandocMonad m => ParsecT Sources st m Text
spnl' :: forall (m :: * -> *) st. PandocMonad m => ParsecT Sources st m Text
spnl' = forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try forall a b. (a -> b) -> a -> b
$ do
FilePath
xs <- forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m [a]
many forall s (m :: * -> *) st.
(Stream s m Char, UpdateSourcePos s Char) =>
ParsecT s st m Char
spaceChar
FilePath
ys <- forall s (m :: * -> *) t a u.
Stream s m t =>
a -> ParsecT s u m a -> ParsecT s u m a
option FilePath
"" 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 (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> 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 -> b) -> f a -> f b
<*> (forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m [a]
many forall s (m :: * -> *) st.
(Stream s m Char, UpdateSourcePos s Char) =>
ParsecT s st m Char
spaceChar forall (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
'\n'))
forall (m :: * -> *) a. Monad m => a -> m a
return forall a b. (a -> b) -> a -> b
$ FilePath -> Text
T.pack forall a b. (a -> b) -> a -> b
$ FilePath
xs forall a. [a] -> [a] -> [a]
++ FilePath
ys
indentSpaces :: PandocMonad m => MarkdownParser m Text
indentSpaces :: forall (m :: * -> *). PandocMonad m => MarkdownParser m Text
indentSpaces = 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
tabStop <- forall st s (m :: * -> *) t b.
(HasReaderOptions st, Stream s m t) =>
(ReaderOptions -> b) -> ParsecT s st m b
getOption ReaderOptions -> Int
readerTabStop
forall s (m :: * -> *) st.
(Stream s m Char, UpdateSourcePos s Char, Monad m) =>
Int -> ParsecT s st m Char -> ParsecT s st m Text
countChar Int
tabStop (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 s (m :: * -> *) u.
(Stream s m Char, UpdateSourcePos s Char) =>
Text -> ParsecT s u m Text
textStr Text
"\t" forall s u (m :: * -> *) a.
ParsecT s u m a -> FilePath -> ParsecT s u m a
<?> FilePath
"indentation"
nonindentSpaces :: PandocMonad m => MarkdownParser m Text
nonindentSpaces :: forall (m :: * -> *). PandocMonad m => MarkdownParser m Text
nonindentSpaces = do
Int
n <- forall (m :: * -> *). PandocMonad m => MarkdownParser m Int
skipNonindentSpaces
forall (m :: * -> *) a. Monad m => a -> m a
return forall a b. (a -> b) -> a -> b
$ Int -> Text -> Text
T.replicate Int
n Text
" "
skipNonindentSpaces :: PandocMonad m => MarkdownParser m Int
skipNonindentSpaces :: forall (m :: * -> *). PandocMonad m => MarkdownParser m Int
skipNonindentSpaces = do
Int
tabStop <- forall st s (m :: * -> *) t b.
(HasReaderOptions st, Stream s m t) =>
(ReaderOptions -> b) -> ParsecT s st m b
getOption ReaderOptions -> Int
readerTabStop
forall st (m :: * -> *).
(HasReaderOptions st, Monad m) =>
Int -> ParsecT Sources st m Int
gobbleAtMostSpaces (Int
tabStop forall a. Num a => a -> a -> a
- Int
1) 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
litChar :: PandocMonad m => MarkdownParser m Text
litChar :: forall (m :: * -> *). PandocMonad m => MarkdownParser m Text
litChar = Char -> Text
T.singleton forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall (m :: * -> *). PandocMonad m => MarkdownParser m Char
escapedChar'
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> forall s (m :: * -> *) st.
(Stream s m Char, UpdateSourcePos s Char) =>
ParsecT s st m Text
characterReference
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> Char -> Text
T.singleton 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) =>
FilePath -> ParsecT s u m Char
noneOf FilePath
"\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) =>
ParsecT s u m Char
newline 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 s (m :: * -> *) st.
(Stream s m Char, UpdateSourcePos s Char) =>
ParsecT s st m Char
blankline forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> forall (m :: * -> *) a. Monad m => a -> m a
return Text
" ")
inlinesInBalancedBrackets :: PandocMonad m => MarkdownParser m (F Inlines)
inlinesInBalancedBrackets :: forall (m :: * -> *). PandocMonad m => MarkdownParser m (F Inlines)
inlinesInBalancedBrackets =
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 :: * -> *) st a.
Monad m =>
ParsecT Sources st m a -> ParsecT Sources st m (a, Text)
withRaw (forall (m :: * -> *). PandocMonad m => Int -> MarkdownParser m ()
go Int
1) forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>=
forall (m :: * -> *) st r.
Monad m =>
ParsecT Sources st m r -> Text -> ParsecT Sources st m r
parseFromString forall (m :: * -> *). PandocMonad m => MarkdownParser m (F Inlines)
inlines forall b c a. (b -> c) -> (a -> b) -> a -> c
. Text -> Text
stripBracket forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a b. (a, b) -> b
snd
where stripBracket :: Text -> Text
stripBracket Text
t = case Text -> Maybe (Text, Char)
T.unsnoc Text
t of
Just (Text
t', Char
']') -> Text
t'
Maybe (Text, Char)
_ -> Text
t
go :: PandocMonad m => Int -> MarkdownParser m ()
go :: forall (m :: * -> *). PandocMonad m => Int -> MarkdownParser m ()
go Int
0 = forall (m :: * -> *) a. Monad m => a -> m a
return ()
go Int
openBrackets =
(() forall (f :: * -> *) a b. Functor f => a -> f b -> f a
<$ (forall (m :: * -> *). PandocMonad m => MarkdownParser m (F Inlines)
escapedChar forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|>
forall (m :: * -> *). PandocMonad m => MarkdownParser m (F Inlines)
code forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|>
forall (m :: * -> *). PandocMonad m => MarkdownParser m (F Inlines)
math forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|>
forall (m :: * -> *). PandocMonad m => MarkdownParser m (F Inlines)
endline forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|>
forall (m :: * -> *). PandocMonad m => MarkdownParser m (F Inlines)
rawHtmlInline forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|>
forall (m :: * -> *). PandocMonad m => MarkdownParser m (F Inlines)
rawLaTeXInline') forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> forall (m :: * -> *). PandocMonad m => Int -> MarkdownParser m ()
go Int
openBrackets)
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|>
(do forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
Char -> ParsecT s u m Char
char Char
']'
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
Control.Monad.when (Int
openBrackets forall a. Ord a => a -> a -> Bool
> Int
1) forall a b. (a -> b) -> a -> b
$ forall (m :: * -> *). PandocMonad m => Int -> MarkdownParser m ()
go (Int
openBrackets forall a. Num a => a -> a -> a
- Int
1))
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
'[' forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> forall (m :: * -> *). PandocMonad m => Int -> MarkdownParser m ()
go (Int
openBrackets forall a. Num a => a -> a -> a
+ Int
1))
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 -> Bool) -> ParsecT s u m Char
satisfy (forall a. Eq a => a -> a -> Bool
/= Char
'\n') forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> forall (m :: * -> *). PandocMonad m => Int -> MarkdownParser m ()
go Int
openBrackets)
rawTitleBlockLine :: PandocMonad m => MarkdownParser m Text
rawTitleBlockLine :: forall (m :: * -> *). PandocMonad m => MarkdownParser m Text
rawTitleBlockLine = do
forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
Char -> ParsecT s u m Char
char Char
'%'
forall s (m :: * -> *) st.
(Stream s m Char, UpdateSourcePos s Char) =>
ParsecT s st m ()
skipSpaces
Text
first <- 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 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 s (m :: * -> *) st.
(Stream s m Char, UpdateSourcePos s Char) =>
ParsecT s st m Char
spaceChar
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 :: * -> *) st.
(Stream s m Char, UpdateSourcePos s Char) =>
ParsecT s st m ()
skipSpaces
forall (m :: * -> *) st. Monad m => ParsecT Sources st m Text
anyLine
forall (m :: * -> *) a. Monad m => a -> m a
return forall a b. (a -> b) -> a -> b
$ Text -> Text
trim forall a b. (a -> b) -> a -> b
$ [Text] -> Text
T.unlines (Text
firstforall a. a -> [a] -> [a]
:[Text]
rest)
titleLine :: PandocMonad m => MarkdownParser m (F Inlines)
titleLine :: forall (m :: * -> *). PandocMonad m => MarkdownParser m (F Inlines)
titleLine = forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try forall a b. (a -> b) -> a -> b
$ do
Text
raw <- forall (m :: * -> *). PandocMonad m => MarkdownParser m Text
rawTitleBlockLine
F Inlines
res <- forall (m :: * -> *) u a.
(Monad m, HasLastStrPosition u) =>
ParsecT Sources u m a -> Text -> ParsecT Sources u m a
parseFromString' forall (m :: * -> *). PandocMonad m => MarkdownParser m (F Inlines)
inlines Text
raw
forall (m :: * -> *) a. Monad m => a -> m a
return forall a b. (a -> b) -> a -> b
$ forall s. Future s Inlines -> Future s Inlines
trimInlinesF F Inlines
res
authorsLine :: PandocMonad m => MarkdownParser m (F [Inlines])
authorsLine :: forall (m :: * -> *).
PandocMonad m =>
MarkdownParser m (F [Inlines])
authorsLine = forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try forall a b. (a -> b) -> a -> b
$ do
Text
raw <- forall (m :: * -> *). PandocMonad m => MarkdownParser m Text
rawTitleBlockLine
let sep :: ParsecT Sources u m Char
sep = (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 (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
ParsecT s u m ()
spaces) 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
let pAuthors :: ParsecT Sources ParserState m [F Inlines]
pAuthors = forall s (m :: * -> *) t u a sep.
Stream s m t =>
ParsecT s u m a -> ParsecT s u m sep -> ParsecT s u m [a]
sepEndBy
(forall s. Future s Inlines -> Future s Inlines
trimInlinesF 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 s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try forall a b. (a -> b) -> a -> b
$ forall s (m :: * -> *) t a u.
(Stream s m t, Show a) =>
ParsecT s u m a -> ParsecT s u m ()
notFollowedBy forall {u}. ParsecT Sources u m Char
sep forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> forall (m :: * -> *). PandocMonad m => MarkdownParser m (F Inlines)
inline))
forall {u}. ParsecT Sources u m Char
sep
forall (t :: * -> *) (m :: * -> *) a.
(Traversable t, Monad m) =>
t (m a) -> m (t a)
sequence 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' ParsecT Sources ParserState m [F Inlines]
pAuthors Text
raw
dateLine :: PandocMonad m => MarkdownParser m (F Inlines)
dateLine :: forall (m :: * -> *). PandocMonad m => MarkdownParser m (F Inlines)
dateLine = forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try forall a b. (a -> b) -> a -> b
$ do
Text
raw <- forall (m :: * -> *). PandocMonad m => MarkdownParser m Text
rawTitleBlockLine
F Inlines
res <- forall (m :: * -> *) u a.
(Monad m, HasLastStrPosition u) =>
ParsecT Sources u m a -> Text -> ParsecT Sources u m a
parseFromString' forall (m :: * -> *). PandocMonad m => MarkdownParser m (F Inlines)
inlines Text
raw
forall (m :: * -> *) a. Monad m => a -> m a
return forall a b. (a -> b) -> a -> b
$ forall s. Future s Inlines -> Future s Inlines
trimInlinesF F Inlines
res
titleBlock :: PandocMonad m => MarkdownParser m ()
titleBlock :: forall (m :: * -> *). PandocMonad m => MarkdownParser m ()
titleBlock = forall (m :: * -> *). PandocMonad m => MarkdownParser m ()
pandocTitleBlock forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> forall (m :: * -> *). PandocMonad m => MarkdownParser m ()
mmdTitleBlock
pandocTitleBlock :: PandocMonad m => MarkdownParser m ()
pandocTitleBlock :: forall (m :: * -> *). PandocMonad m => MarkdownParser m ()
pandocTitleBlock = do
forall s (m :: * -> *) a st.
(Stream s m a, HasReaderOptions st) =>
Extension -> ParsecT s st m ()
guardEnabled Extension
Ext_pandoc_title_block
forall s (m :: * -> *) t u a.
Stream s m t =>
ParsecT s u m a -> ParsecT s u m a
lookAhead (forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
Char -> ParsecT s u m Char
char Char
'%')
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try forall a b. (a -> b) -> a -> b
$ do
F Inlines
title <- 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 => MarkdownParser m (F Inlines)
titleLine
F [Inlines]
author <- forall s (m :: * -> *) t a u.
Stream s m t =>
a -> ParsecT s u m a -> ParsecT s u m a
option (forall (m :: * -> *) a. Monad m => a -> m a
return []) forall (m :: * -> *).
PandocMonad m =>
MarkdownParser m (F [Inlines])
authorsLine
F Inlines
date <- 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 => MarkdownParser m (F Inlines)
dateLine
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
let meta' :: Future ParserState Meta
meta' = do Inlines
title' <- F Inlines
title
[Inlines]
author' <- F [Inlines]
author
Inlines
date' <- F Inlines
date
forall (m :: * -> *) a. Monad m => a -> m a
return forall a b. (a -> b) -> a -> b
$
(if forall (t :: * -> *) a. Foldable t => t a -> Bool
null Inlines
title'
then forall a. a -> a
id
else forall a b. (HasMeta a, ToMetaValue b) => Text -> b -> a -> a
B.setMeta Text
"title" Inlines
title')
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (if forall (t :: * -> *) a. Foldable t => t a -> Bool
null [Inlines]
author'
then forall a. a -> a
id
else forall a b. (HasMeta a, ToMetaValue b) => Text -> b -> a -> a
B.setMeta Text
"author" [Inlines]
author')
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (if forall (t :: * -> *) a. Foldable t => t a -> Bool
null Inlines
date'
then forall a. a -> a
id
else forall a b. (HasMeta a, ToMetaValue b) => Text -> b -> a -> a
B.setMeta Text
"date" Inlines
date')
forall a b. (a -> b) -> a -> b
$ Meta
nullMeta
forall (m :: * -> *) u s. Monad m => (u -> u) -> ParsecT s u m ()
updateState forall a b. (a -> b) -> a -> b
$ \ParserState
st -> ParserState
st{ stateMeta' :: Future ParserState Meta
stateMeta' = ParserState -> Future ParserState Meta
stateMeta' ParserState
st forall a. Semigroup a => a -> a -> a
<> Future ParserState Meta
meta' }
yamlMetaBlock' :: PandocMonad m => MarkdownParser m (F Blocks)
yamlMetaBlock' :: forall (m :: * -> *). PandocMonad m => MarkdownParser m (F Blocks)
yamlMetaBlock' = do
forall s (m :: * -> *) a st.
(Stream s m a, HasReaderOptions st) =>
Extension -> ParsecT s st m ()
guardEnabled Extension
Ext_yaml_metadata_block
Future ParserState Meta
newMetaF <- forall st (m :: * -> *).
(HasLastStrPosition st, PandocMonad m) =>
ParsecT Sources st m (Future st MetaValue)
-> ParsecT Sources st m (Future st Meta)
yamlMetaBlock (forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap forall a. ToMetaValue a => a -> MetaValue
B.toMetaValue forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall (m :: * -> *). PandocMonad m => MarkdownParser m (F Blocks)
parseBlocks)
forall (m :: * -> *) u s. Monad m => (u -> u) -> ParsecT s u m ()
updateState forall a b. (a -> b) -> a -> b
$ \ParserState
st -> ParserState
st{ stateMeta' :: Future ParserState Meta
stateMeta' = ParserState -> Future ParserState Meta
stateMeta' ParserState
st forall a. Semigroup a => a -> a -> a
<> Future ParserState Meta
newMetaF }
forall (m :: * -> *) a. Monad m => a -> m a
return forall a. Monoid a => a
mempty
mmdTitleBlock :: PandocMonad m => MarkdownParser m ()
mmdTitleBlock :: forall (m :: * -> *). PandocMonad m => MarkdownParser m ()
mmdTitleBlock = do
forall s (m :: * -> *) a st.
(Stream s m a, HasReaderOptions st) =>
Extension -> ParsecT s st m ()
guardEnabled Extension
Ext_mmd_title_block
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try forall a b. (a -> b) -> a -> b
$ do
(Text, MetaValue)
firstPair <- forall (m :: * -> *).
PandocMonad m =>
Bool -> MarkdownParser m (Text, MetaValue)
kvPair Bool
False
[(Text, MetaValue)]
restPairs <- forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m [a]
many (forall (m :: * -> *).
PandocMonad m =>
Bool -> MarkdownParser m (Text, MetaValue)
kvPair Bool
True)
let kvPairs :: [(Text, MetaValue)]
kvPairs = (Text, MetaValue)
firstPair forall a. a -> [a] -> [a]
: [(Text, MetaValue)]
restPairs
forall s (m :: * -> *) st.
(Stream s m Char, UpdateSourcePos s Char) =>
ParsecT s st m Text
blanklines
forall (m :: * -> *) u s. Monad m => (u -> u) -> ParsecT s u m ()
updateState forall a b. (a -> b) -> a -> b
$ \ParserState
st -> ParserState
st{ stateMeta' :: Future ParserState Meta
stateMeta' = ParserState -> Future ParserState Meta
stateMeta' ParserState
st forall a. Semigroup a => a -> a -> a
<>
forall (m :: * -> *) a. Monad m => a -> m a
return (Map Text MetaValue -> Meta
Meta forall a b. (a -> b) -> a -> b
$ forall k a. Ord k => [(k, a)] -> Map k a
M.fromList [(Text, MetaValue)]
kvPairs) }
kvPair :: PandocMonad m => Bool -> MarkdownParser m (Text, MetaValue)
kvPair :: forall (m :: * -> *).
PandocMonad m =>
Bool -> MarkdownParser m (Text, MetaValue)
kvPair Bool
allowEmpty = forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try forall a b. (a -> b) -> a -> b
$ do
Text
key <- forall end s (m :: * -> *) t st.
(Show end, Stream s m t) =>
ParsecT s st m Char -> ParsecT s st m end -> ParsecT s st m Text
many1TillChar (forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
ParsecT s u m Char
alphaNum 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) =>
FilePath -> ParsecT s u m Char
oneOf FilePath
"_- ") (forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
Char -> ParsecT s u m Char
char Char
':')
Text
val <- Text -> Text
trim forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall s (m :: * -> *) t st a.
Stream s m t =>
ParsecT s st m Char -> ParsecT s st m a -> ParsecT s st m Text
manyTillChar forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
ParsecT s u m Char
anyChar
(forall 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) =>
ParsecT s u m Char
newline forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> forall s (m :: * -> *) t u a.
Stream s m t =>
ParsecT s u m a -> ParsecT s u m a
lookAhead (forall s (m :: * -> *) st.
(Stream s m Char, UpdateSourcePos s Char) =>
ParsecT s st m Char
blankline forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> forall s (m :: * -> *) st.
(Stream s m Char, UpdateSourcePos s Char) =>
ParsecT s st m Char
nonspaceChar))
forall (f :: * -> *). Alternative f => Bool -> f ()
guard forall a b. (a -> b) -> a -> b
$ Bool
allowEmpty Bool -> Bool -> Bool
|| Bool -> Bool
not (Text -> Bool
T.null Text
val)
let key' :: Text
key' = [Text] -> Text
T.concat forall a b. (a -> b) -> a -> b
$ Text -> [Text]
T.words forall a b. (a -> b) -> a -> b
$ Text -> Text
T.toLower Text
key
let val' :: MetaValue
val' = [Inline] -> MetaValue
MetaInlines forall a b. (a -> b) -> a -> b
$ forall a. Many a -> [a]
B.toList forall a b. (a -> b) -> a -> b
$ Text -> Inlines
B.text Text
val
forall (m :: * -> *) a. Monad m => a -> m a
return (Text
key',MetaValue
val')
parseMarkdown :: PandocMonad m => MarkdownParser m Pandoc
parseMarkdown :: forall (m :: * -> *). PandocMonad m => MarkdownParser m Pandoc
parseMarkdown = 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 => MarkdownParser m ()
titleBlock
F Blocks
blocks <- forall (m :: * -> *). PandocMonad m => MarkdownParser m (F Blocks)
parseBlocks
ParserState
st <- forall (m :: * -> *) s u. Monad m => ParsecT s u m u
getState
forall (m :: * -> *). PandocMonad m => MarkdownParser m ()
checkNotes
let doc :: Pandoc
doc = forall s a. Future s a -> s -> a
runF (do Pandoc Meta
_ [Block]
bs <- Blocks -> Pandoc
B.doc forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> F Blocks
blocks
Meta
meta <- ParserState -> Future ParserState Meta
stateMeta' ParserState
st
forall (m :: * -> *) a. Monad m => a -> m a
return forall a b. (a -> b) -> a -> b
$ Meta -> [Block] -> Pandoc
Pandoc Meta
meta [Block]
bs) ParserState
st
forall (m :: * -> *) st s.
(PandocMonad m, HasLogMessages st) =>
ParsecT s st m ()
reportLogMessages
forall (m :: * -> *) a. Monad m => a -> m a
return Pandoc
doc
checkNotes :: PandocMonad m => MarkdownParser m ()
checkNotes :: forall (m :: * -> *). PandocMonad m => MarkdownParser m ()
checkNotes = do
ParserState
st <- forall (m :: * -> *) s u. Monad m => ParsecT s u m u
getState
let notesUsed :: Set Text
notesUsed = ParserState -> Set Text
stateNoteRefs ParserState
st
let notesDefined :: [Text]
notesDefined = forall k a. Map k a -> [k]
M.keys (ParserState -> NoteTable'
stateNotes' ParserState
st)
forall (t :: * -> *) (m :: * -> *) a b.
(Foldable t, Monad m) =>
(a -> m b) -> t a -> m ()
mapM_ (\Text
n -> forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
unless (Text
n forall a. Ord a => a -> Set a -> Bool
`Set.member` Set Text
notesUsed) forall a b. (a -> b) -> a -> b
$
case forall k a. Ord k => k -> Map k a -> Maybe a
M.lookup Text
n (ParserState -> NoteTable'
stateNotes' ParserState
st) of
Just (SourcePos
pos, F Blocks
_) -> forall (m :: * -> *). PandocMonad m => LogMessage -> m ()
report (Text -> SourcePos -> LogMessage
NoteDefinedButNotUsed Text
n SourcePos
pos)
Maybe (SourcePos, F Blocks)
Nothing -> forall e (m :: * -> *) a. MonadError e m => e -> m a
throwError forall a b. (a -> b) -> a -> b
$
Text -> PandocError
PandocShouldNeverHappenError Text
"note not found")
[Text]
notesDefined
referenceKey :: PandocMonad m => MarkdownParser m (F Blocks)
referenceKey :: forall (m :: * -> *). PandocMonad m => MarkdownParser m (F Blocks)
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 :: * -> *). PandocMonad m => MarkdownParser m Int
skipNonindentSpaces
forall s (m :: * -> *) t a u.
(Stream s m t, Show a) =>
ParsecT s u m a -> ParsecT s u m ()
notFollowedBy (forall (f :: * -> *) a. Functor f => f a -> f ()
void forall (m :: * -> *). PandocMonad m => MarkdownParser m (F Inlines)
cite)
(F Inlines
_,Text
raw) <- forall (m :: * -> *).
PandocMonad m =>
MarkdownParser m (F Inlines, Text)
reference
forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
Char -> ParsecT s u m Char
char Char
':'
forall s (m :: * -> *) st.
(Stream s m Char, UpdateSourcePos s Char) =>
ParsecT s st m ()
skipSpaces 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 ()
optional 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 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 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
'[')
let sourceURL :: ParsecT Sources ParserState m Text
sourceURL = forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap [Text] -> Text
T.unwords forall a b. (a -> b) -> a -> b
$ forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m [a]
many 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 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 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 => MarkdownParser m Text
referenceTitle
forall b s (m :: * -> *) a st.
(Show b, Stream s m a) =>
ParsecT s st m b -> ParsecT s st m ()
notFollowedBy' forall a b. (a -> b) -> a -> b
$ forall s (m :: * -> *) a st.
(Stream s m a, HasReaderOptions st) =>
Extension -> ParsecT s st m ()
guardEnabled Extension
Ext_link_attributes forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>>
forall (m :: * -> *). PandocMonad m => MarkdownParser m Attr
attributes
forall b s (m :: * -> *) a st.
(Show b, Stream s m a) =>
ParsecT s st m b -> ParsecT s st m ()
notFollowedBy' forall a b. (a -> b) -> a -> b
$ forall s (m :: * -> *) a st.
(Stream s m a, HasReaderOptions st) =>
Extension -> ParsecT s st m ()
guardEnabled Extension
Ext_mmd_link_attributes 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 :: * -> *) st. PandocMonad m => ParsecT Sources st m ()
spnl forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
<* forall (m :: * -> *).
PandocMonad m =>
MarkdownParser m (Attr -> Attr)
keyValAttr)
forall b s (m :: * -> *) a st.
(Show b, Stream s m a) =>
ParsecT s st m b -> ParsecT s st m ()
notFollowedBy' (() forall (f :: * -> *) a b. Functor f => a -> f b -> f a
<$ forall (m :: * -> *).
PandocMonad m =>
MarkdownParser m (F Inlines, Text)
reference)
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 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 forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> forall (m :: * -> *). PandocMonad m => MarkdownParser m Text
litChar)
let betweenAngles :: ParsecT Sources ParserState m Text
betweenAngles = 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 a. Monoid a => [a] -> a
mconcat forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (forall s (m :: * -> *) t u a sep.
Stream s m t =>
ParsecT s u m a -> ParsecT s u m sep -> ParsecT s u m [a]
manyTill forall (m :: * -> *). PandocMonad m => MarkdownParser m Text
litChar (forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
Char -> ParsecT s u m Char
char Char
'>'))
Bool
rebase <- 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 s (m :: * -> *) a st.
(Stream s m a, HasReaderOptions st) =>
Extension -> ParsecT s st m ()
guardEnabled Extension
Ext_rebase_relative_paths)
Text
src <- (if Bool
rebase then SourcePos -> Text -> Text
rebasePath SourcePos
pos else forall a. a -> a
id) 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 ParsecT Sources ParserState m Text
betweenAngles forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> ParsecT Sources ParserState m Text
sourceURL)
Text
tit <- forall s (m :: * -> *) t a u.
Stream s m t =>
a -> ParsecT s u m a -> ParsecT s u m a
option Text
"" forall (m :: * -> *). PandocMonad m => MarkdownParser m Text
referenceTitle
Attr
attr <- forall s (m :: * -> *) t a u.
Stream s m t =>
a -> ParsecT s u m a -> ParsecT s u m a
option Attr
nullAttr 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 s (m :: * -> *) a st.
(Stream s m a, HasReaderOptions st) =>
Extension -> ParsecT s st m ()
guardEnabled Extension
Ext_link_attributes
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 s (m :: * -> *) t u a.
Stream s m t =>
ParsecT s u m a -> ParsecT s u m ()
optional 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 s (m :: * -> *) st.
(Stream s m Char, UpdateSourcePos s Char) =>
ParsecT s st m ()
skipSpaces
forall (m :: * -> *). PandocMonad m => MarkdownParser m Attr
attributes
[Attr -> Attr]
addKvs <- forall s (m :: * -> *) t a u.
Stream s m t =>
a -> ParsecT s u m a -> ParsecT s u m a
option [] forall a b. (a -> b) -> a -> b
$ forall s (m :: * -> *) a st.
(Stream s m a, HasReaderOptions st) =>
Extension -> ParsecT s st m ()
guardEnabled Extension
Ext_mmd_link_attributes
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m [a]
many (forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try forall a b. (a -> b) -> a -> b
$ forall (m :: * -> *) st. PandocMonad m => ParsecT Sources st m ()
spnl forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> forall (m :: * -> *).
PandocMonad m =>
MarkdownParser m (Attr -> Attr)
keyValAttr)
forall s (m :: * -> *) st.
(Stream s m Char, UpdateSourcePos s Char) =>
ParsecT s st m Text
blanklines
let attr' :: Attr
attr' = Attr -> Attr
extractIdClass forall a b. (a -> b) -> a -> b
$ forall (t :: * -> *) b a.
Foldable t =>
(b -> a -> b) -> b -> t a -> b
foldl' (\Attr
x Attr -> Attr
f -> Attr -> Attr
f Attr
x) Attr
attr [Attr -> Attr]
addKvs
target :: Target
target = (Text -> Text
escapeURI forall a b. (a -> b) -> a -> b
$ Text -> Text
trimr Text
src, Text
tit)
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
raw
case forall k a. Ord k => k -> Map k a -> Maybe a
M.lookup Key
key KeyTable
oldkeys of
Just (Target
t,Attr
a) | Bool -> Bool
not (Target
t forall a. Eq a => a -> a -> Bool
== Target
target Bool -> Bool -> Bool
&& Attr
a forall a. Eq a => a -> a -> Bool
== Attr
attr') ->
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
raw SourcePos
pos
Maybe (Target, 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 (Target
target, Attr
attr') KeyTable
oldkeys }
forall (m :: * -> *) a. Monad m => a -> m a
return forall a b. (a -> b) -> a -> b
$ forall (m :: * -> *) a. Monad m => a -> m a
return forall a. Monoid a => a
mempty
referenceTitle :: PandocMonad m => MarkdownParser m Text
referenceTitle :: forall (m :: * -> *). PandocMonad m => MarkdownParser m Text
referenceTitle = 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 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 ()
optional 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 s (m :: * -> *) st.
(Stream s m Char, UpdateSourcePos s Char) =>
ParsecT s st m ()
skipSpaces
forall (m :: * -> *).
PandocMonad m =>
Char -> MarkdownParser m Text
quotedTitle Char
'"' forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> forall (m :: * -> *).
PandocMonad m =>
Char -> MarkdownParser m Text
quotedTitle Char
'\'' forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> forall s (m :: * -> *) st.
(Stream s m Char, UpdateSourcePos s Char) =>
Char -> Char -> ParsecT s st m Text -> ParsecT s st m Text
charsInBalanced Char
'(' Char
')' forall (m :: * -> *). PandocMonad m => MarkdownParser m Text
litChar
quotedTitle :: PandocMonad m => Char -> MarkdownParser m Text
quotedTitle :: forall (m :: * -> *).
PandocMonad m =>
Char -> MarkdownParser m Text
quotedTitle Char
c = 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
c
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 ()
spaces
let pEnder :: ParsecT Sources u m ()
pEnder = 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
c 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) =>
(Char -> Bool) -> ParsecT s u m Char
satisfy Char -> Bool
isAlphaNum)
let regChunk :: ParsecT Sources ParserState m Text
regChunk = forall s (m :: * -> *) t st.
Stream s m t =>
ParsecT s st m Char -> ParsecT s st m Text
many1Char (forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
FilePath -> ParsecT s u m Char
noneOf [Char
'\\',Char
'\n',Char
'&',Char
c]) forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> forall (m :: * -> *). PandocMonad m => MarkdownParser m Text
litChar
let nestedChunk :: ParsecT Sources ParserState m Text
nestedChunk = (\Text
x -> (Char
c Char -> Text -> Text
`T.cons` Text
x) Text -> Char -> Text
`T.snoc` Char
c) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall (m :: * -> *).
PandocMonad m =>
Char -> MarkdownParser m Text
quotedTitle Char
c
[Text] -> Text
T.unwords forall b c a. (b -> c) -> (a -> b) -> a -> c
. Text -> [Text]
T.words forall b c a. (b -> c) -> (a -> b) -> a -> c
. [Text] -> Text
T.concat forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall s (m :: * -> *) t u a sep.
Stream s m t =>
ParsecT s u m a -> ParsecT s u m sep -> ParsecT s u m [a]
manyTill (ParsecT Sources ParserState m Text
nestedChunk forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> ParsecT Sources ParserState m Text
regChunk) forall {u}. ParsecT Sources u m ()
pEnder
abbrevKey :: PandocMonad m => MarkdownParser m (F Blocks)
abbrevKey :: forall (m :: * -> *). PandocMonad m => MarkdownParser m (F Blocks)
abbrevKey = do
forall s (m :: * -> *) a st.
(Stream s m a, HasReaderOptions st) =>
Extension -> ParsecT s st m ()
guardEnabled Extension
Ext_abbreviations
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 :: * -> *).
PandocMonad m =>
MarkdownParser m (F Inlines, Text)
reference
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 ()
skipMany (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 (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
$ forall (m :: * -> *) a. Monad m => a -> m a
return forall a. Monoid a => a
mempty
noteMarker :: PandocMonad m => MarkdownParser m Text
noteMarker :: forall (m :: * -> *). PandocMonad m => MarkdownParser m Text
noteMarker = forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
FilePath -> ParsecT s u m FilePath
string FilePath
"[^" forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> forall end s (m :: * -> *) t st.
(Show end, Stream s m t) =>
ParsecT s st m Char -> ParsecT s st m end -> ParsecT s st m Text
many1TillChar (forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
(Char -> Bool) -> ParsecT s u m Char
satisfy forall a b. (a -> b) -> a -> b
$ Bool -> Bool
not forall b c a. (b -> c) -> (a -> b) -> a -> c
. Char -> Bool
isBlank) (forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
Char -> ParsecT s u m Char
char Char
']')
rawLine :: PandocMonad m => MarkdownParser m Text
rawLine :: forall (m :: * -> *). PandocMonad m => MarkdownParser m Text
rawLine = 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 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 b s (m :: * -> *) a st.
(Show b, Stream s m a) =>
ParsecT s st m b -> ParsecT s st m ()
notFollowedBy' 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 :: * -> *). PandocMonad m => MarkdownParser m Int
skipNonindentSpaces forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> forall (m :: * -> *). PandocMonad m => MarkdownParser m Text
noteMarker
forall s (m :: * -> *) t u a.
Stream s m t =>
ParsecT s u m a -> ParsecT s u m ()
optional forall (m :: * -> *). PandocMonad m => MarkdownParser m Text
indentSpaces
forall (m :: * -> *) st. Monad m => ParsecT Sources st m Text
anyLine
rawLines :: PandocMonad m => MarkdownParser m Text
rawLines :: forall (m :: * -> *). PandocMonad m => MarkdownParser m Text
rawLines = do
Text
first <- 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 (m :: * -> *). PandocMonad m => MarkdownParser m Text
rawLine
forall (m :: * -> *) a. Monad m => a -> m a
return forall a b. (a -> b) -> a -> b
$ [Text] -> Text
T.unlines (Text
firstforall a. a -> [a] -> [a]
:[Text]
rest)
noteBlock :: PandocMonad m => MarkdownParser m (F Blocks)
noteBlock :: forall (m :: * -> *). PandocMonad m => MarkdownParser m (F Blocks)
noteBlock = do
forall s (m :: * -> *) a st.
(Stream s m a, HasReaderOptions st) =>
Extension -> ParsecT s st m ()
guardEnabled Extension
Ext_footnotes
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 :: * -> *). PandocMonad m => MarkdownParser m Int
skipNonindentSpaces
Text
ref <- forall (m :: * -> *). PandocMonad m => MarkdownParser m Text
noteMarker
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 s (m :: * -> *) st.
(Stream s m Char, UpdateSourcePos s Char) =>
ParsecT s st m Char
blankline
forall s (m :: * -> *) t u a.
Stream s m t =>
ParsecT s u m a -> ParsecT s u m ()
optional forall (m :: * -> *). PandocMonad m => MarkdownParser m Text
indentSpaces
forall (m :: * -> *) u s. Monad m => (u -> u) -> ParsecT s u m ()
updateState forall a b. (a -> b) -> a -> b
$ \ParserState
st -> ParserState
st{ stateInNote :: Bool
stateInNote = Bool
True }
Text
first <- forall (m :: * -> *). PandocMonad m => MarkdownParser m Text
rawLines
[Text]
rest <- forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m [a]
many 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 s (m :: * -> *) st.
(Stream s m Char, UpdateSourcePos s Char) =>
ParsecT s st m Text
blanklines forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> forall (m :: * -> *). PandocMonad m => MarkdownParser m Text
indentSpaces forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> forall (m :: * -> *). PandocMonad m => MarkdownParser m Text
rawLines
let raw :: Text
raw = [Text] -> Text
T.unlines (Text
firstforall a. a -> [a] -> [a]
:[Text]
rest) forall a. Semigroup a => a -> a -> a
<> Text
"\n"
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
F Blocks
parsed <- forall (m :: * -> *) u a.
(Monad m, HasLastStrPosition u) =>
ParsecT Sources u m a -> Text -> ParsecT Sources u m a
parseFromString' forall (m :: * -> *). PandocMonad m => MarkdownParser m (F Blocks)
parseBlocks Text
raw
NoteTable'
oldnotes <- 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 k a. Ord k => k -> Map k a -> Maybe a
M.lookup Text
ref NoteTable'
oldnotes of
Just (SourcePos, F Blocks)
_ -> 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
DuplicateNoteReference Text
ref SourcePos
pos
Maybe (SourcePos, F Blocks)
Nothing -> 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 { stateNotes' :: NoteTable'
stateNotes' =
forall k a. Ord k => k -> a -> Map k a -> Map k a
M.insert Text
ref (SourcePos
pos, F Blocks
parsed) NoteTable'
oldnotes,
stateInNote :: Bool
stateInNote = Bool
False }
forall (m :: * -> *) a. Monad m => a -> m a
return forall a. Monoid a => a
mempty
parseBlocks :: PandocMonad m => MarkdownParser m (F Blocks)
parseBlocks :: forall (m :: * -> *). PandocMonad m => MarkdownParser m (F Blocks)
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 sep.
Stream s m t =>
ParsecT s u m a -> ParsecT s u m sep -> ParsecT s u m [a]
manyTill forall (m :: * -> *). PandocMonad m => MarkdownParser m (F Blocks)
block forall s (m :: * -> *) t u.
(Stream s m t, Show t) =>
ParsecT s u m ()
eof
block :: PandocMonad m => MarkdownParser m (F Blocks)
block :: forall (m :: * -> *). PandocMonad m => MarkdownParser m (F Blocks)
block = do
F Blocks
res <- forall s (m :: * -> *) t u a.
Stream s m t =>
[ParsecT s u m a] -> ParsecT s u m a
choice [ forall a. Monoid a => a
mempty forall (f :: * -> *) a b. Functor f => a -> f b -> f a
<$ forall s (m :: * -> *) st.
(Stream s m Char, UpdateSourcePos s Char) =>
ParsecT s st m Text
blanklines
, forall (m :: * -> *). PandocMonad m => MarkdownParser m (F Blocks)
codeBlockFenced
, forall (m :: * -> *). PandocMonad m => MarkdownParser m (F Blocks)
yamlMetaBlock'
, forall (m :: * -> *). PandocMonad m => MarkdownParser m (F Blocks)
bulletList
, forall (m :: * -> *). PandocMonad m => MarkdownParser m (F Blocks)
divHtml
, forall (m :: * -> *). PandocMonad m => MarkdownParser m (F Blocks)
divFenced
, forall (m :: * -> *). PandocMonad m => MarkdownParser m (F Blocks)
header
, forall (m :: * -> *). PandocMonad m => MarkdownParser m (F Blocks)
lhsCodeBlock
, forall (m :: * -> *). PandocMonad m => MarkdownParser m (F Blocks)
htmlBlock
, forall (m :: * -> *). PandocMonad m => MarkdownParser m (F Blocks)
table
, forall (m :: * -> *). PandocMonad m => MarkdownParser m (F Blocks)
codeBlockIndented
, forall (m :: * -> *). PandocMonad m => MarkdownParser m (F Blocks)
rawTeXBlock
, forall (m :: * -> *). PandocMonad m => MarkdownParser m (F Blocks)
lineBlock
, forall (m :: * -> *). PandocMonad m => MarkdownParser m (F Blocks)
blockQuote
, forall (m :: * -> *) st.
PandocMonad m =>
ParsecT Sources st m (F Blocks)
hrule
, forall (m :: * -> *). PandocMonad m => MarkdownParser m (F Blocks)
orderedList
, forall (m :: * -> *). PandocMonad m => MarkdownParser m (F Blocks)
definitionList
, forall (m :: * -> *). PandocMonad m => MarkdownParser m (F Blocks)
noteBlock
, forall (m :: * -> *). PandocMonad m => MarkdownParser m (F Blocks)
referenceKey
, forall (m :: * -> *). PandocMonad m => MarkdownParser m (F Blocks)
abbrevKey
, forall (m :: * -> *). PandocMonad m => MarkdownParser m (F Blocks)
para
, forall (m :: * -> *). PandocMonad m => MarkdownParser m (F Blocks)
plain
] forall s u (m :: * -> *) a.
ParsecT s u m a -> FilePath -> ParsecT s u m a
<?> FilePath
"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 forall a b. (a -> b) -> a -> b
$ forall s a. Future s a -> s -> a
runF F Blocks
res ParserState
defaultParserState)
forall (m :: * -> *) a. Monad m => a -> m a
return F Blocks
res
header :: PandocMonad m => MarkdownParser m (F Blocks)
= forall (m :: * -> *). PandocMonad m => MarkdownParser m (F Blocks)
setextHeader forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> forall (m :: * -> *). PandocMonad m => MarkdownParser m (F Blocks)
atxHeader forall s u (m :: * -> *) a.
ParsecT s u m a -> FilePath -> ParsecT s u m a
<?> FilePath
"header"
atxChar :: PandocMonad m => MarkdownParser m Char
atxChar :: forall (m :: * -> *). PandocMonad m => MarkdownParser m Char
atxChar = do
Extensions
exts <- forall st s (m :: * -> *) t b.
(HasReaderOptions st, Stream s m t) =>
(ReaderOptions -> b) -> ParsecT s st m b
getOption ReaderOptions -> Extensions
readerExtensions
forall (m :: * -> *) a. Monad m => a -> m a
return forall a b. (a -> b) -> a -> b
$ if Extension -> Extensions -> Bool
extensionEnabled Extension
Ext_literate_haskell Extensions
exts
then Char
'='
else Char
'#'
atxHeader :: PandocMonad m => MarkdownParser m (F 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
Int
level <- forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap forall (t :: * -> *) a. Foldable t => t a -> Int
length (forall (m :: * -> *). PandocMonad m => MarkdownParser m Char
atxChar forall (m :: * -> *) a b. Monad m => m a -> (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 b c a. (b -> c) -> (a -> b) -> a -> c
. forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
Char -> ParsecT s u m 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 a b. (a -> b) -> a -> b
$ forall s (m :: * -> *) a st.
(Stream s m a, HasReaderOptions st) =>
Extension -> ParsecT s st m ()
guardEnabled Extension
Ext_fancy_lists 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 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
')')
forall s (m :: * -> *) a st.
(Stream s m a, HasReaderOptions st) =>
Extension -> ParsecT s st m ()
guardDisabled Extension
Ext_space_in_atx_header forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m 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
nonspaceChar
forall s (m :: * -> *) st.
(Stream s m Char, UpdateSourcePos s Char) =>
ParsecT s st m ()
skipSpaces
(F Inlines
text, Text
raw) <- forall (m :: * -> *) st a.
Monad m =>
ParsecT Sources st m a -> ParsecT Sources st m (a, Text)
withRaw forall a b. (a -> b) -> a -> b
$ do
Bool
oldAllowLineBreaks <- ParserState -> Bool
stateAllowLineBreaks forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall (m :: * -> *) s u. Monad m => ParsecT s u m u
getState
forall (m :: * -> *) u s. Monad m => (u -> u) -> ParsecT s u m ()
updateState forall a b. (a -> b) -> a -> b
$ \ParserState
st -> ParserState
st{ stateAllowLineBreaks :: Bool
stateAllowLineBreaks = Bool
False }
F Inlines
res <- forall s. Future s Inlines -> Future s Inlines
trimInlinesF 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 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 => MarkdownParser m Attr
atxClosing forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> forall (m :: * -> *). PandocMonad m => MarkdownParser m (F Inlines)
inline)
forall (m :: * -> *) u s. Monad m => (u -> u) -> ParsecT s u m ()
updateState forall a b. (a -> b) -> a -> b
$ \ParserState
st -> ParserState
st{ stateAllowLineBreaks :: Bool
stateAllowLineBreaks = Bool
oldAllowLineBreaks }
forall (m :: * -> *) a. Monad m => a -> m a
return F Inlines
res
Attr
attr <- forall (m :: * -> *). PandocMonad m => MarkdownParser m Attr
atxClosing
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 (forall s a. Future s a -> s -> a
runF F Inlines
text ParserState
defaultParserState)
forall s (m :: * -> *) a st.
(Stream s m a, HasReaderOptions st) =>
Extension -> ParsecT s st m ()
guardDisabled Extension
Ext_implicit_header_references
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> forall (m :: * -> *).
PandocMonad m =>
Text -> Attr -> MarkdownParser m ()
registerImplicitHeader Text
raw Attr
attr'
forall (m :: * -> *) a. Monad m => a -> m a
return forall a b. (a -> b) -> a -> b
$ Attr -> Int -> Inlines -> Blocks
B.headerWith Attr
attr' Int
level forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> F Inlines
text
atxClosing :: PandocMonad m => MarkdownParser m Attr
atxClosing :: forall (m :: * -> *). PandocMonad m => MarkdownParser m Attr
atxClosing = 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 s (m :: * -> *) t a u.
Stream s m t =>
a -> ParsecT s u m a -> ParsecT s u m a
option Attr
nullAttr
(forall s (m :: * -> *) a st.
(Stream s m a, HasReaderOptions st) =>
Extension -> ParsecT s st m ()
guardEnabled Extension
Ext_mmd_header_identifiers forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> forall (m :: * -> *). PandocMonad m => MarkdownParser m Attr
mmdHeaderIdentifier)
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m ()
skipMany forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
Char -> ParsecT s u m Char
char forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< forall (m :: * -> *). PandocMonad m => MarkdownParser m Char
atxChar
forall s (m :: * -> *) st.
(Stream s m Char, UpdateSourcePos s Char) =>
ParsecT s st m ()
skipSpaces
Attr
attr <- forall s (m :: * -> *) t a u.
Stream s m t =>
a -> ParsecT s u m a -> ParsecT s u m a
option Attr
attr'
(forall s (m :: * -> *) a st.
(Stream s m a, HasReaderOptions st) =>
Extension -> ParsecT s st m ()
guardEnabled Extension
Ext_header_attributes forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> forall (m :: * -> *). PandocMonad m => MarkdownParser m Attr
attributes)
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 Attr
attr
setextHeaderEnd :: PandocMonad m => MarkdownParser m Attr
= 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 s (m :: * -> *) t a u.
Stream s m t =>
a -> ParsecT s u m a -> ParsecT s u m a
option Attr
nullAttr
forall a b. (a -> b) -> a -> b
$ (forall s (m :: * -> *) a st.
(Stream s m a, HasReaderOptions st) =>
Extension -> ParsecT s st m ()
guardEnabled Extension
Ext_mmd_header_identifiers forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> forall (m :: * -> *). PandocMonad m => MarkdownParser m Attr
mmdHeaderIdentifier)
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> (forall s (m :: * -> *) a st.
(Stream s m a, HasReaderOptions st) =>
Extension -> ParsecT s st m ()
guardEnabled Extension
Ext_header_attributes forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> forall (m :: * -> *). PandocMonad m => MarkdownParser m Attr
attributes)
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 Attr
attr
mmdHeaderIdentifier :: PandocMonad m => MarkdownParser m Attr
= do
(F Inlines
_, Text
raw) <- forall (m :: * -> *).
PandocMonad m =>
MarkdownParser m (F Inlines, Text)
reference
let raw' :: Text
raw' = Text -> Text
trim forall a b. (a -> b) -> a -> b
$ Text -> Text
stripFirstAndLast Text
raw
let ident :: Text
ident = [Text] -> Text
T.concat forall a b. (a -> b) -> a -> b
$ Text -> [Text]
T.words forall a b. (a -> b) -> a -> b
$ Text -> Text
T.toLower Text
raw'
let attr :: (Text, [a], [a])
attr = (Text
ident, [], [])
forall s (m :: * -> *) a st.
(Stream s m a, HasReaderOptions st) =>
Extension -> ParsecT s st m ()
guardDisabled Extension
Ext_implicit_header_references
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> forall (m :: * -> *).
PandocMonad m =>
Text -> Attr -> MarkdownParser m ()
registerImplicitHeader Text
raw' forall {a} {a}. (Text, [a], [a])
attr
forall s (m :: * -> *) st.
(Stream s m Char, UpdateSourcePos s Char) =>
ParsecT s st m ()
skipSpaces
forall (m :: * -> *) a. Monad m => a -> m a
return forall {a} {a}. (Text, [a], [a])
attr
setextHeader :: PandocMonad m => MarkdownParser m (F 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 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 :: * -> *) st. Monad m => ParsecT Sources st m Text
anyLine 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) =>
FilePath -> ParsecT s u m Char
oneOf FilePath
setextHChars) forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> forall s (m :: * -> *) st.
(Stream s m Char, UpdateSourcePos s Char) =>
ParsecT s st m Char
blankline
forall s (m :: * -> *) st.
(Stream s m Char, UpdateSourcePos s Char) =>
ParsecT s st m ()
skipSpaces
(F Inlines
text, Text
raw) <- forall (m :: * -> *) st a.
Monad m =>
ParsecT Sources st m a -> ParsecT Sources st m (a, Text)
withRaw forall a b. (a -> b) -> a -> b
$ do
Bool
oldAllowLineBreaks <- ParserState -> Bool
stateAllowLineBreaks forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall (m :: * -> *) s u. Monad m => ParsecT s u m u
getState
forall (m :: * -> *) u s. Monad m => (u -> u) -> ParsecT s u m ()
updateState forall a b. (a -> b) -> a -> b
$ \ParserState
st -> ParserState
st{ stateAllowLineBreaks :: Bool
stateAllowLineBreaks = Bool
False }
F Inlines
res <- forall s. Future s Inlines -> Future s Inlines
trimInlinesF 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 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 => MarkdownParser m Attr
setextHeaderEnd forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> forall (m :: * -> *). PandocMonad m => MarkdownParser m (F Inlines)
inline)
forall (m :: * -> *) u s. Monad m => (u -> u) -> ParsecT s u m ()
updateState forall a b. (a -> b) -> a -> b
$ \ParserState
st -> ParserState
st{ stateAllowLineBreaks :: Bool
stateAllowLineBreaks = Bool
oldAllowLineBreaks }
forall (m :: * -> *) a. Monad m => a -> m a
return F Inlines
res
Attr
attr <- forall (m :: * -> *). PandocMonad m => MarkdownParser m Attr
setextHeaderEnd
Char
underlineChar <- forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
FilePath -> ParsecT s u m Char
oneOf FilePath
setextHChars
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m [a]
many (forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
Char -> ParsecT s u m Char
char Char
underlineChar)
forall s (m :: * -> *) st.
(Stream s m Char, UpdateSourcePos s Char) =>
ParsecT s st m Text
blanklines
let level :: Int
level = forall a. a -> Maybe a -> a
fromMaybe Int
0 (forall a. Eq a => a -> [a] -> Maybe Int
elemIndex Char
underlineChar FilePath
setextHChars) forall a. Num a => a -> a -> a
+ Int
1
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 (forall s a. Future s a -> s -> a
runF F Inlines
text ParserState
defaultParserState)
forall s (m :: * -> *) a st.
(Stream s m a, HasReaderOptions st) =>
Extension -> ParsecT s st m ()
guardDisabled Extension
Ext_implicit_header_references
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> forall (m :: * -> *).
PandocMonad m =>
Text -> Attr -> MarkdownParser m ()
registerImplicitHeader Text
raw Attr
attr'
forall (m :: * -> *) a. Monad m => a -> m a
return forall a b. (a -> b) -> a -> b
$ Attr -> Int -> Inlines -> Blocks
B.headerWith Attr
attr' Int
level forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> F Inlines
text
registerImplicitHeader :: PandocMonad m => Text -> Attr -> MarkdownParser m ()
Text
raw attr :: Attr
attr@(Text
ident, [Text]
_, [Target]
_)
| Text -> Bool
T.null Text
raw = forall (m :: * -> *) a. Monad m => a -> m a
return ()
| Bool
otherwise = do
let key :: Key
key = Text -> Key
toKey forall a b. (a -> b) -> a -> b
$ Text
"[" forall a. Semigroup a => a -> a -> a
<> Text
raw forall a. Semigroup a => a -> a -> a
<> Text
"]"
forall (m :: * -> *) u s. Monad m => (u -> u) -> ParsecT s u m ()
updateState forall a b. (a -> b) -> a -> b
$ \ParserState
s ->
ParserState
s { stateHeaderKeys :: KeyTable
stateHeaderKeys = forall k a. Ord k => (a -> a -> a) -> k -> a -> Map k a -> Map k a
M.insertWith (\(Target, Attr)
_new (Target, Attr)
old -> (Target, Attr)
old)
Key
key ((Text
"#" forall a. Semigroup a => a -> a -> a
<> Text
ident,Text
""), Attr
attr)
(ParserState -> KeyTable
stateHeaderKeys ParserState
s) }
hrule :: PandocMonad m => ParsecT Sources st m (F Blocks)
hrule :: forall (m :: * -> *) st.
PandocMonad m =>
ParsecT Sources st m (F Blocks)
hrule = forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try forall a b. (a -> b) -> a -> b
$ 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 -> Bool) -> ParsecT s u m Char
satisfy Char -> Bool
isHruleChar
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 forall a b. (a -> b) -> a -> b
$ forall (m :: * -> *) a. Monad m => a -> m a
return Blocks
B.horizontalRule
indentedLine :: PandocMonad m => MarkdownParser m Text
indentedLine :: forall (m :: * -> *). PandocMonad m => MarkdownParser m Text
indentedLine = forall (m :: * -> *). PandocMonad m => MarkdownParser m Text
indentSpaces forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> forall (m :: * -> *) st. Monad m => ParsecT Sources st m Text
anyLineNewline
blockDelimiter :: PandocMonad m
=> (Char -> Bool)
-> Maybe Int
-> ParsecT Sources ParserState m Int
blockDelimiter :: forall (m :: * -> *).
PandocMonad m =>
(Char -> Bool) -> Maybe Int -> ParsecT Sources ParserState m Int
blockDelimiter Char -> Bool
f Maybe Int
len = 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 => MarkdownParser m Int
skipNonindentSpaces
Char
c <- 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 -> Bool) -> ParsecT s u m Char
satisfy Char -> Bool
f)
case Maybe Int
len of
Just Int
l -> forall s (m :: * -> *) t u a.
Stream s m t =>
Int -> ParsecT s u m a -> ParsecT s u m [a]
count Int
l (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 s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m [a]
many (forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
Char -> ParsecT s u m Char
char Char
c) forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> forall (m :: * -> *) a. Monad m => a -> m a
return Int
l
Maybe Int
Nothing -> forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap ((forall a. Num a => a -> a -> a
+ Int
3) forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (t :: * -> *) a. Foldable t => t a -> Int
length) (forall s (m :: * -> *) t u a.
Stream s m t =>
Int -> ParsecT s u m a -> ParsecT s u m [a]
count Int
3 (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 s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m [a]
many (forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
Char -> ParsecT s u m Char
char Char
c))
attributes :: PandocMonad m => MarkdownParser m Attr
attributes :: forall (m :: * -> *). PandocMonad m => MarkdownParser m Attr
attributes = 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 :: * -> *) st. PandocMonad m => ParsecT Sources st m ()
spnl
[Attr -> Attr]
attrs <- forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m [a]
many (forall (m :: * -> *).
PandocMonad m =>
MarkdownParser m (Attr -> Attr)
attribute forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
<* forall (m :: * -> *) st. PandocMonad m => ParsecT Sources st m ()
spnl)
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
$ forall (t :: * -> *) b a.
Foldable t =>
(b -> a -> b) -> b -> t a -> b
foldl' (\Attr
x Attr -> Attr
f -> Attr -> Attr
f Attr
x) Attr
nullAttr [Attr -> Attr]
attrs
attribute :: PandocMonad m => MarkdownParser m (Attr -> Attr)
attribute :: forall (m :: * -> *).
PandocMonad m =>
MarkdownParser m (Attr -> Attr)
attribute = forall (m :: * -> *).
PandocMonad m =>
MarkdownParser m (Attr -> Attr)
identifierAttr forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> forall (m :: * -> *).
PandocMonad m =>
MarkdownParser m (Attr -> Attr)
classAttr forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> forall (m :: * -> *).
PandocMonad m =>
MarkdownParser m (Attr -> Attr)
keyValAttr forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> forall (m :: * -> *).
PandocMonad m =>
MarkdownParser m (Attr -> Attr)
specialAttr
identifier :: PandocMonad m => MarkdownParser m Text
identifier :: forall (m :: * -> *). PandocMonad m => MarkdownParser m Text
identifier = do
Char
first <- forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
ParsecT s u m Char
letter
FilePath
rest <- forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m [a]
many 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
alphaNum 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) =>
FilePath -> ParsecT s u m Char
oneOf FilePath
"-_:."
forall (m :: * -> *) a. Monad m => a -> m a
return forall a b. (a -> b) -> a -> b
$ FilePath -> Text
T.pack (Char
firstforall a. a -> [a] -> [a]
:FilePath
rest)
identifierAttr :: PandocMonad m => MarkdownParser m (Attr -> Attr)
identifierAttr :: forall (m :: * -> *).
PandocMonad m =>
MarkdownParser m (Attr -> Attr)
identifierAttr = 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
result <- FilePath -> 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) =>
ParsecT s u m Char
alphaNum 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) =>
FilePath -> ParsecT s u m Char
oneOf FilePath
"-_:.")
forall (m :: * -> *) a. Monad m => a -> m a
return forall a b. (a -> b) -> a -> b
$ \(Text
_,[Text]
cs,[Target]
kvs) -> (Text
result,[Text]
cs,[Target]
kvs)
classAttr :: PandocMonad m => MarkdownParser m (Attr -> Attr)
classAttr :: forall (m :: * -> *).
PandocMonad m =>
MarkdownParser m (Attr -> Attr)
classAttr = 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
result <- forall (m :: * -> *). PandocMonad m => MarkdownParser m Text
identifier
forall (m :: * -> *) a. Monad m => a -> m a
return forall a b. (a -> b) -> a -> b
$ \(Text
id',[Text]
cs,[Target]
kvs) -> (Text
id',[Text]
cs forall a. [a] -> [a] -> [a]
++ [Text
result],[Target]
kvs)
keyValAttr :: PandocMonad m => MarkdownParser m (Attr -> Attr)
keyValAttr :: forall (m :: * -> *).
PandocMonad m =>
MarkdownParser m (Attr -> Attr)
keyValAttr = forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try forall a b. (a -> b) -> a -> b
$ do
Text
key <- forall (m :: * -> *). PandocMonad m => MarkdownParser m Text
identifier
forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
Char -> ParsecT s u m Char
char Char
'='
Text
val <- forall a. Monoid a => [a] -> a
mconcat 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 => MarkdownParser m Text
litChar
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> forall a. Monoid a => [a] -> a
mconcat 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 => MarkdownParser m Text
litChar
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> (Text
"" 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) =>
FilePath -> ParsecT s u m FilePath
string FilePath
"\"\""))
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> (Text
"" 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) =>
FilePath -> ParsecT s u m FilePath
string FilePath
"''"))
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> forall s (m :: * -> *) t st.
Stream s m t =>
ParsecT s st m Char -> ParsecT s st m Text
manyChar (forall (m :: * -> *). PandocMonad m => MarkdownParser m Char
escapedChar' 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) =>
FilePath -> ParsecT s u m Char
noneOf FilePath
" \t\n\r}")
forall (m :: * -> *) a. Monad m => a -> m a
return forall a b. (a -> b) -> a -> b
$ \(Text
id',[Text]
cs,[Target]
kvs) ->
case Text
key of
Text
"id" -> (Text
val,[Text]
cs,[Target]
kvs)
Text
"class" -> (Text
id',[Text]
cs forall a. [a] -> [a] -> [a]
++ Text -> [Text]
T.words Text
val,[Target]
kvs)
Text
_ -> (Text
id',[Text]
cs,[Target]
kvs forall a. [a] -> [a] -> [a]
++ [(Text
key,Text
val)])
specialAttr :: PandocMonad m => MarkdownParser m (Attr -> Attr)
specialAttr :: forall (m :: * -> *).
PandocMonad m =>
MarkdownParser m (Attr -> Attr)
specialAttr = 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. Monad m => a -> m a
return forall a b. (a -> b) -> a -> b
$ \(Text
id',[Text]
cs,[Target]
kvs) -> (Text
id',[Text]
cs forall a. [a] -> [a] -> [a]
++ [Text
"unnumbered"],[Target]
kvs)
rawAttribute :: PandocMonad m => MarkdownParser m Text
rawAttribute :: forall (m :: * -> *). PandocMonad m => MarkdownParser m Text
rawAttribute = do
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 ()
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
char Char
'='
Text
format <- forall s (m :: * -> *) t st.
Stream s m t =>
ParsecT s st m Char -> ParsecT s st m Text
many1Char forall a b. (a -> b) -> a -> b
$ forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
(Char -> Bool) -> ParsecT s u m Char
satisfy (\Char
c -> Char -> Bool
isAlphaNum Char
c Bool -> Bool -> Bool
|| Char
c forall (t :: * -> *) a. (Foldable t, Eq a) => a -> t a -> Bool
`elem` [Char
'-', Char
'_'])
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
char Char
'}'
forall (m :: * -> *) a. Monad m => a -> m a
return Text
format
codeBlockFenced :: PandocMonad m => MarkdownParser m (F Blocks)
codeBlockFenced :: forall (m :: * -> *). PandocMonad m => MarkdownParser m (F Blocks)
codeBlockFenced = forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try forall a b. (a -> b) -> a -> b
$ do
Text
indentchars <- forall (m :: * -> *). PandocMonad m => MarkdownParser m Text
nonindentSpaces
let indentLevel :: Int
indentLevel = Text -> Int
T.length Text
indentchars
Char
c <- (forall s (m :: * -> *) a st.
(Stream s m a, HasReaderOptions st) =>
Extension -> ParsecT s st m ()
guardEnabled Extension
Ext_fenced_code_blocks forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> forall s (m :: * -> *) t u a.
Stream s m t =>
ParsecT s u m a -> ParsecT s u m a
lookAhead (forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
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 s (m :: * -> *) a st.
(Stream s m a, HasReaderOptions st) =>
Extension -> ParsecT s st m ()
guardEnabled Extension
Ext_backtick_code_blocks forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> forall s (m :: * -> *) t u a.
Stream s m t =>
ParsecT s u m a -> ParsecT s u m a
lookAhead (forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
Char -> ParsecT s u m Char
char Char
'`'))
Int
size <- forall (m :: * -> *).
PandocMonad m =>
(Char -> Bool) -> Maybe Int -> ParsecT Sources ParserState m Int
blockDelimiter (forall a. Eq a => a -> a -> Bool
== Char
c) forall a. Maybe a
Nothing
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
Either Text Attr
rawattr <-
(forall a b. a -> Either a b
Left forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (forall s (m :: * -> *) a st.
(Stream s m a, HasReaderOptions st) =>
Extension -> ParsecT s st m ()
guardEnabled Extension
Ext_raw_attribute 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 => MarkdownParser m Text
rawAttribute))
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|>
(forall a b. b -> Either a b
Right forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> do
let pLangId :: ParsecT Sources st m Text
pLangId = forall s (m :: * -> *) t st.
Stream s m t =>
ParsecT s st m Char -> ParsecT s st m Text
many1Char forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
(Char -> Bool) -> ParsecT s u m Char
satisfy forall a b. (a -> b) -> a -> b
$ \Char
x ->
Char
x forall (t :: * -> *) a. (Foldable t, Eq a) => a -> t a -> Bool
`notElem` [Char
'`', Char
'{', Char
'}'] Bool -> Bool -> Bool
&& Bool -> Bool
not (Char -> Bool
isSpace Char
x)
Maybe Text
mbLanguageId <- forall s (m :: * -> *) t u a.
Stream s m t =>
ParsecT s u m a -> ParsecT s u m (Maybe a)
optionMaybe (Text -> Text
toLanguageId forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall {st}. ParsecT Sources st m Text
pLangId)
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
Maybe Attr
mbAttr <- forall s (m :: * -> *) t u a.
Stream s m t =>
ParsecT s u m a -> ParsecT s u m (Maybe a)
optionMaybe
(forall s (m :: * -> *) a st.
(Stream s m a, HasReaderOptions st) =>
Extension -> ParsecT s st m ()
guardEnabled Extension
Ext_fenced_code_attributes forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try forall (m :: * -> *). PandocMonad m => MarkdownParser m Attr
attributes)
forall (m :: * -> *) a. Monad m => a -> m a
return forall a b. (a -> b) -> a -> b
$ case Maybe Attr
mbAttr of
Maybe Attr
Nothing -> (Text
"", forall a. Maybe a -> [a]
maybeToList Maybe Text
mbLanguageId, [])
Just (Text
elementId, [Text]
classes, [Target]
attrs) ->
(Text
elementId, (forall b a. b -> (a -> b) -> Maybe a -> b
maybe forall a. a -> a
id (:) Maybe Text
mbLanguageId) [Text]
classes, [Target]
attrs))
forall s (m :: * -> *) st.
(Stream s m Char, UpdateSourcePos s Char) =>
ParsecT s st m Char
blankline
Text
contents <- Text -> [Text] -> Text
T.intercalate Text
"\n" forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$>
forall s (m :: * -> *) t u a sep.
Stream s m t =>
ParsecT s u m a -> ParsecT s u m sep -> ParsecT s u m [a]
manyTill (forall st (m :: * -> *).
(HasReaderOptions st, Monad m) =>
Int -> ParsecT Sources st m Int
gobbleAtMostSpaces Int
indentLevel forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> forall (m :: * -> *) st. Monad m => ParsecT Sources st m Text
anyLine)
(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 =>
(Char -> Bool) -> Maybe Int -> ParsecT Sources ParserState m Int
blockDelimiter (forall a. Eq a => a -> a -> Bool
== Char
c) (forall a. a -> Maybe a
Just Int
size)
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
$ forall (m :: * -> *) a. Monad m => a -> m a
return forall a b. (a -> b) -> a -> b
$
case Either Text Attr
rawattr of
Left Text
syn -> Text -> Text -> Blocks
B.rawBlock Text
syn Text
contents
Right Attr
attr -> Attr -> Text -> Blocks
B.codeBlockWith Attr
attr Text
contents
toLanguageId :: Text -> Text
toLanguageId :: Text -> Text
toLanguageId = Text -> Text
T.toLower forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall {a}. (Eq a, IsString a) => a -> a
go
where go :: a -> a
go a
"c++" = a
"cpp"
go a
"objective-c" = a
"objectivec"
go a
x = a
x
codeBlockIndented :: PandocMonad m => MarkdownParser m (F Blocks)
codeBlockIndented :: forall (m :: * -> *). PandocMonad m => MarkdownParser m (F Blocks)
codeBlockIndented = do
[Text]
contents <- 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 => MarkdownParser m Text
indentedLine 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 (do Text
b <- forall s (m :: * -> *) st.
(Stream s m Char, UpdateSourcePos s Char) =>
ParsecT s st m Text
blanklines
Text
l <- forall (m :: * -> *). PandocMonad m => MarkdownParser m Text
indentedLine
forall (m :: * -> *) a. Monad m => a -> m a
return forall a b. (a -> b) -> a -> b
$ Text
b forall a. Semigroup a => a -> a -> a
<> Text
l))
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
[Text]
classes <- forall st s (m :: * -> *) t b.
(HasReaderOptions st, Stream s m t) =>
(ReaderOptions -> b) -> ParsecT s st m b
getOption ReaderOptions -> [Text]
readerIndentedCodeClasses
forall (m :: * -> *) a. Monad m => a -> m a
return forall a b. (a -> b) -> a -> b
$ forall (m :: * -> *) a. Monad m => a -> m a
return forall a b. (a -> b) -> a -> b
$ Attr -> Text -> Blocks
B.codeBlockWith (Text
"", [Text]
classes, []) forall a b. (a -> b) -> a -> b
$
Text -> Text
stripTrailingNewlines forall a b. (a -> b) -> a -> b
$ [Text] -> Text
T.concat [Text]
contents
lhsCodeBlock :: PandocMonad m => MarkdownParser m (F Blocks)
lhsCodeBlock :: forall (m :: * -> *). PandocMonad m => MarkdownParser m (F Blocks)
lhsCodeBlock = do
forall s (m :: * -> *) a st.
(Stream s m a, HasReaderOptions st) =>
Extension -> ParsecT s st m ()
guardEnabled Extension
Ext_literate_haskell
(forall (m :: * -> *) a. Monad m => a -> m a
return forall b c a. (b -> c) -> (a -> b) -> a -> c
. Attr -> Text -> Blocks
B.codeBlockWith (Text
"",[Text
"haskell",Text
"literate"],[]) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$>
(forall (m :: * -> *). PandocMonad m => MarkdownParser m Text
lhsCodeBlockBird forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> forall (m :: * -> *). PandocMonad m => MarkdownParser m Text
lhsCodeBlockLaTeX))
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 forall b c a. (b -> c) -> (a -> b) -> a -> c
. Attr -> Text -> Blocks
B.codeBlockWith (Text
"",[Text
"haskell"],[]) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$>
forall (m :: * -> *). PandocMonad m => MarkdownParser m Text
lhsCodeBlockInverseBird)
lhsCodeBlockLaTeX :: PandocMonad m => MarkdownParser m Text
lhsCodeBlockLaTeX :: forall (m :: * -> *). PandocMonad m => MarkdownParser m Text
lhsCodeBlockLaTeX = 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) =>
FilePath -> ParsecT s u m FilePath
string FilePath
"\\begin{code}"
forall s (m :: * -> *) t u a sep.
Stream s m t =>
ParsecT s u m a -> ParsecT s u m sep -> ParsecT s u m [a]
manyTill 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) =>
ParsecT s u m Char
newline
Text
contents <- forall end s (m :: * -> *) t st.
(Show end, Stream s m t) =>
ParsecT s st m Char -> ParsecT s st m end -> ParsecT s st m Text
many1TillChar forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
ParsecT s u m Char
anyChar (forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try forall a b. (a -> b) -> a -> b
$ forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
FilePath -> ParsecT s u m FilePath
string FilePath
"\\end{code}")
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
stripTrailingNewlines Text
contents
lhsCodeBlockBird :: PandocMonad m => MarkdownParser m Text
lhsCodeBlockBird :: forall (m :: * -> *). PandocMonad m => MarkdownParser m Text
lhsCodeBlockBird = forall (m :: * -> *).
PandocMonad m =>
Char -> MarkdownParser m Text
lhsCodeBlockBirdWith Char
'>'
lhsCodeBlockInverseBird :: PandocMonad m => MarkdownParser m Text
lhsCodeBlockInverseBird :: forall (m :: * -> *). PandocMonad m => MarkdownParser m Text
lhsCodeBlockInverseBird = forall (m :: * -> *).
PandocMonad m =>
Char -> MarkdownParser m Text
lhsCodeBlockBirdWith Char
'<'
lhsCodeBlockBirdWith :: PandocMonad m => Char -> MarkdownParser m Text
lhsCodeBlockBirdWith :: forall (m :: * -> *).
PandocMonad m =>
Char -> MarkdownParser m Text
lhsCodeBlockBirdWith Char
c = 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 (f :: * -> *). Applicative f => Bool -> f () -> f ()
when (SourcePos -> Int
sourceColumn SourcePos
pos forall a. Eq a => a -> a -> Bool
/= Int
1) forall a b. (a -> b) -> a -> b
$ forall (m :: * -> *) a. MonadFail m => FilePath -> m a
Prelude.fail FilePath
"Not in first column"
[Text]
lns <- 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 (m :: * -> *) st.
PandocMonad m =>
Char -> ParsecT Sources st m Text
birdTrackLine Char
c
let lns' :: [Text]
lns' = if forall (t :: * -> *) a. Foldable t => (a -> Bool) -> t a -> Bool
all (\Text
ln -> Text -> Bool
T.null Text
ln Bool -> Bool -> Bool
|| Int -> Text -> Text
T.take Int
1 Text
ln forall a. Eq a => a -> a -> Bool
== Text
" ") [Text]
lns
then forall a b. (a -> b) -> [a] -> [b]
map (Int -> Text -> Text
T.drop Int
1) [Text]
lns
else [Text]
lns
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] -> Text
T.intercalate Text
"\n" [Text]
lns'
birdTrackLine :: PandocMonad m => Char -> ParsecT Sources st m Text
birdTrackLine :: forall (m :: * -> *) st.
PandocMonad m =>
Char -> ParsecT Sources st m Text
birdTrackLine Char
c = 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
c
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
when (Char
c forall a. Eq a => a -> a -> Bool
== Char
'<') forall a b. (a -> b) -> a -> b
$ forall s (m :: * -> *) t a u.
(Stream s m t, Show a) =>
ParsecT s u m a -> ParsecT s u m ()
notFollowedBy forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
ParsecT s u m Char
letter
forall (m :: * -> *) st. Monad m => ParsecT Sources st m Text
anyLine
emailBlockQuoteStart :: PandocMonad m => MarkdownParser m Char
emailBlockQuoteStart :: forall (m :: * -> *). PandocMonad m => MarkdownParser m Char
emailBlockQuoteStart = 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 => MarkdownParser m Int
skipNonindentSpaces forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
Char -> ParsecT s u m Char
char Char
'>' forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
<* forall s (m :: * -> *) t u a.
Stream s m t =>
ParsecT s u m a -> ParsecT s u m ()
optional (forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
Char -> ParsecT s u m Char
char Char
' ')
emailBlockQuote :: PandocMonad m => MarkdownParser m [Text]
emailBlockQuote :: forall (m :: * -> *). PandocMonad m => MarkdownParser m [Text]
emailBlockQuote = 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 => MarkdownParser m Char
emailBlockQuoteStart
let emailLine :: ParsecT Sources ParserState m Text
emailLine = forall s (m :: * -> *) t st.
Stream s m t =>
ParsecT s st m Char -> ParsecT s st m Text
manyChar forall a b. (a -> b) -> a -> b
$ forall (m :: * -> *) st. PandocMonad m => ParsecT Sources st m Char
nonEndline 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 => MarkdownParser m (F Inlines)
endline forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> forall s (m :: * -> *) t a u.
(Stream s m t, Show a) =>
ParsecT s u m a -> ParsecT s u m ()
notFollowedBy forall (m :: * -> *). PandocMonad m => MarkdownParser m Char
emailBlockQuoteStart forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>>
forall (m :: * -> *) a. Monad m => a -> m a
return Char
'\n')
let emailSep :: ParsecT Sources ParserState m Char
emailSep = 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 => MarkdownParser m Char
emailBlockQuoteStart)
Text
first <- ParsecT Sources ParserState m Text
emailLine
[Text]
rest <- forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m [a]
many 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
$ ParsecT Sources ParserState m Char
emailSep forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> ParsecT Sources ParserState m Text
emailLine
let raw :: [Text]
raw = Text
firstforall a. a -> [a] -> [a]
:[Text]
rest
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 s (m :: * -> *) t u.
(Stream s m t, Show t) =>
ParsecT s u m ()
eof forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> forall (m :: * -> *) a. Monad m => a -> m a
return Char
'\n')
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 [Text]
raw
blockQuote :: PandocMonad m => MarkdownParser m (F Blocks)
blockQuote :: forall (m :: * -> *). PandocMonad m => MarkdownParser m (F Blocks)
blockQuote = do
[Text]
raw <- forall (m :: * -> *). PandocMonad m => MarkdownParser m [Text]
emailBlockQuote
F Blocks
contents <- forall (m :: * -> *) u a.
(Monad m, HasLastStrPosition u) =>
ParsecT Sources u m a -> Text -> ParsecT Sources u m a
parseFromString' forall (m :: * -> *). PandocMonad m => MarkdownParser m (F Blocks)
parseBlocks forall a b. (a -> b) -> a -> b
$ Text -> [Text] -> Text
T.intercalate Text
"\n" [Text]
raw forall a. Semigroup a => a -> a -> a
<> Text
"\n\n"
forall (m :: * -> *) a. Monad m => a -> m a
return forall a b. (a -> b) -> a -> b
$ Blocks -> Blocks
B.blockQuote forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> F Blocks
contents
bulletListStart :: PandocMonad m => MarkdownParser m ()
bulletListStart :: forall (m :: * -> *). PandocMonad m => MarkdownParser m ()
bulletListStart = 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 :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
ParsecT s u m Char
newline
forall (m :: * -> *). PandocMonad m => MarkdownParser m Int
skipNonindentSpaces
forall b s (m :: * -> *) a st.
(Show b, Stream s m a) =>
ParsecT s st m b -> ParsecT s st m ()
notFollowedBy' (() forall (f :: * -> *) a b. Functor f => a -> f b -> f a
<$ forall (m :: * -> *) st.
PandocMonad m =>
ParsecT Sources st m (F Blocks)
hrule)
forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
(Char -> Bool) -> ParsecT s u m Char
satisfy Char -> Bool
isBulletListMarker
forall st (m :: * -> *).
(HasReaderOptions st, Monad m) =>
Int -> ParsecT Sources st m ()
gobbleSpaces Int
1 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 s (m :: * -> *) t u a.
Stream s m t =>
ParsecT s u m a -> ParsecT s u m a
lookAhead forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
ParsecT s u m Char
newline
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try (forall st (m :: * -> *).
(HasReaderOptions st, Monad m) =>
Int -> ParsecT Sources st m Int
gobbleAtMostSpaces Int
3 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 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 :: * -> *) a. Monad m => a -> m a
return ()
orderedListStart :: PandocMonad m
=> Maybe (ListNumberStyle, ListNumberDelim)
-> MarkdownParser m (Int, ListNumberStyle, ListNumberDelim)
orderedListStart :: forall (m :: * -> *).
PandocMonad m =>
Maybe (ListNumberStyle, ListNumberDelim)
-> MarkdownParser m (Int, ListNumberStyle, ListNumberDelim)
orderedListStart Maybe (ListNumberStyle, ListNumberDelim)
mbstydelim = 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 :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
ParsecT s u m Char
newline
forall (m :: * -> *). PandocMonad m => MarkdownParser m Int
skipNonindentSpaces
forall s (m :: * -> *) t a u.
(Stream s m t, Show a) =>
ParsecT s u m a -> ParsecT s u m ()
notFollowedBy forall a b. (a -> b) -> a -> b
$ forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
FilePath -> ParsecT s u m FilePath
string FilePath
"p." forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> forall s (m :: * -> *) st.
(Stream s m Char, UpdateSourcePos s Char) =>
ParsecT s st m Char
spaceChar forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
ParsecT s u m Char
digit
(do forall s (m :: * -> *) a st.
(Stream s m a, HasReaderOptions st) =>
Extension -> ParsecT s st m ()
guardDisabled Extension
Ext_fancy_lists
Int
start <- forall s (m :: * -> *) t st.
Stream s m t =>
ParsecT s st m Char -> ParsecT s st m Text
many1Char forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
ParsecT s u m Char
digit forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= forall (m :: * -> *) a. (MonadPlus m, Read a) => Text -> m a
safeRead
forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
Char -> ParsecT s u m Char
char Char
'.'
forall st (m :: * -> *).
(HasReaderOptions st, Monad m) =>
Int -> ParsecT Sources st m ()
gobbleSpaces Int
1 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 s (m :: * -> *) t u a.
Stream s m t =>
ParsecT s u m a -> ParsecT s u m a
lookAhead forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
ParsecT s u m Char
newline
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 st (m :: * -> *).
(HasReaderOptions st, Monad m) =>
Int -> ParsecT Sources st m Int
gobbleAtMostSpaces Int
3 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 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 (Int
start, ListNumberStyle
DefaultStyle, ListNumberDelim
DefaultDelim))
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|>
(do (Int
num, ListNumberStyle
style, ListNumberDelim
delim) <- forall b a. b -> (a -> b) -> Maybe a -> b
maybe
forall s (m :: * -> *).
(Stream s m Char, UpdateSourcePos s Char) =>
ParsecT s ParserState m (Int, ListNumberStyle, ListNumberDelim)
anyOrderedListMarker
(\(ListNumberStyle
sty,ListNumberDelim
delim) -> (\Int
start -> (Int
start,ListNumberStyle
sty,ListNumberDelim
delim)) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$>
forall s (m :: * -> *).
(Stream s m Char, UpdateSourcePos s Char) =>
ListNumberStyle -> ListNumberDelim -> ParsecT s ParserState m Int
orderedListMarker ListNumberStyle
sty ListNumberDelim
delim)
Maybe (ListNumberStyle, ListNumberDelim)
mbstydelim
forall st (m :: * -> *).
(HasReaderOptions st, Monad m) =>
Int -> ParsecT Sources st m ()
gobbleSpaces Int
1 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 s (m :: * -> *) t u a.
Stream s m t =>
ParsecT s u m a -> ParsecT s u m a
lookAhead forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
ParsecT s u m Char
newline
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
when (ListNumberDelim
delim forall a. Eq a => a -> a -> Bool
== ListNumberDelim
Period Bool -> Bool -> Bool
&& (ListNumberStyle
style forall a. Eq a => a -> a -> Bool
== ListNumberStyle
UpperAlpha Bool -> Bool -> Bool
||
(ListNumberStyle
style forall a. Eq a => a -> a -> Bool
== ListNumberStyle
UpperRoman Bool -> Bool -> Bool
&&
Int
num forall (t :: * -> *) a. (Foldable t, Eq a) => a -> t a -> Bool
`elem` [Int
1, Int
5, Int
10, Int
50, Int
100, Int
500, Int
1000]))) forall a b. (a -> b) -> a -> b
$
() 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
lookAhead (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 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 ()
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 st (m :: * -> *).
(HasReaderOptions st, Monad m) =>
Int -> ParsecT Sources st m Int
gobbleAtMostSpaces Int
3 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 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 (Int
num, ListNumberStyle
style, ListNumberDelim
delim))
listStart :: PandocMonad m => MarkdownParser m ()
listStart :: forall (m :: * -> *). PandocMonad m => MarkdownParser m ()
listStart = forall (m :: * -> *). PandocMonad m => MarkdownParser m ()
bulletListStart forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> forall (f :: * -> *) a. Functor f => f a -> f ()
Control.Monad.void (forall (m :: * -> *).
PandocMonad m =>
Maybe (ListNumberStyle, ListNumberDelim)
-> MarkdownParser m (Int, ListNumberStyle, ListNumberDelim)
orderedListStart forall a. Maybe a
Nothing)
listLine :: PandocMonad m => Int -> MarkdownParser m Text
listLine :: forall (m :: * -> *). PandocMonad m => Int -> MarkdownParser m Text
listLine Int
continuationIndent = 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 b s (m :: * -> *) a st.
(Show b, Stream s m a) =>
ParsecT s st m b -> ParsecT s st m ()
notFollowedBy' (do forall st (m :: * -> *).
(HasReaderOptions st, Monad m) =>
Int -> ParsecT Sources st m ()
gobbleSpaces Int
continuationIndent
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 :: * -> *). PandocMonad m => MarkdownParser m ()
listStart)
forall (m :: * -> *). PandocMonad m => MarkdownParser m ()
notFollowedByHtmlCloser
forall (m :: * -> *). PandocMonad m => MarkdownParser m ()
notFollowedByDivCloser
forall s (m :: * -> *) t u a.
Stream s m t =>
ParsecT s u m a -> ParsecT s u m ()
optional (() forall (f :: * -> *) a b. Functor f => a -> f b -> f a
<$ forall st (m :: * -> *).
(HasReaderOptions st, Monad m) =>
Int -> ParsecT Sources st m ()
gobbleSpaces Int
continuationIndent)
forall (m :: * -> *). PandocMonad m => MarkdownParser m Text
listLineCommon
listLineCommon :: PandocMonad m => MarkdownParser m Text
listLineCommon :: forall (m :: * -> *). PandocMonad m => MarkdownParser m Text
listLineCommon = [Text] -> Text
T.concat forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall s (m :: * -> *) t u a sep.
Stream s m t =>
ParsecT s u m a -> ParsecT s u m sep -> ParsecT s u m [a]
manyTill
( forall s (m :: * -> *) t st.
Stream s m t =>
ParsecT s st m Char -> ParsecT s st m Text
many1Char (forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
(Char -> Bool) -> ParsecT s u m Char
satisfy forall a b. (a -> b) -> a -> b
$ \Char
c -> Char
c forall (t :: * -> *) a. (Foldable t, Eq a) => a -> t a -> Bool
`notElem` [Char
'\n', Char
'<', 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 -> b) -> f a -> f b
fmap forall a b. (a, b) -> b
snd (forall (m :: * -> *) st a.
Monad m =>
ParsecT Sources st m a -> ParsecT Sources st m (a, Text)
withRaw forall (m :: * -> *). PandocMonad m => MarkdownParser m (F Inlines)
code)
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 -> b) -> f a -> f b
fmap (forall str. StringLike str => [Tag str] -> str
renderTags forall b c a. (b -> c) -> (a -> b) -> a -> c
. (forall a. a -> [a] -> [a]
:[]) forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a b. (a, b) -> a
fst) (forall st (m :: * -> *).
(HasReaderOptions st, Monad m) =>
(Tag Text -> Bool) -> ParsecT Sources st m (Tag Text, Text)
htmlTag Tag Text -> Bool
isCommentTag)
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> forall s (m :: * -> *) st.
(Stream s m Char, UpdateSourcePos s Char, Monad m) =>
Int -> ParsecT s st m Char -> ParsecT s st m Text
countChar Int
1 forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
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
rawListItem :: PandocMonad m
=> Bool
-> MarkdownParser m a
-> MarkdownParser m (Text, Int)
rawListItem :: forall (m :: * -> *) a.
PandocMonad m =>
Bool -> MarkdownParser m a -> MarkdownParser m (Text, Int)
rawListItem Bool
fourSpaceRule MarkdownParser m a
start = 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
pos1 <- forall (m :: * -> *) s u. Monad m => ParsecT s u m SourcePos
getPosition
MarkdownParser m a
start
SourcePos
pos2 <- forall (m :: * -> *) s u. Monad m => ParsecT s u m SourcePos
getPosition
let continuationIndent :: Int
continuationIndent = if Bool
fourSpaceRule
then Int
4
else SourcePos -> Int
sourceColumn SourcePos
pos2 forall a. Num a => a -> a -> a
- SourcePos -> Int
sourceColumn SourcePos
pos1
Text
first <- forall (m :: * -> *). PandocMonad m => MarkdownParser m Text
listLineCommon
[Text]
rest <- forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m [a]
many (do 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 => MarkdownParser 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 (f :: * -> *) a b. Functor f => a -> f b -> f a
<$ forall (m :: * -> *). PandocMonad m => MarkdownParser m (F Blocks)
codeBlockFenced)
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 (m :: * -> *). PandocMonad m => Int -> MarkdownParser m Text
listLine Int
continuationIndent)
Text
blanks <- forall s (m :: * -> *) t st.
Stream s m t =>
ParsecT s st m Char -> ParsecT s st m Text
manyChar forall s (m :: * -> *) st.
(Stream s m Char, UpdateSourcePos s Char) =>
ParsecT s st m Char
blankline
let result :: Text
result = [Text] -> Text
T.unlines (Text
firstforall a. a -> [a] -> [a]
:[Text]
rest) forall a. Semigroup a => a -> a -> a
<> Text
blanks
forall (m :: * -> *) a. Monad m => a -> m a
return (Text
result, Int
continuationIndent)
listContinuation :: PandocMonad m => Int -> MarkdownParser m Text
listContinuation :: forall (m :: * -> *). PandocMonad m => Int -> MarkdownParser m Text
listContinuation Int
continuationIndent = forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try forall a b. (a -> b) -> a -> b
$ do
Text
x <- 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 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 (m :: * -> *). PandocMonad m => MarkdownParser m ()
notFollowedByHtmlCloser
forall (m :: * -> *). PandocMonad m => MarkdownParser m ()
notFollowedByDivCloser
forall st (m :: * -> *).
(HasReaderOptions st, Monad m) =>
Int -> ParsecT Sources st m ()
gobbleSpaces Int
continuationIndent
forall (m :: * -> *) st. Monad m => ParsecT Sources st m Text
anyLineNewline
[Text]
xs <- forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m [a]
many 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 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 (m :: * -> *). PandocMonad m => MarkdownParser m ()
notFollowedByHtmlCloser
forall (m :: * -> *). PandocMonad m => MarkdownParser m ()
notFollowedByDivCloser
forall st (m :: * -> *).
(HasReaderOptions st, Monad m) =>
Int -> ParsecT Sources st m ()
gobbleSpaces Int
continuationIndent forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> 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 => MarkdownParser m ()
listStart
forall (m :: * -> *) st. Monad m => ParsecT Sources st m Text
anyLineNewline
Text
blanks <- forall s (m :: * -> *) t st.
Stream s m t =>
ParsecT s st m Char -> ParsecT s st m Text
manyChar forall s (m :: * -> *) st.
(Stream s m Char, UpdateSourcePos s Char) =>
ParsecT s st m Char
blankline
forall (m :: * -> *) a. Monad m => a -> m a
return forall a b. (a -> b) -> a -> b
$ [Text] -> Text
T.concat (Text
xforall a. a -> [a] -> [a]
:[Text]
xs) forall a. Semigroup a => a -> a -> a
<> Text
blanks
blanklines' :: PandocMonad m => MarkdownParser m Text
blanklines' :: forall (m :: * -> *). PandocMonad m => MarkdownParser m Text
blanklines' = 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 s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try ParsecT Sources ParserState m Text
checkDivCloser
where checkDivCloser :: ParsecT Sources ParserState m Text
checkDivCloser = do
forall s (m :: * -> *) a st.
(Stream s m a, HasReaderOptions st) =>
Extension -> ParsecT s st m ()
guardEnabled Extension
Ext_fenced_divs
Int
divLevel <- ParserState -> Int
stateFencedDivLevel forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall (m :: * -> *) s u. Monad m => ParsecT s u m u
getState
forall (f :: * -> *). Alternative f => Bool -> f ()
guard (Int
divLevel forall a. Ord a => a -> a -> Bool
>= Int
1)
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 => MarkdownParser m ()
divFenceEnd
forall (m :: * -> *) a. Monad m => a -> m a
return Text
""
notFollowedByDivCloser :: PandocMonad m => MarkdownParser m ()
notFollowedByDivCloser :: forall (m :: * -> *). PandocMonad m => MarkdownParser m ()
notFollowedByDivCloser =
forall s (m :: * -> *) a st.
(Stream s m a, HasReaderOptions st) =>
Extension -> ParsecT s st m ()
guardDisabled Extension
Ext_fenced_divs forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|>
do Int
divLevel <- ParserState -> Int
stateFencedDivLevel forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall (m :: * -> *) s u. Monad m => ParsecT s u m u
getState
forall (f :: * -> *). Alternative f => Bool -> f ()
guard (Int
divLevel forall a. Ord a => a -> a -> Bool
< Int
1) forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> forall s (m :: * -> *) t a u.
(Stream s m t, Show a) =>
ParsecT s u m a -> ParsecT s u m ()
notFollowedBy forall (m :: * -> *). PandocMonad m => MarkdownParser m ()
divFenceEnd
notFollowedByHtmlCloser :: PandocMonad m => MarkdownParser m ()
notFollowedByHtmlCloser :: forall (m :: * -> *). PandocMonad m => MarkdownParser m ()
notFollowedByHtmlCloser = do
Maybe Text
inHtmlBlock <- ParserState -> Maybe Text
stateInHtmlBlock 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 Maybe Text
inHtmlBlock of
Just Text
t -> forall b s (m :: * -> *) a st.
(Show b, Stream s m a) =>
ParsecT s st m b -> ParsecT s st m ()
notFollowedBy' 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 str t. (StringLike str, TagRep t) => Tag str -> t -> Bool
~== forall str. str -> Tag str
TagClose Text
t)
Maybe Text
Nothing -> forall (m :: * -> *) a. Monad m => a -> m a
return ()
listItem :: PandocMonad m
=> Bool
-> MarkdownParser m a
-> MarkdownParser m (F Blocks)
listItem :: forall (m :: * -> *) a.
PandocMonad m =>
Bool -> MarkdownParser m a -> MarkdownParser m (F Blocks)
listItem Bool
fourSpaceRule MarkdownParser m a
start = forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try forall a b. (a -> b) -> a -> b
$ do
ParserState
state <- forall (m :: * -> *) s u. Monad m => ParsecT s u m u
getState
let oldContext :: ParserContext
oldContext = ParserState -> ParserContext
stateParserContext ParserState
state
forall (m :: * -> *) u s. Monad m => u -> ParsecT s u m ()
setState forall a b. (a -> b) -> a -> b
$ ParserState
state {stateParserContext :: ParserContext
stateParserContext = ParserContext
ListItemState}
(Text
first, Int
continuationIndent) <- forall (m :: * -> *) a.
PandocMonad m =>
Bool -> MarkdownParser m a -> MarkdownParser m (Text, Int)
rawListItem Bool
fourSpaceRule MarkdownParser m a
start
[Text]
continuations <- forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m [a]
many (forall (m :: * -> *). PandocMonad m => Int -> MarkdownParser m Text
listContinuation Int
continuationIndent)
let raw :: Text
raw = [Text] -> Text
T.concat (Text
firstforall a. a -> [a] -> [a]
:[Text]
continuations)
F Blocks
contents <- forall (m :: * -> *) u a.
(Monad m, HasLastStrPosition u) =>
ParsecT Sources u m a -> Text -> ParsecT Sources u m a
parseFromString' forall (m :: * -> *). PandocMonad m => MarkdownParser m (F Blocks)
parseBlocks Text
raw
forall (m :: * -> *) u s. Monad m => (u -> u) -> ParsecT s u m ()
updateState (\ParserState
st -> ParserState
st {stateParserContext :: ParserContext
stateParserContext = ParserContext
oldContext})
Extensions
exts <- forall st s (m :: * -> *) t b.
(HasReaderOptions st, Stream s m t) =>
(ReaderOptions -> b) -> ParsecT s st m b
getOption ReaderOptions -> Extensions
readerExtensions
forall (m :: * -> *) a. Monad m => a -> m a
return forall a b. (a -> b) -> a -> b
$ forall a. [a] -> Many a
B.fromList forall b c a. (b -> c) -> (a -> b) -> a -> c
. Extensions -> [Block] -> [Block]
taskListItemFromAscii Extensions
exts 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
<$> F Blocks
contents
orderedList :: PandocMonad m => MarkdownParser m (F Blocks)
orderedList :: forall (m :: * -> *). PandocMonad m => MarkdownParser m (F Blocks)
orderedList = 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
start, ListNumberStyle
style, ListNumberDelim
delim) <- 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 =>
Maybe (ListNumberStyle, ListNumberDelim)
-> MarkdownParser m (Int, ListNumberStyle, ListNumberDelim)
orderedListStart forall a. Maybe a
Nothing)
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
unless (ListNumberStyle
style forall (t :: * -> *) a. (Foldable t, Eq a) => a -> t a -> Bool
`elem` [ListNumberStyle
DefaultStyle, ListNumberStyle
Decimal, ListNumberStyle
Example] Bool -> Bool -> Bool
&&
ListNumberDelim
delim forall (t :: * -> *) a. (Foldable t, Eq a) => a -> t a -> Bool
`elem` [ListNumberDelim
DefaultDelim, ListNumberDelim
Period]) forall a b. (a -> b) -> a -> b
$
forall s (m :: * -> *) a st.
(Stream s m a, HasReaderOptions st) =>
Extension -> ParsecT s st m ()
guardEnabled Extension
Ext_fancy_lists
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
when (ListNumberStyle
style forall a. Eq a => a -> a -> Bool
== ListNumberStyle
Example) forall a b. (a -> b) -> a -> b
$ forall s (m :: * -> *) a st.
(Stream s m a, HasReaderOptions st) =>
Extension -> ParsecT s st m ()
guardEnabled Extension
Ext_example_lists
Bool
fourSpaceRule <- (Bool
True forall (f :: * -> *) a b. Functor f => a -> f b -> f a
<$ forall s (m :: * -> *) a st.
(Stream s m a, HasReaderOptions st) =>
Extension -> ParsecT s st m ()
guardEnabled Extension
Ext_four_space_rule)
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 (ListNumberStyle
style forall a. Eq a => a -> a -> Bool
== ListNumberStyle
Example)
Future ParserState [Blocks]
items <- forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap forall (t :: * -> *) (m :: * -> *) a.
(Traversable t, Monad m) =>
t (m a) -> m (t a)
sequence forall a b. (a -> b) -> a -> b
$ forall s (m :: * -> *) t u a.
Stream s m t =>
ParsecT s u m a -> ParsecT s u m [a]
many1 forall a b. (a -> b) -> a -> b
$ forall (m :: * -> *) a.
PandocMonad m =>
Bool -> MarkdownParser m a -> MarkdownParser m (F Blocks)
listItem Bool
fourSpaceRule
(forall (m :: * -> *).
PandocMonad m =>
Maybe (ListNumberStyle, ListNumberDelim)
-> MarkdownParser m (Int, ListNumberStyle, ListNumberDelim)
orderedListStart (forall a. a -> Maybe a
Just (ListNumberStyle
style, ListNumberDelim
delim)))
Int
start' <- if ListNumberStyle
style forall a. Eq a => a -> a -> Bool
== ListNumberStyle
Example
then forall (m :: * -> *) a. Monad m => a -> m a
return Int
start
else (Int
start forall (f :: * -> *) a b. Functor f => a -> f b -> f a
<$ forall s (m :: * -> *) a st.
(Stream s m a, HasReaderOptions st) =>
Extension -> ParsecT s st m ()
guardEnabled Extension
Ext_startnum) 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 Int
1
forall (m :: * -> *) a. Monad m => a -> m a
return forall a b. (a -> b) -> a -> b
$ (Int, ListNumberStyle, ListNumberDelim) -> [Blocks] -> Blocks
B.orderedListWith (Int
start', ListNumberStyle
style, ListNumberDelim
delim) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap [Blocks] -> [Blocks]
compactify Future ParserState [Blocks]
items
bulletList :: PandocMonad m => MarkdownParser m (F Blocks)
bulletList :: forall (m :: * -> *). PandocMonad m => MarkdownParser m (F Blocks)
bulletList = do
Bool
fourSpaceRule <- (Bool
True forall (f :: * -> *) a b. Functor f => a -> f b -> f a
<$ forall s (m :: * -> *) a st.
(Stream s m a, HasReaderOptions st) =>
Extension -> ParsecT s st m ()
guardEnabled Extension
Ext_four_space_rule)
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
Future ParserState [Blocks]
items <- forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap forall (t :: * -> *) (m :: * -> *) a.
(Traversable t, Monad m) =>
t (m a) -> m (t a)
sequence forall a b. (a -> b) -> a -> b
$ forall s (m :: * -> *) t u a.
Stream s m t =>
ParsecT s u m a -> ParsecT s u m [a]
many1 forall a b. (a -> b) -> a -> b
$ forall (m :: * -> *) a.
PandocMonad m =>
Bool -> MarkdownParser m a -> MarkdownParser m (F Blocks)
listItem Bool
fourSpaceRule forall (m :: * -> *). PandocMonad m => MarkdownParser m ()
bulletListStart
forall (m :: * -> *) a. Monad m => a -> m a
return forall a b. (a -> b) -> a -> b
$ [Blocks] -> Blocks
B.bulletList forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap [Blocks] -> [Blocks]
compactify Future ParserState [Blocks]
items
defListMarker :: PandocMonad m => MarkdownParser m ()
defListMarker :: forall (m :: * -> *). PandocMonad m => MarkdownParser m ()
defListMarker = do
Text
sps <- forall (m :: * -> *). PandocMonad m => MarkdownParser m Text
nonindentSpaces
forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
Char -> ParsecT s u m Char
char Char
':' forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
Char -> ParsecT s u m Char
char Char
'~'
Int
tabStop <- forall st s (m :: * -> *) t b.
(HasReaderOptions st, Stream s m t) =>
(ReaderOptions -> b) -> ParsecT s st m b
getOption ReaderOptions -> Int
readerTabStop
let remaining :: Int
remaining = Int
tabStop forall a. Num a => a -> a -> a
- (Text -> Int
T.length Text
sps forall a. Num a => a -> a -> a
+ Int
1)
if Int
remaining forall a. Ord a => a -> a -> Bool
> Int
0
then 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 =>
Int -> ParsecT s u m a -> ParsecT s u m [a]
count Int
remaining (forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
Char -> ParsecT s u m Char
char Char
' ')) forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
FilePath -> ParsecT s u m FilePath
string FilePath
"\t" forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> forall s (m :: * -> *) t u a.
Stream s m t =>
ParsecT s u m a -> ParsecT s u m [a]
many1 forall s (m :: * -> *) st.
(Stream s m Char, UpdateSourcePos s Char) =>
ParsecT s st m Char
spaceChar
else forall (m :: * -> *) a. MonadPlus m => m a
mzero
forall (m :: * -> *) a. Monad m => a -> m a
return ()
definitionListItem :: PandocMonad m => Bool -> MarkdownParser m (F (Inlines, [Blocks]))
definitionListItem :: forall (m :: * -> *).
PandocMonad m =>
Bool -> MarkdownParser m (F (Inlines, [Blocks]))
definitionListItem Bool
compact = forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try forall a b. (a -> b) -> a -> b
$ do
Text
rawLine' <- forall (m :: * -> *) st. Monad m => ParsecT Sources st m Text
anyLine
[Text]
raw <- 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 (m :: * -> *).
PandocMonad m =>
Bool -> MarkdownParser m Text
defRawBlock Bool
compact
F Inlines
term <- forall (m :: * -> *) u a.
(Monad m, HasLastStrPosition u) =>
ParsecT Sources u m a -> Text -> ParsecT Sources u m a
parseFromString' (forall s. Future s Inlines -> Future s Inlines
trimInlinesF forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall (m :: * -> *). PandocMonad m => MarkdownParser m (F Inlines)
inlines) Text
rawLine'
[F Blocks]
contents <- forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
mapM (forall (m :: * -> *) u a.
(Monad m, HasLastStrPosition u) =>
ParsecT Sources u m a -> Text -> ParsecT Sources u m a
parseFromString' forall (m :: * -> *). PandocMonad m => MarkdownParser m (F Blocks)
parseBlocks forall b c a. (b -> c) -> (a -> b) -> a -> c
. (forall a. Semigroup a => a -> a -> a
<> Text
"\n")) [Text]
raw
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
$ forall (m :: * -> *) a1 a2 r.
Monad m =>
(a1 -> a2 -> r) -> m a1 -> m a2 -> m r
liftM2 (,) F Inlines
term (forall (t :: * -> *) (m :: * -> *) a.
(Traversable t, Monad m) =>
t (m a) -> m (t a)
sequence [F Blocks]
contents)
defRawBlock :: PandocMonad m => Bool -> MarkdownParser m Text
defRawBlock :: forall (m :: * -> *).
PandocMonad m =>
Bool -> MarkdownParser m Text
defRawBlock Bool
compact = 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
hasBlank <- forall s (m :: * -> *) t a u.
Stream s m t =>
a -> ParsecT s u m a -> ParsecT s u m a
option Bool
False forall a b. (a -> b) -> a -> b
$ forall s (m :: * -> *) st.
(Stream s m Char, UpdateSourcePos s Char) =>
ParsecT s st m Char
blankline forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> forall (m :: * -> *) a. Monad m => a -> m a
return Bool
True
forall (m :: * -> *). PandocMonad m => MarkdownParser m ()
defListMarker
Text
firstline <- forall (m :: * -> *) st. Monad m => ParsecT Sources st m Text
anyLineNewline
let dline :: ParsecT Sources ParserState m Text
dline = forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try
( do 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 (m :: * -> *). PandocMonad m => MarkdownParser m ()
notFollowedByHtmlCloser
forall (m :: * -> *). PandocMonad m => MarkdownParser m ()
notFollowedByDivCloser
if Bool
compact
then () forall (f :: * -> *) a b. Functor f => a -> f b -> f a
<$ forall (m :: * -> *). PandocMonad m => MarkdownParser m Text
indentSpaces
else (() forall (f :: * -> *) a b. Functor f => a -> f b -> f a
<$ forall (m :: * -> *). PandocMonad m => MarkdownParser m Text
indentSpaces)
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> forall s (m :: * -> *) t a u.
(Stream s m t, Show a) =>
ParsecT s u m a -> ParsecT s u m ()
notFollowedBy forall (m :: * -> *). PandocMonad m => MarkdownParser m ()
defListMarker
forall (m :: * -> *) st. Monad m => ParsecT Sources st m Text
anyLine )
[Text]
rawlines <- forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m [a]
many ParsecT Sources ParserState m Text
dline
Text
cont <- forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap [Text] -> Text
T.concat forall a b. (a -> b) -> a -> b
$ forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m [a]
many 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
Text
trailing <- forall s (m :: * -> *) t a u.
Stream s m t =>
a -> ParsecT s u m a -> ParsecT s u m a
option Text
"" forall s (m :: * -> *) st.
(Stream s m Char, UpdateSourcePos s Char) =>
ParsecT s st m Text
blanklines
Text
ln <- forall (m :: * -> *). PandocMonad m => MarkdownParser m Text
indentSpaces 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 s (m :: * -> *) st.
(Stream s m Char, UpdateSourcePos s Char) =>
ParsecT s st m Char
blankline forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> forall (m :: * -> *) st. Monad m => ParsecT Sources st m Text
anyLine
[Text]
lns <- forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m [a]
many ParsecT Sources ParserState m Text
dline
forall (m :: * -> *) a. Monad m => a -> m a
return forall a b. (a -> b) -> a -> b
$ Text
trailing forall a. Semigroup a => a -> a -> a
<> [Text] -> Text
T.unlines (Text
lnforall a. a -> [a] -> [a]
:[Text]
lns)
forall (m :: * -> *) a. Monad m => a -> m a
return forall a b. (a -> b) -> a -> b
$ Text -> Text
trimr (Text
firstline forall a. Semigroup a => a -> a -> a
<> [Text] -> Text
T.unlines [Text]
rawlines forall a. Semigroup a => a -> a -> a
<> Text
cont) forall a. Semigroup a => a -> a -> a
<>
if Bool
hasBlank Bool -> Bool -> Bool
|| Bool -> Bool
not (Text -> Bool
T.null Text
cont) then Text
"\n\n" else Text
""
definitionList :: PandocMonad m => MarkdownParser m (F Blocks)
definitionList :: forall (m :: * -> *). PandocMonad m => MarkdownParser m (F Blocks)
definitionList = forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try forall a b. (a -> b) -> a -> b
$ do
forall s (m :: * -> *) t u a.
Stream s m t =>
ParsecT s u m a -> ParsecT s u m a
lookAhead (forall (m :: * -> *) st. Monad m => ParsecT Sources st m Text
anyLine 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 ()
optional (forall s (m :: * -> *) st.
(Stream s m Char, UpdateSourcePos s Char) =>
ParsecT s st m Char
blankline 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 (f :: * -> *) a. Functor f => f a -> f ()
Control.Monad.void forall (m :: * -> *). PandocMonad m => MarkdownParser m (F Blocks)
table)) forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>>
forall (m :: * -> *). PandocMonad m => MarkdownParser m ()
defListMarker)
forall (m :: * -> *). PandocMonad m => MarkdownParser m (F Blocks)
compactDefinitionList forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> forall (m :: * -> *). PandocMonad m => MarkdownParser m (F Blocks)
normalDefinitionList
compactDefinitionList :: PandocMonad m => MarkdownParser m (F Blocks)
compactDefinitionList :: forall (m :: * -> *). PandocMonad m => MarkdownParser m (F Blocks)
compactDefinitionList = do
forall s (m :: * -> *) a st.
(Stream s m a, HasReaderOptions st) =>
Extension -> ParsecT s st m ()
guardEnabled Extension
Ext_compact_definition_lists
Future ParserState [(Inlines, [Blocks])]
items <- forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap forall (t :: * -> *) (m :: * -> *) a.
(Traversable t, Monad m) =>
t (m a) -> m (t a)
sequence forall a b. (a -> b) -> a -> b
$ forall s (m :: * -> *) t u a.
Stream s m t =>
ParsecT s u m a -> ParsecT s u m [a]
many1 forall a b. (a -> b) -> a -> b
$ forall (m :: * -> *).
PandocMonad m =>
Bool -> MarkdownParser m (F (Inlines, [Blocks]))
definitionListItem Bool
True
forall (m :: * -> *) a. Monad m => a -> m a
return forall a b. (a -> b) -> a -> b
$ [(Inlines, [Blocks])] -> Blocks
B.definitionList forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap [(Inlines, [Blocks])] -> [(Inlines, [Blocks])]
compactifyDL Future ParserState [(Inlines, [Blocks])]
items
normalDefinitionList :: PandocMonad m => MarkdownParser m (F Blocks)
normalDefinitionList :: forall (m :: * -> *). PandocMonad m => MarkdownParser m (F Blocks)
normalDefinitionList = do
forall s (m :: * -> *) a st.
(Stream s m a, HasReaderOptions st) =>
Extension -> ParsecT s st m ()
guardEnabled Extension
Ext_definition_lists
Future ParserState [(Inlines, [Blocks])]
items <- forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap forall (t :: * -> *) (m :: * -> *) a.
(Traversable t, Monad m) =>
t (m a) -> m (t a)
sequence forall a b. (a -> b) -> a -> b
$ forall s (m :: * -> *) t u a.
Stream s m t =>
ParsecT s u m a -> ParsecT s u m [a]
many1 forall a b. (a -> b) -> a -> b
$ forall (m :: * -> *).
PandocMonad m =>
Bool -> MarkdownParser m (F (Inlines, [Blocks]))
definitionListItem Bool
False
forall (m :: * -> *) a. Monad m => a -> m a
return forall a b. (a -> b) -> a -> b
$ [(Inlines, [Blocks])] -> Blocks
B.definitionList forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Future ParserState [(Inlines, [Blocks])]
items
para :: PandocMonad m => MarkdownParser m (F Blocks)
para :: forall (m :: * -> *). PandocMonad m => MarkdownParser m (F Blocks)
para = forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try forall a b. (a -> b) -> a -> b
$ do
Extensions
exts <- forall st s (m :: * -> *) t b.
(HasReaderOptions st, Stream s m t) =>
(ReaderOptions -> b) -> ParsecT s st m b
getOption ReaderOptions -> Extensions
readerExtensions
F Inlines
result <- forall s. Future s Inlines -> Future s Inlines
trimInlinesF forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall (m :: * -> *). PandocMonad m => MarkdownParser m (F Inlines)
inlines1
let figureOr :: (Inlines -> Blocks) -> Inlines -> Blocks
figureOr Inlines -> Blocks
constr Inlines
inlns =
case forall a. Many a -> [a]
B.toList Inlines
inlns of
[Image Attr
attr [Inline]
figCaption (Text
src, Text
tit)]
| Extension -> Extensions -> Bool
extensionEnabled Extension
Ext_implicit_figures Extensions
exts
, Bool -> Bool
not (forall (t :: * -> *) a. Foldable t => t a -> Bool
null [Inline]
figCaption) -> do
Attr -> Inlines -> Text -> Text -> Blocks
implicitFigure Attr
attr (forall a. [a] -> Many a
B.fromList [Inline]
figCaption) Text
src Text
tit
[Inline]
_ -> Inlines -> Blocks
constr Inlines
inlns
forall s (m :: * -> *) t a u.
Stream s m t =>
a -> ParsecT s u m a -> ParsecT s u m a
option ((Inlines -> Blocks) -> Inlines -> Blocks
figureOr Inlines -> Blocks
B.plain forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> F Inlines
result)
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) =>
ParsecT s u m Char
newline
(forall a. Monoid a => a
mempty forall (f :: * -> *) a b. Functor f => a -> f b -> f a
<$ forall s (m :: * -> *) st.
(Stream s m Char, UpdateSourcePos s Char) =>
ParsecT s st m Text
blanklines)
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> (forall s (m :: * -> *) a st.
(Stream s m a, HasReaderOptions st) =>
Extension -> ParsecT s st m ()
guardDisabled Extension
Ext_blank_before_blockquote
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 :: * -> *). PandocMonad m => MarkdownParser m (F Blocks)
blockQuote)
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> (forall s (m :: * -> *) a st.
(Stream s m a, HasReaderOptions st) =>
Extension -> ParsecT s st m ()
guardEnabled Extension
Ext_backtick_code_blocks
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 :: * -> *). PandocMonad m => MarkdownParser m (F Blocks)
codeBlockFenced)
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> (forall s (m :: * -> *) a st.
(Stream s m a, HasReaderOptions st) =>
Extension -> ParsecT s st m ()
guardDisabled Extension
Ext_blank_before_header
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 :: * -> *). PandocMonad m => MarkdownParser m (F Blocks)
header)
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> (forall s (m :: * -> *) a st.
(Stream s m a, HasReaderOptions st) =>
Extension -> ParsecT s st m ()
guardEnabled Extension
Ext_lists_without_preceding_blankline
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
<* 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 => MarkdownParser m ()
inList
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 :: * -> *). PandocMonad m => MarkdownParser m ()
listStart)
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> do forall s (m :: * -> *) a st.
(Stream s m a, HasReaderOptions st) =>
Extension -> ParsecT s st m ()
guardEnabled Extension
Ext_native_divs
Maybe Text
inHtmlBlock <- ParserState -> Maybe Text
stateInHtmlBlock 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 Maybe Text
inHtmlBlock of
Just Text
"div" -> () 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
lookAhead (forall st (m :: * -> *).
(HasReaderOptions st, Monad m) =>
(Tag Text -> Bool) -> ParsecT Sources st m (Tag Text, Text)
htmlTag (forall str t. (StringLike str, TagRep t) => Tag str -> t -> Bool
~== forall str. str -> Tag str
TagClose (Text
"div" :: Text)))
Maybe Text
_ -> forall (m :: * -> *) a. MonadPlus m => m a
mzero
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> do forall s (m :: * -> *) a st.
(Stream s m a, HasReaderOptions st) =>
Extension -> ParsecT s st m ()
guardEnabled Extension
Ext_fenced_divs
Int
divLevel <- ParserState -> Int
stateFencedDivLevel forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall (m :: * -> *) s u. Monad m => ParsecT s u m u
getState
if Int
divLevel forall a. Ord a => a -> a -> Bool
> Int
0
then 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 => MarkdownParser m ()
divFenceEnd
else forall (m :: * -> *) a. MonadPlus m => m a
mzero
forall (m :: * -> *) a. Monad m => a -> m a
return forall a b. (a -> b) -> a -> b
$ (Inlines -> Blocks) -> Inlines -> Blocks
figureOr Inlines -> Blocks
B.para forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> F Inlines
result
plain :: PandocMonad m => MarkdownParser m (F Blocks)
plain :: forall (m :: * -> *). PandocMonad m => MarkdownParser m (F Blocks)
plain = forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap Inlines -> Blocks
B.plain forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall s. Future s Inlines -> Future s Inlines
trimInlinesF forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall (m :: * -> *). PandocMonad m => MarkdownParser m (F Inlines)
inlines1
implicitFigure :: Attr -> Inlines -> Text -> Text -> Blocks
implicitFigure :: Attr -> Inlines -> Text -> Text -> Blocks
implicitFigure (Text
ident, [Text]
classes, [Target]
attribs) Inlines
capt Text
url Text
title =
let alt :: Inlines
alt = case Text
"alt" forall a b. Eq a => a -> [(a, b)] -> Maybe b
`lookup` [Target]
attribs of
Just Text
alt' -> Text -> Inlines
B.text Text
alt'
Maybe Text
_ -> Inlines
capt
attribs' :: [Target]
attribs' = forall a. (a -> Bool) -> [a] -> [a]
filter ((forall a. Eq a => a -> a -> Bool
/= Text
"alt") forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a b. (a, b) -> a
fst) [Target]
attribs
figattr :: Attr
figattr = (Text
ident, forall a. Monoid a => a
mempty, forall a. Monoid a => a
mempty)
caption :: Caption
caption = Blocks -> Caption
B.simpleCaption forall a b. (a -> b) -> a -> b
$ Inlines -> Blocks
B.plain Inlines
capt
figbody :: Blocks
figbody = Inlines -> Blocks
B.plain forall a b. (a -> b) -> a -> b
$ Attr -> Text -> Text -> Inlines -> Inlines
B.imageWith (Text
"", [Text]
classes, [Target]
attribs') Text
url Text
title Inlines
alt
in Attr -> Caption -> Blocks -> Blocks
B.figureWith Attr
figattr Caption
caption Blocks
figbody
htmlElement :: PandocMonad m => MarkdownParser m Text
htmlElement :: forall (m :: * -> *). PandocMonad m => MarkdownParser m Text
htmlElement = forall (m :: * -> *). PandocMonad m => MarkdownParser m Text
rawVerbatimBlock
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> forall (m :: * -> *). PandocMonad m => MarkdownParser m Text
strictHtmlBlock
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 -> b) -> f a -> f b
fmap forall a b. (a, b) -> b
snd (forall st (m :: * -> *).
(HasReaderOptions st, Monad m) =>
(Tag Text -> Bool) -> ParsecT Sources st m (Tag Text, Text)
htmlTag Tag Text -> Bool
isBlockTag)
htmlBlock :: PandocMonad m => MarkdownParser m (F Blocks)
htmlBlock :: forall (m :: * -> *). PandocMonad m => MarkdownParser m (F Blocks)
htmlBlock = do
forall s (m :: * -> *) a st.
(Stream s m a, HasReaderOptions st) =>
Extension -> ParsecT s st m ()
guardEnabled Extension
Ext_raw_html
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try (do
(TagOpen Text
_ [Target]
attrs) <- 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 a b. (a, b) -> a
fst 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
isBlockTag
forall (m :: * -> *) a. Monad m => a -> m a
return forall b c a. (b -> c) -> (a -> b) -> a -> c
. Text -> Text -> Blocks
B.rawBlock Text
"html" forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall (m :: * -> *). PandocMonad m => MarkdownParser m Text
rawVerbatimBlock
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> (do forall s (m :: * -> *) a st.
(Stream s m a, HasReaderOptions st) =>
Extension -> ParsecT s st m ()
guardEnabled Extension
Ext_markdown_attribute
Bool
oldMarkdownAttribute <- ParserState -> Bool
stateMarkdownAttribute forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall (m :: * -> *) s u. Monad m => ParsecT s u m u
getState
Bool
markdownAttribute <-
case forall a b. Eq a => a -> [(a, b)] -> Maybe b
lookup Text
"markdown" [Target]
attrs of
Just Text
"0" -> Bool
False forall (f :: * -> *) a b. Functor f => a -> f b -> f a
<$ forall (m :: * -> *) u s. Monad m => (u -> u) -> ParsecT s u m ()
updateState (\ParserState
st -> ParserState
st{
stateMarkdownAttribute :: Bool
stateMarkdownAttribute = Bool
False })
Just Text
_ -> Bool
True forall (f :: * -> *) a b. Functor f => a -> f b -> f a
<$ forall (m :: * -> *) u s. Monad m => (u -> u) -> ParsecT s u m ()
updateState (\ParserState
st -> ParserState
st{
stateMarkdownAttribute :: Bool
stateMarkdownAttribute = Bool
True })
Maybe Text
Nothing -> forall (m :: * -> *) a. Monad m => a -> m a
return Bool
oldMarkdownAttribute
F Blocks
res <- if Bool
markdownAttribute
then forall (m :: * -> *). PandocMonad m => MarkdownParser m (F Blocks)
rawHtmlBlocks
else forall (m :: * -> *). PandocMonad m => MarkdownParser m (F Blocks)
htmlBlock'
forall (m :: * -> *) u s. Monad m => (u -> u) -> ParsecT s u m ()
updateState forall a b. (a -> b) -> a -> b
$ \ParserState
st -> ParserState
st{ stateMarkdownAttribute :: Bool
stateMarkdownAttribute =
Bool
oldMarkdownAttribute }
forall (m :: * -> *) a. Monad m => a -> m a
return F Blocks
res)
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> (forall s (m :: * -> *) a st.
(Stream s m a, HasReaderOptions st) =>
Extension -> ParsecT s st m ()
guardEnabled Extension
Ext_markdown_in_html_blocks forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> forall (m :: * -> *). PandocMonad m => MarkdownParser m (F Blocks)
rawHtmlBlocks))
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> forall (m :: * -> *). PandocMonad m => MarkdownParser m (F Blocks)
htmlBlock'
htmlBlock' :: PandocMonad m => MarkdownParser m (F Blocks)
htmlBlock' :: forall (m :: * -> *). PandocMonad m => MarkdownParser m (F Blocks)
htmlBlock' = forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try forall a b. (a -> b) -> a -> b
$ do
Text
first <- forall (m :: * -> *). PandocMonad m => MarkdownParser m Text
htmlElement
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 (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
$ if Text -> Bool
T.null Text
first
then forall a. Monoid a => a
mempty
else forall (m :: * -> *) a. Monad m => a -> m a
return forall a b. (a -> b) -> a -> b
$ Text -> Text -> Blocks
B.rawBlock Text
"html" Text
first
strictHtmlBlock :: PandocMonad m => MarkdownParser m Text
strictHtmlBlock :: forall (m :: * -> *). PandocMonad m => MarkdownParser m Text
strictHtmlBlock = forall (m :: * -> *) st.
Monad m =>
(Tag Text -> Bool) -> ParsecT Sources st m Text
htmlInBalanced (Bool -> Bool
not forall b c a. (b -> c) -> (a -> b) -> a -> c
. Tag Text -> Bool
isInlineTag)
rawVerbatimBlock :: PandocMonad m => MarkdownParser m Text
rawVerbatimBlock :: forall (m :: * -> *). PandocMonad m => MarkdownParser m Text
rawVerbatimBlock = forall (m :: * -> *) st.
Monad m =>
(Tag Text -> Bool) -> ParsecT Sources st m Text
htmlInBalanced forall {a}. (Eq a, IsString a) => Tag a -> Bool
isVerbTag
where isVerbTag :: Tag a -> Bool
isVerbTag (TagOpen a
"pre" [Attribute a]
_) = Bool
True
isVerbTag (TagOpen a
"style" [Attribute a]
_) = Bool
True
isVerbTag (TagOpen a
"script" [Attribute a]
_) = Bool
True
isVerbTag (TagOpen a
"textarea" [Attribute a]
_) = Bool
True
isVerbTag Tag a
_ = Bool
False
rawTeXBlock :: PandocMonad m => MarkdownParser m (F Blocks)
rawTeXBlock :: forall (m :: * -> *). PandocMonad m => MarkdownParser m (F Blocks)
rawTeXBlock = do
forall s (m :: * -> *) a st.
(Stream s m a, HasReaderOptions st) =>
Extension -> ParsecT s st m ()
guardEnabled Extension
Ext_raw_tex
Blocks
result <- (Text -> Text -> Blocks
B.rawBlock Text
"tex" forall b c a. (b -> c) -> (a -> b) -> a -> c
. Text -> Text
trim forall b c a. (b -> c) -> (a -> b) -> a -> c
. [Text] -> Text
T.concat 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 a. Semigroup a => a -> a -> a
(<>) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall (m :: * -> *) st. PandocMonad m => ParsecT Sources st m Text
rawConTeXtEnvironment forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall (m :: * -> *) st. PandocMonad m => ParsecT Sources st m Text
spnl'))
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> (Text -> Text -> Blocks
B.rawBlock Text
"tex" forall b c a. (b -> c) -> (a -> b) -> a -> c
. Text -> Text
trim forall b c a. (b -> c) -> (a -> b) -> a -> c
. [Text] -> Text
T.concat 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 a. Semigroup a => a -> a -> a
(<>) 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 -> b) -> f a -> f b
<*> forall (m :: * -> *) st. PandocMonad m => ParsecT Sources st m Text
spnl'))
forall (m :: * -> *) a. Monad m => a -> m a
return forall a b. (a -> b) -> a -> b
$ case forall a. Many a -> [a]
B.toList Blocks
result of
[RawBlock Format
_ Text
cs]
| (Char -> Bool) -> Text -> Bool
T.all (forall (t :: * -> *) a. (Foldable t, Eq a) => a -> t a -> Bool
`elem` [Char
' ',Char
'\t',Char
'\n']) Text
cs -> forall (m :: * -> *) a. Monad m => a -> m a
return forall a. Monoid a => a
mempty
[Block]
_ -> forall (m :: * -> *) a. Monad m => a -> m a
return Blocks
result
rawHtmlBlocks :: PandocMonad m => MarkdownParser m (F Blocks)
rawHtmlBlocks :: forall (m :: * -> *). PandocMonad m => MarkdownParser m (F Blocks)
rawHtmlBlocks = do
(TagOpen Text
tagtype [Target]
_, Text
raw) <- forall st (m :: * -> *).
(HasReaderOptions st, Monad m) =>
(Tag Text -> Bool) -> ParsecT Sources st m (Tag Text, Text)
htmlTag Tag Text -> Bool
isBlockTag
let selfClosing :: Bool
selfClosing = Text
"/>" Text -> Text -> Bool
`T.isSuffixOf` Text
raw
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
Int
tabStop <- forall st s (m :: * -> *) t b.
(HasReaderOptions st, Stream s m t) =>
(ReaderOptions -> b) -> ParsecT s st m b
getOption ReaderOptions -> Int
readerTabStop
Int
indentlevel <- forall s (m :: * -> *) t a u.
Stream s m t =>
a -> ParsecT s u m a -> ParsecT s u m a
option Int
0 forall a b. (a -> b) -> a -> b
$
do forall s (m :: * -> *) st.
(Stream s m Char, UpdateSourcePos s Char) =>
ParsecT s st m Char
blankline
forall (t :: * -> *) a. (Foldable t, Num a) => t a -> a
sum 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 ( (Int
1 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
<|>
(Int
tabStop 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
'\t') )
Maybe Text
oldInHtmlBlock <- ParserState -> Maybe Text
stateInHtmlBlock forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall (m :: * -> *) s u. Monad m => ParsecT s u m u
getState
forall (m :: * -> *) u s. Monad m => (u -> u) -> ParsecT s u m ()
updateState forall a b. (a -> b) -> a -> b
$ \ParserState
st -> ParserState
st{ stateInHtmlBlock :: Maybe Text
stateInHtmlBlock = forall a. a -> Maybe a
Just Text
tagtype }
let closer :: ParsecT Sources ParserState m (Tag Text, Text)
closer = forall st (m :: * -> *).
(HasReaderOptions st, Monad m) =>
(Tag Text -> Bool) -> ParsecT Sources st m (Tag Text, Text)
htmlTag (forall str t. (StringLike str, TagRep t) => Tag str -> t -> Bool
~== forall str. str -> Tag str
TagClose Text
tagtype)
let block' :: MarkdownParser m (F Blocks)
block' = 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 st (m :: * -> *).
(HasReaderOptions st, Monad m) =>
Int -> ParsecT Sources st m Int
gobbleAtMostSpaces Int
indentlevel
forall b s (m :: * -> *) a st.
(Show b, Stream s m a) =>
ParsecT s st m b -> ParsecT s st m ()
notFollowedBy' ParsecT Sources ParserState m (Tag Text, Text)
closer
forall (m :: * -> *). PandocMonad m => MarkdownParser m (F Blocks)
block
F Blocks
contents <- if Bool
selfClosing
then forall (m :: * -> *) a. Monad m => a -> m a
return forall a. Monoid a => a
mempty
else 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 MarkdownParser m (F Blocks)
block'
F Blocks
result <-
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try
(do forall st (m :: * -> *).
(HasReaderOptions st, Monad m) =>
Int -> ParsecT Sources st m Int
gobbleAtMostSpaces Int
indentlevel
(Tag Text
_, Text
rawcloser) <- ParsecT Sources ParserState m (Tag Text, Text)
closer
forall (m :: * -> *) a. Monad m => a -> m a
return (forall (m :: * -> *) a. Monad m => a -> m a
return (Text -> Text -> Blocks
B.rawBlock Text
"html" forall a b. (a -> b) -> a -> b
$ Text -> Text
stripMarkdownAttribute Text
raw) forall a. Semigroup a => a -> a -> a
<>
F Blocks
contents forall a. Semigroup a => a -> a -> a
<>
forall (m :: * -> *) a. Monad m => a -> m a
return (Text -> Text -> Blocks
B.rawBlock Text
"html" Text
rawcloser)))
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 (forall (m :: * -> *) a. Monad m => a -> m a
return (Text -> Text -> Blocks
B.rawBlock Text
"html" Text
raw) forall a. Semigroup a => a -> a -> a
<> F Blocks
contents)
forall (m :: * -> *) u s. Monad m => (u -> u) -> ParsecT s u m ()
updateState forall a b. (a -> b) -> a -> b
$ \ParserState
st -> ParserState
st{ stateInHtmlBlock :: Maybe Text
stateInHtmlBlock = Maybe Text
oldInHtmlBlock }
forall (m :: * -> *) a. Monad m => a -> m a
return F Blocks
result
stripMarkdownAttribute :: Text -> Text
stripMarkdownAttribute :: Text -> Text
stripMarkdownAttribute Text
s = [Tag Text] -> Text
renderTags' forall a b. (a -> b) -> a -> b
$ forall a b. (a -> b) -> [a] -> [b]
map forall {a}. (Eq a, IsString a) => Tag a -> Tag a
filterAttrib forall a b. (a -> b) -> a -> b
$ forall str. StringLike str => str -> [Tag str]
parseTags Text
s
where filterAttrib :: Tag a -> Tag a
filterAttrib (TagOpen a
t [Attribute a]
as) = forall str. str -> [Attribute str] -> Tag str
TagOpen a
t
[(a
k,a
v) | (a
k,a
v) <- [Attribute a]
as, a
k forall a. Eq a => a -> a -> Bool
/= a
"markdown"]
filterAttrib Tag a
x = Tag a
x
lineBlock :: PandocMonad m => MarkdownParser m (F Blocks)
lineBlock :: forall (m :: * -> *). PandocMonad m => MarkdownParser m (F Blocks)
lineBlock = do
forall s (m :: * -> *) a st.
(Stream s m a, HasReaderOptions st) =>
Extension -> ParsecT s st m ()
guardEnabled Extension
Ext_line_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
[F Inlines]
lines' <- forall (m :: * -> *) st. Monad m => ParsecT Sources st m [Text]
lineBlockLines forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>=
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
mapM (forall (m :: * -> *) u a.
(Monad m, HasLastStrPosition u) =>
ParsecT Sources u m a -> Text -> ParsecT Sources u m a
parseFromString' (forall s. Future s Inlines -> Future s Inlines
trimInlinesF forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall (m :: * -> *). PandocMonad m => MarkdownParser m (F Inlines)
inlines))
forall (m :: * -> *) a. Monad m => a -> m a
return forall a b. (a -> b) -> a -> b
$ [Inlines] -> Blocks
B.lineBlock forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall (t :: * -> *) (m :: * -> *) a.
(Traversable t, Monad m) =>
t (m a) -> m (t a)
sequence [F Inlines]
lines'
dashedLine :: PandocMonad m
=> Char
-> ParsecT Sources st m (Int, Int)
dashedLine :: forall (m :: * -> *) st.
PandocMonad m =>
Char -> ParsecT Sources st m (Int, Int)
dashedLine Char
ch = do
FilePath
dashes <- 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
ch)
FilePath
sp <- forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m [a]
many forall s (m :: * -> *) st.
(Stream s m Char, UpdateSourcePos s Char) =>
ParsecT s st m Char
spaceChar
let lengthDashes :: Int
lengthDashes = forall (t :: * -> *) a. Foldable t => t a -> Int
length FilePath
dashes
lengthSp :: Int
lengthSp = forall (t :: * -> *) a. Foldable t => t a -> Int
length FilePath
sp
forall (m :: * -> *) a. Monad m => a -> m a
return (Int
lengthDashes, Int
lengthDashes forall a. Num a => a -> a -> a
+ Int
lengthSp)
simpleTableHeader :: PandocMonad m
=> Bool
-> MarkdownParser m (F [Blocks], [Alignment], [Int])
Bool
headless = forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try forall a b. (a -> b) -> a -> b
$ do
Text
rawContent <- if Bool
headless
then forall (m :: * -> *) a. Monad m => a -> m a
return Text
""
else forall (m :: * -> *) st. Monad m => ParsecT Sources st m Text
anyLine
Text
initSp <- forall (m :: * -> *). PandocMonad m => MarkdownParser m Text
nonindentSpaces
[(Int, Int)]
dashes <- forall s (m :: * -> *) t u a.
Stream s m t =>
ParsecT s u m a -> ParsecT s u m [a]
many1 (forall (m :: * -> *) st.
PandocMonad m =>
Char -> ParsecT Sources st m (Int, Int)
dashedLine Char
'-')
forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
ParsecT s u m Char
newline
let ([Int]
lengths, [Int]
lines') = forall a b. [(a, b)] -> ([a], [b])
unzip [(Int, Int)]
dashes
let indices :: [Int]
indices = forall b a. (b -> a -> b) -> b -> [a] -> [b]
scanl forall a. Num a => a -> a -> a
(+) (Text -> Int
T.length Text
initSp) [Int]
lines'
[Text]
rawHeads <- forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (forall a. [a] -> [a]
tail forall b c a. (b -> c) -> (a -> b) -> a -> c
. [Int] -> Text -> [Text]
splitTextByIndices (forall a. [a] -> [a]
init [Int]
indices)) forall a b. (a -> b) -> a -> b
$
if Bool
headless
then forall s (m :: * -> *) t u a.
Stream s m t =>
ParsecT s u m a -> ParsecT s u m a
lookAhead forall (m :: * -> *) st. Monad m => ParsecT Sources st m Text
anyLine
else forall (m :: * -> *) a. Monad m => a -> m a
return Text
rawContent
let aligns :: [Alignment]
aligns = forall a b c. (a -> b -> c) -> [a] -> [b] -> [c]
zipWith [Text] -> Int -> Alignment
alignType (forall a b. (a -> b) -> [a] -> [b]
map (forall a. a -> [a] -> [a]
: []) [Text]
rawHeads) [Int]
lengths
let rawHeads' :: [Text]
rawHeads' = if Bool
headless
then []
else [Text]
rawHeads
Future ParserState [Blocks]
heads <- forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap forall (t :: * -> *) (m :: * -> *) a.
(Traversable t, Monad m) =>
t (m a) -> m (t a)
sequence
forall a b. (a -> b) -> a -> b
$
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
mapM (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 => MarkdownParser m (F Blocks)
plain)forall b c a. (b -> c) -> (a -> b) -> a -> c
.Text -> Text
trim) [Text]
rawHeads'
forall (m :: * -> *) a. Monad m => a -> m a
return (Future ParserState [Blocks]
heads, [Alignment]
aligns, [Int]
indices)
alignType :: [Text]
-> Int
-> Alignment
alignType :: [Text] -> Int -> Alignment
alignType [] Int
_ = Alignment
AlignDefault
alignType [Text]
strLst Int
len =
let nonempties :: [Text]
nonempties = forall a. (a -> Bool) -> [a] -> [a]
filter (Bool -> Bool
not forall b c a. (b -> c) -> (a -> b) -> a -> c
. Text -> Bool
T.null) forall a b. (a -> b) -> a -> b
$ forall a b. (a -> b) -> [a] -> [b]
map Text -> Text
trimr [Text]
strLst
(Bool
leftSpace, Bool
rightSpace) =
case forall b a. Ord b => (a -> b) -> [a] -> [a]
sortOn Text -> Int
T.length [Text]
nonempties of
(Text
x:[Text]
_) -> (Text -> Char
T.head Text
x forall (t :: * -> *) a. (Foldable t, Eq a) => a -> t a -> Bool
`elem` [Char
' ', Char
'\t'], Text -> Int
T.length Text
x forall a. Ord a => a -> a -> Bool
< Int
len)
[] -> (Bool
False, Bool
False)
in case (Bool
leftSpace, Bool
rightSpace) of
(Bool
True, Bool
False) -> Alignment
AlignRight
(Bool
False, Bool
True) -> Alignment
AlignLeft
(Bool
True, Bool
True) -> Alignment
AlignCenter
(Bool
False, Bool
False) -> Alignment
AlignDefault
tableFooter :: PandocMonad m => MarkdownParser m Text
= 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 => MarkdownParser m Int
skipNonindentSpaces 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 :: * -> *) st.
PandocMonad m =>
Char -> ParsecT Sources st m (Int, Int)
dashedLine Char
'-') forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> forall (m :: * -> *). PandocMonad m => MarkdownParser m Text
blanklines'
tableSep :: PandocMonad m => MarkdownParser m Char
tableSep :: forall (m :: * -> *). PandocMonad m => MarkdownParser m Char
tableSep = 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 => MarkdownParser m Int
skipNonindentSpaces 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 :: * -> *) st.
PandocMonad m =>
Char -> ParsecT Sources st m (Int, Int)
dashedLine Char
'-') forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
Char -> ParsecT s u m Char
char Char
'\n'
rawTableLine :: PandocMonad m
=> [Int]
-> MarkdownParser m [Text]
rawTableLine :: forall (m :: * -> *).
PandocMonad m =>
[Int] -> MarkdownParser m [Text]
rawTableLine [Int]
indices = do
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 => MarkdownParser 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 => MarkdownParser m Text
tableFooter)
Text
line <- forall (m :: * -> *) st. Monad m => ParsecT Sources st m Text
anyLine
forall (m :: * -> *) a. Monad m => a -> m a
return forall a b. (a -> b) -> a -> b
$ forall a b. (a -> b) -> [a] -> [b]
map Text -> Text
trim forall a b. (a -> b) -> a -> b
$ forall a. [a] -> [a]
tail forall a b. (a -> b) -> a -> b
$
[Int] -> Text -> [Text]
splitTextByIndices (forall a. [a] -> [a]
init [Int]
indices) Text
line
tableLine :: PandocMonad m
=> [Int]
-> MarkdownParser m (F [Blocks])
tableLine :: forall (m :: * -> *).
PandocMonad m =>
[Int] -> MarkdownParser m (Future ParserState [Blocks])
tableLine [Int]
indices = forall (m :: * -> *).
PandocMonad m =>
[Int] -> MarkdownParser m [Text]
rawTableLine [Int]
indices forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>=
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap forall (t :: * -> *) (m :: * -> *) a.
(Traversable t, Monad m) =>
t (m a) -> m (t a)
sequence forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
mapM (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 => MarkdownParser m (F Blocks)
plain))
multilineRow :: PandocMonad m
=> [Int]
-> MarkdownParser m (F [Blocks])
multilineRow :: forall (m :: * -> *).
PandocMonad m =>
[Int] -> MarkdownParser m (Future ParserState [Blocks])
multilineRow [Int]
indices = do
[[Text]]
colLines <- 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] -> MarkdownParser m [Text]
rawTableLine [Int]
indices)
let cols :: [Text]
cols = forall a b. (a -> b) -> [a] -> [b]
map [Text] -> Text
T.unlines forall a b. (a -> b) -> a -> b
$ forall a. [[a]] -> [[a]]
transpose [[Text]]
colLines
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap forall (t :: * -> *) (m :: * -> *) a.
(Traversable t, Monad m) =>
t (m a) -> m (t a)
sequence forall a b. (a -> b) -> a -> b
$ forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
mapM (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 => MarkdownParser m (F Blocks)
plain)) [Text]
cols
tableCaption :: PandocMonad m => MarkdownParser m (F Inlines)
tableCaption :: forall (m :: * -> *). PandocMonad m => MarkdownParser m (F Inlines)
tableCaption = do
forall s (m :: * -> *) a st.
(Stream s m a, HasReaderOptions st) =>
Extension -> ParsecT s st m ()
guardEnabled Extension
Ext_table_captions
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 => MarkdownParser m Int
skipNonindentSpaces
(forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
FilePath -> ParsecT s u m FilePath
string FilePath
":" 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 -> Bool) -> ParsecT s u m Char
satisfy Char -> Bool
isPunctuation)) 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) =>
FilePath -> ParsecT s u m Char
oneOf [Char
'T',Char
't'] 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) =>
FilePath -> ParsecT s u m FilePath
string FilePath
"able:")
forall s. Future s Inlines -> Future s Inlines
trimInlinesF forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall (m :: * -> *). PandocMonad m => MarkdownParser m (F Inlines)
inlines1 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
simpleTable :: PandocMonad m
=> Bool
-> MarkdownParser m (F TableComponents)
simpleTable :: forall (m :: * -> *).
PandocMonad m =>
Bool -> MarkdownParser m (F TableComponents)
simpleTable Bool
headless = do
F TableComponents
tableComponents <-
forall s (m :: * -> *) st (mf :: * -> *) sep end.
(Stream s m Char, UpdateSourcePos s Char, HasReaderOptions st,
Monad mf) =>
TableNormalization
-> ParsecT s st m (mf [Blocks], [Alignment], [Int])
-> ([Int] -> ParsecT s st m (mf [Blocks]))
-> ParsecT s st m sep
-> ParsecT s st m end
-> ParsecT s st m (mf TableComponents)
tableWith' TableNormalization
NormalizeHeader
(forall (m :: * -> *).
PandocMonad m =>
Bool
-> MarkdownParser
m (Future ParserState [Blocks], [Alignment], [Int])
simpleTableHeader Bool
headless) forall (m :: * -> *).
PandocMonad m =>
[Int] -> MarkdownParser m (Future ParserState [Blocks])
tableLine
(forall (m :: * -> *) a. Monad m => a -> m a
return ())
(if Bool
headless then forall (m :: * -> *). PandocMonad m => MarkdownParser m Text
tableFooter else forall (m :: * -> *). PandocMonad m => MarkdownParser m Text
tableFooter forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> forall (m :: * -> *). PandocMonad m => MarkdownParser m Text
blanklines')
let useDefaultColumnWidths :: TableComponents -> TableComponents
useDefaultColumnWidths TableComponents
tc =
let cs' :: [(Alignment, ColWidth)]
cs' = forall a b. (a -> b) -> [a] -> [b]
map (forall (p :: * -> * -> *) b c a.
Bifunctor p =>
(b -> c) -> p a b -> p a c
second (forall a b. a -> b -> a
const ColWidth
ColWidthDefault)) forall a b. (a -> b) -> a -> b
$ TableComponents -> [(Alignment, ColWidth)]
tableColSpecs TableComponents
tc
in TableComponents
tc {tableColSpecs :: [(Alignment, ColWidth)]
tableColSpecs = [(Alignment, ColWidth)]
cs'}
forall (m :: * -> *) a. Monad m => a -> m a
return forall a b. (a -> b) -> a -> b
$ TableComponents -> TableComponents
useDefaultColumnWidths forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> F TableComponents
tableComponents
multilineTable :: PandocMonad m
=> Bool
-> MarkdownParser m (F TableComponents)
multilineTable :: forall (m :: * -> *).
PandocMonad m =>
Bool -> MarkdownParser m (F TableComponents)
multilineTable Bool
headless =
forall s (m :: * -> *) st (mf :: * -> *) sep end.
(Stream s m Char, UpdateSourcePos s Char, HasReaderOptions st,
Monad mf) =>
TableNormalization
-> ParsecT s st m (mf [Blocks], [Alignment], [Int])
-> ([Int] -> ParsecT s st m (mf [Blocks]))
-> ParsecT s st m sep
-> ParsecT s st m end
-> ParsecT s st m (mf TableComponents)
tableWith' TableNormalization
NormalizeHeader (forall (m :: * -> *).
PandocMonad m =>
Bool
-> MarkdownParser
m (Future ParserState [Blocks], [Alignment], [Int])
multilineTableHeader Bool
headless)
forall (m :: * -> *).
PandocMonad m =>
[Int] -> MarkdownParser m (Future ParserState [Blocks])
multilineRow forall s (m :: * -> *) st.
(Stream s m Char, UpdateSourcePos s Char) =>
ParsecT s st m Text
blanklines forall (m :: * -> *). PandocMonad m => MarkdownParser m Text
tableFooter
multilineTableHeader :: PandocMonad m
=> Bool
-> MarkdownParser m (F [Blocks], [Alignment], [Int])
Bool
headless = 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 :: * -> *). Applicative f => Bool -> f () -> f ()
unless Bool
headless forall a b. (a -> b) -> a -> b
$
forall (m :: * -> *). PandocMonad m => MarkdownParser m Char
tableSep 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 s (m :: * -> *) st.
(Stream s m Char, UpdateSourcePos s Char) =>
ParsecT s st m Char
blankline
[Text]
rawContent <- if Bool
headless
then forall (m :: * -> *) a. Monad m => a -> m a
return forall a b. (a -> b) -> a -> b
$ forall a. a -> [a]
repeat Text
""
else 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 (m :: * -> *) t a u.
(Stream s m t, Show a) =>
ParsecT s u m a -> ParsecT s u m ()
notFollowedBy forall (m :: * -> *). PandocMonad m => MarkdownParser m Char
tableSep forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> forall (m :: * -> *) st. Monad m => ParsecT Sources st m Text
anyLine
Text
initSp <- forall (m :: * -> *). PandocMonad m => MarkdownParser m Text
nonindentSpaces
[(Int, Int)]
dashes <- forall s (m :: * -> *) t u a.
Stream s m t =>
ParsecT s u m a -> ParsecT s u m [a]
many1 (forall (m :: * -> *) st.
PandocMonad m =>
Char -> ParsecT Sources st m (Int, Int)
dashedLine Char
'-')
forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
ParsecT s u m Char
newline
let ([Int]
lengths, [Int]
lines') = forall a b. [(a, b)] -> ([a], [b])
unzip [(Int, Int)]
dashes
let indices :: [Int]
indices = forall b a. (b -> a -> b) -> b -> [a] -> [b]
scanl forall a. Num a => a -> a -> a
(+) (Text -> Int
T.length Text
initSp) [Int]
lines'
let indices' :: [Int]
indices' = case forall a. [a] -> [a]
reverse [Int]
indices of
[] -> []
(Int
x:[Int]
xs) -> forall a. [a] -> [a]
reverse (Int
xforall a. Num a => a -> a -> a
+Int
1forall a. a -> [a] -> [a]
:[Int]
xs)
[[Text]]
rawHeadsList <- if Bool
headless
then forall a b. (a -> b) -> [a] -> [b]
map (forall a. a -> [a] -> [a]
:[]) forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. [a] -> [a]
tail forall b c a. (b -> c) -> (a -> b) -> a -> c
. [Int] -> Text -> [Text]
splitTextByIndices (forall a. [a] -> [a]
init [Int]
indices')
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
lookAhead forall (m :: * -> *) st. Monad m => ParsecT Sources st m Text
anyLine
else forall (m :: * -> *) a. Monad m => a -> m a
return 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. [a] -> [a]
tail forall b c a. (b -> c) -> (a -> b) -> a -> c
. [Int] -> Text -> [Text]
splitTextByIndices (forall a. [a] -> [a]
init [Int]
indices'))
[Text]
rawContent
let aligns :: [Alignment]
aligns = forall a b c. (a -> b -> c) -> [a] -> [b] -> [c]
zipWith [Text] -> Int -> Alignment
alignType [[Text]]
rawHeadsList [Int]
lengths
let rawHeads :: [Text]
rawHeads = if Bool
headless
then []
else forall a b. (a -> b) -> [a] -> [b]
map ([Text] -> Text
T.unlines forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a b. (a -> b) -> [a] -> [b]
map Text -> Text
trim) [[Text]]
rawHeadsList
Future ParserState [Blocks]
heads <- forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap forall (t :: * -> *) (m :: * -> *) a.
(Traversable t, Monad m) =>
t (m a) -> m (t a)
sequence forall a b. (a -> b) -> a -> b
$
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
mapM (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 => MarkdownParser m (F Blocks)
plain)forall b c a. (b -> c) -> (a -> b) -> a -> c
.Text -> Text
trim) [Text]
rawHeads
forall (m :: * -> *) a. Monad m => a -> m a
return (Future ParserState [Blocks]
heads, [Alignment]
aligns, [Int]
indices')
gridTable :: PandocMonad m
=> MarkdownParser m (F TableComponents)
gridTable :: forall (m :: * -> *).
PandocMonad m =>
MarkdownParser m (F TableComponents)
gridTable = forall (m :: * -> *) (mf :: * -> *) st.
(Monad m, Monad mf, HasReaderOptions st, HasLastStrPosition st) =>
TableNormalization
-> ParsecT Sources st m (mf Blocks)
-> ParsecT Sources st m (mf TableComponents)
gridTableWith' TableNormalization
NormalizeHeader forall (m :: * -> *). PandocMonad m => MarkdownParser m (F Blocks)
parseBlocks
pipeBreak :: PandocMonad m => MarkdownParser m ([Alignment], [Int])
pipeBreak :: forall (m :: * -> *).
PandocMonad m =>
MarkdownParser m ([Alignment], [Int])
pipeBreak = 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 => MarkdownParser m Text
nonindentSpaces
Bool
openPipe <- (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
(Alignment, Int)
first <- forall (m :: * -> *) st.
PandocMonad m =>
ParsecT Sources st m (Alignment, Int)
pipeTableHeaderPart
[(Alignment, Int)]
rest <- forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m [a]
many forall a b. (a -> b) -> a -> b
$ forall (m :: * -> *). PandocMonad m => MarkdownParser m ()
sepPipe forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> forall (m :: * -> *) st.
PandocMonad m =>
ParsecT Sources st m (Alignment, Int)
pipeTableHeaderPart
Bool
closePipe <- (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 (f :: * -> *). Alternative f => Bool -> f ()
guard forall a b. (a -> b) -> a -> b
$ Bool -> Bool
not (forall (t :: * -> *) a. Foldable t => t a -> Bool
null [(Alignment, Int)]
rest Bool -> Bool -> Bool
&& Bool -> Bool
not (Bool
openPipe Bool -> Bool -> Bool
|| Bool
closePipe))
forall s (m :: * -> *) st.
(Stream s m Char, UpdateSourcePos s Char) =>
ParsecT s st m Char
blankline
forall (m :: * -> *) a. Monad m => a -> m a
return forall a b. (a -> b) -> a -> b
$ forall a b. [(a, b)] -> ([a], [b])
unzip ((Alignment, Int)
firstforall a. a -> [a] -> [a]
:[(Alignment, Int)]
rest)
pipeTable :: PandocMonad m => MarkdownParser m (F TableComponents)
pipeTable :: forall (m :: * -> *).
PandocMonad m =>
MarkdownParser m (F TableComponents)
pipeTable = 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 => MarkdownParser m Text
nonindentSpaces
forall s (m :: * -> *) t u a.
Stream s m t =>
ParsecT s u m a -> ParsecT s u m a
lookAhead forall s (m :: * -> *) st.
(Stream s m Char, UpdateSourcePos s Char) =>
ParsecT s st m Char
nonspaceChar
([Text]
heads,([Alignment]
aligns, [Int]
seplengths)) <- (,) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall (m :: * -> *). PandocMonad m => MarkdownParser m [Text]
pipeTableRow forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall (m :: * -> *).
PandocMonad m =>
MarkdownParser m ([Alignment], [Int])
pipeBreak
let cellContents :: Text -> ParsecT Sources ParserState m (F Blocks)
cellContents = forall (m :: * -> *) u a.
(Monad m, HasLastStrPosition u) =>
ParsecT Sources u m a -> Text -> ParsecT Sources u m a
parseFromString' forall (m :: * -> *). PandocMonad m => MarkdownParser m (F Blocks)
pipeTableCell forall b c a. (b -> c) -> (a -> b) -> a -> c
. Text -> Text
trim
let numcols :: Int
numcols = forall (t :: * -> *) a. Foldable t => t a -> Int
length [Alignment]
aligns
let heads' :: [Text]
heads' = forall a. Int -> [a] -> [a]
take Int
numcols [Text]
heads
[[Text]]
lines' <- forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m [a]
many forall (m :: * -> *). PandocMonad m => MarkdownParser m [Text]
pipeTableRow
let lines'' :: [[Text]]
lines'' = forall a b. (a -> b) -> [a] -> [b]
map (forall a. Int -> [a] -> [a]
take Int
numcols) [[Text]]
lines'
let lineWidths :: [Int]
lineWidths = forall a b. (a -> b) -> [a] -> [b]
map (forall (t :: * -> *) a. (Foldable t, Num a) => t a -> a
sum forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a b. (a -> b) -> [a] -> [b]
map forall a. HasChars a => a -> Int
realLength) ([Text]
heads' forall a. a -> [a] -> [a]
: [[Text]]
lines'')
Int
columns <- forall st s (m :: * -> *) t b.
(HasReaderOptions st, Stream s m t) =>
(ReaderOptions -> b) -> ParsecT s st m b
getOption ReaderOptions -> Int
readerColumns
let widths :: [Double]
widths = if forall (f :: * -> *) a. (Foldable f, Ord a, Bounded a) => f a -> a
maximumBounded (forall (t :: * -> *) a. (Foldable t, Num a) => t a -> a
sum [Int]
seplengths forall a. a -> [a] -> [a]
: [Int]
lineWidths) forall a. Num a => a -> a -> a
+ (Int
numcols forall a. Num a => a -> a -> a
+ Int
1)
forall a. Ord a => a -> a -> Bool
> Int
columns
then forall a b. (a -> b) -> [a] -> [b]
map (\Int
len ->
forall a b. (Integral a, Num b) => a -> b
fromIntegral Int
len forall a. Fractional a => a -> a -> a
/ forall a b. (Integral a, Num b) => a -> b
fromIntegral (forall (t :: * -> *) a. (Foldable t, Num a) => t a -> a
sum [Int]
seplengths))
[Int]
seplengths
else forall a. Int -> a -> [a]
replicate (forall (t :: * -> *) a. Foldable t => t a -> Int
length [Alignment]
aligns) Double
0.0
(Future ParserState [Blocks]
headCells :: F [Blocks]) <- forall (t :: * -> *) (m :: * -> *) a.
(Traversable t, Monad m) =>
t (m a) -> m (t a)
sequence forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
mapM Text -> ParsecT Sources ParserState m (F Blocks)
cellContents [Text]
heads'
(F [[Blocks]]
rows :: F [[Blocks]]) <- forall (t :: * -> *) (m :: * -> *) a.
(Traversable t, Monad m) =>
t (m a) -> m (t a)
sequence forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$>
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
mapM (forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap forall (t :: * -> *) (m :: * -> *) a.
(Traversable t, Monad m) =>
t (m a) -> m (t a)
sequence forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
mapM Text -> ParsecT Sources ParserState m (F Blocks)
cellContents) [[Text]]
lines''
forall (m :: * -> *) a. Monad m => a -> m a
return forall a b. (a -> b) -> a -> b
$
TableNormalization
-> [Alignment]
-> [Double]
-> [Blocks]
-> [[Blocks]]
-> TableComponents
toTableComponents' TableNormalization
NormalizeHeader [Alignment]
aligns [Double]
widths forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Future ParserState [Blocks]
headCells forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> F [[Blocks]]
rows
sepPipe :: PandocMonad m => MarkdownParser m ()
sepPipe :: forall (m :: * -> *). PandocMonad m => MarkdownParser m ()
sepPipe = 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 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
'+'
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
pipeTableRow :: PandocMonad m => MarkdownParser m [Text]
pipeTableRow :: forall (m :: * -> *). PandocMonad m => MarkdownParser m [Text]
pipeTableRow = 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 :: * -> *) st. PandocMonad m => ParsecT Sources st m ()
scanForPipe
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
Bool
openPipe <- (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
let chunk :: ParsecT Sources ParserState m ()
chunk = forall (f :: * -> *) a. Functor f => f a -> f ()
void (forall (m :: * -> *). PandocMonad m => MarkdownParser m (F Inlines)
code forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> forall (m :: * -> *). PandocMonad m => MarkdownParser m (F Inlines)
math forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> forall (m :: * -> *). PandocMonad m => MarkdownParser m (F Inlines)
rawHtmlInline forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|>
forall (m :: * -> *). PandocMonad m => MarkdownParser m (F Inlines)
escapedChar forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> forall (m :: * -> *). PandocMonad m => MarkdownParser m (F Inlines)
rawLaTeXInline')
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> forall (f :: * -> *) a. Functor f => f a -> f ()
void (forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
FilePath -> ParsecT s u m Char
noneOf FilePath
"|\n\r")
[Text]
cells <- (forall a b. (a, b) -> b
snd forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall (m :: * -> *) st a.
Monad m =>
ParsecT Sources st m a -> ParsecT Sources st m (a, Text)
withRaw (forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m [a]
many ParsecT Sources ParserState m ()
chunk)) forall s (m :: * -> *) t u a sep.
Stream s m t =>
ParsecT s u m a -> ParsecT s u m sep -> ParsecT s u m [a]
`sepBy1` forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
Char -> ParsecT s u m Char
char Char
'|'
Bool
closePipe <- (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 (f :: * -> *). Alternative f => Bool -> f ()
guard forall a b. (a -> b) -> a -> b
$ Bool -> Bool
not (forall (t :: * -> *) a. Foldable t => t a -> Int
length [Text]
cells forall a. Eq a => a -> a -> Bool
== Int
1 Bool -> Bool -> Bool
&& Bool -> Bool
not (Bool
openPipe Bool -> Bool -> Bool
|| Bool
closePipe))
forall s (m :: * -> *) st.
(Stream s m Char, UpdateSourcePos s Char) =>
ParsecT s st m Char
blankline
forall (m :: * -> *) a. Monad m => a -> m a
return [Text]
cells
pipeTableCell :: PandocMonad m => MarkdownParser m (F Blocks)
pipeTableCell :: forall (m :: * -> *). PandocMonad m => MarkdownParser m (F Blocks)
pipeTableCell =
(do F Inlines
result <- forall (m :: * -> *). PandocMonad m => MarkdownParser m (F Inlines)
inlines1
forall (m :: * -> *) a. Monad m => a -> m a
return forall a b. (a -> b) -> a -> b
$ Inlines -> Blocks
B.plain forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> F Inlines
result)
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 forall a. Monoid a => a
mempty
pipeTableHeaderPart :: PandocMonad m => ParsecT Sources st m (Alignment, Int)
= 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
Maybe Char
left <- forall s (m :: * -> *) t u a.
Stream s m t =>
ParsecT s u m a -> ParsecT s u m (Maybe a)
optionMaybe (forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
Char -> ParsecT s u m Char
char Char
':')
FilePath
pipe <- 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
'-')
Maybe Char
right <- forall s (m :: * -> *) t u a.
Stream s m t =>
ParsecT s u m a -> ParsecT s u m (Maybe a)
optionMaybe (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 ()
skipMany forall s (m :: * -> *) st.
(Stream s m Char, UpdateSourcePos s Char) =>
ParsecT s st m Char
spaceChar
let len :: Int
len = forall (t :: * -> *) a. Foldable t => t a -> Int
length FilePath
pipe forall a. Num a => a -> a -> a
+ forall b a. b -> (a -> b) -> Maybe a -> b
maybe Int
0 (forall a b. a -> b -> a
const Int
1) Maybe Char
left forall a. Num a => a -> a -> a
+ forall b a. b -> (a -> b) -> Maybe a -> b
maybe Int
0 (forall a b. a -> b -> a
const Int
1) Maybe Char
right
forall (m :: * -> *) a. Monad m => a -> m a
return
(case (Maybe Char
left,Maybe Char
right) of
(Maybe Char
Nothing,Maybe Char
Nothing) -> Alignment
AlignDefault
(Just Char
_,Maybe Char
Nothing) -> Alignment
AlignLeft
(Maybe Char
Nothing,Just Char
_) -> Alignment
AlignRight
(Just Char
_,Just Char
_) -> Alignment
AlignCenter, Int
len)
scanForPipe :: PandocMonad m => ParsecT Sources st m ()
scanForPipe :: forall (m :: * -> *) st. PandocMonad m => ParsecT Sources st m ()
scanForPipe = do
Sources [(SourcePos, Text)]
inps <- forall (m :: * -> *) s u. Monad m => ParsecT s u m s
getInput
let ln :: Text
ln = case [(SourcePos, Text)]
inps of
[] -> Text
""
((SourcePos
_,Text
t):(SourcePos
_,Text
t'):[(SourcePos, Text)]
_) | Text -> Bool
T.null Text
t -> Text
t'
((SourcePos
_,Text
t):[(SourcePos, Text)]
_) -> Text
t
case (Char -> Bool) -> Text -> Target
T.break (\Char
c -> Char
c forall a. Eq a => a -> a -> Bool
== Char
'\n' Bool -> Bool -> Bool
|| Char
c forall a. Eq a => a -> a -> Bool
== Char
'|') Text
ln of
(Text
_, Text -> Maybe (Char, Text)
T.uncons -> Just (Char
'|', Text
_)) -> forall (m :: * -> *) a. Monad m => a -> m a
return ()
Target
_ -> forall (m :: * -> *) a. MonadPlus m => m a
mzero
table :: PandocMonad m => MarkdownParser m (F Blocks)
table :: forall (m :: * -> *). PandocMonad m => MarkdownParser m (F Blocks)
table = forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try forall a b. (a -> b) -> a -> b
$ do
Maybe (F Inlines)
frontCaption <- forall s (m :: * -> *) t a u.
Stream s m t =>
a -> ParsecT s u m a -> ParsecT s u m a
option forall a. Maybe a
Nothing (forall a. a -> Maybe a
Just forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall (m :: * -> *). PandocMonad m => MarkdownParser m (F Inlines)
tableCaption)
F TableComponents
tableComponents <-
(forall s (m :: * -> *) a st.
(Stream s m a, HasReaderOptions st) =>
Extension -> ParsecT s st m ()
guardEnabled Extension
Ext_pipe_tables 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 :: * -> *) st. PandocMonad m => ParsecT Sources st m ()
scanForPipe forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> forall (m :: * -> *).
PandocMonad m =>
MarkdownParser m (F TableComponents)
pipeTable)) forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|>
(forall s (m :: * -> *) a st.
(Stream s m a, HasReaderOptions st) =>
Extension -> ParsecT s st m ()
guardEnabled Extension
Ext_multiline_tables 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 =>
Bool -> MarkdownParser m (F TableComponents)
multilineTable Bool
False)) forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|>
(forall s (m :: * -> *) a st.
(Stream s m a, HasReaderOptions st) =>
Extension -> ParsecT s st m ()
guardEnabled Extension
Ext_simple_tables 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 =>
Bool -> MarkdownParser m (F TableComponents)
simpleTable Bool
True forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> forall (m :: * -> *).
PandocMonad m =>
Bool -> MarkdownParser m (F TableComponents)
simpleTable Bool
False)) forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|>
(forall s (m :: * -> *) a st.
(Stream s m a, HasReaderOptions st) =>
Extension -> ParsecT s st m ()
guardEnabled Extension
Ext_multiline_tables 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 =>
Bool -> MarkdownParser m (F TableComponents)
multilineTable Bool
True)) forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|>
(forall s (m :: * -> *) a st.
(Stream s m a, HasReaderOptions st) =>
Extension -> ParsecT s st m ()
guardEnabled Extension
Ext_grid_tables 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 =>
MarkdownParser m (F TableComponents)
gridTable) forall s u (m :: * -> *) a.
ParsecT s u m a -> FilePath -> ParsecT s u m a
<?> FilePath
"table"
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
F Inlines
caption <- case Maybe (F Inlines)
frontCaption of
Maybe (F Inlines)
Nothing -> forall s (m :: * -> *) t a u.
Stream s m t =>
a -> ParsecT s u m a -> ParsecT s u m a
option (forall (m :: * -> *) a. Monad m => a -> m a
return forall a. Monoid a => a
mempty) forall (m :: * -> *). PandocMonad m => MarkdownParser m (F Inlines)
tableCaption
Just F Inlines
c -> forall (m :: * -> *) a. Monad m => a -> m a
return F Inlines
c
forall (m :: * -> *) a. Monad m => a -> m a
return forall a b. (a -> b) -> a -> b
$ do
Inlines
caption' <- F Inlines
caption
(TableComponents Attr
_attr Caption
_capt [(Alignment, ColWidth)]
colspecs TableHead
th [TableBody]
tb TableFoot
tf) <- F TableComponents
tableComponents
forall (m :: * -> *) a. Monad m => a -> m a
return forall a b. (a -> b) -> a -> b
$ Caption
-> [(Alignment, ColWidth)]
-> TableHead
-> [TableBody]
-> TableFoot
-> Blocks
B.table (Blocks -> Caption
B.simpleCaption forall a b. (a -> b) -> a -> b
$ Inlines -> Blocks
B.plain Inlines
caption') [(Alignment, ColWidth)]
colspecs TableHead
th [TableBody]
tb TableFoot
tf
inlines :: PandocMonad m => MarkdownParser m (F Inlines)
inlines :: forall (m :: * -> *). PandocMonad m => MarkdownParser m (F Inlines)
inlines = 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 => MarkdownParser m (F Inlines)
inline
inlines1 :: PandocMonad m => MarkdownParser m (F Inlines)
inlines1 :: forall (m :: * -> *). PandocMonad m => MarkdownParser m (F Inlines)
inlines1 = 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 => MarkdownParser m (F Inlines)
inline
inline :: PandocMonad m => MarkdownParser m (F Inlines)
inline :: forall (m :: * -> *). PandocMonad m => MarkdownParser m (F Inlines)
inline = do
Char
c <- forall s (m :: * -> *) t u a.
Stream s m t =>
ParsecT s u m a -> ParsecT s u m a
lookAhead forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
ParsecT s u m Char
anyChar
((case Char
c of
Char
' ' -> forall (m :: * -> *). PandocMonad m => MarkdownParser m (F Inlines)
whitespace
Char
'\t' -> forall (m :: * -> *). PandocMonad m => MarkdownParser m (F Inlines)
whitespace
Char
'\n' -> forall (m :: * -> *). PandocMonad m => MarkdownParser m (F Inlines)
endline
Char
'`' -> forall (m :: * -> *). PandocMonad m => MarkdownParser m (F Inlines)
code
Char
'_' -> forall (m :: * -> *). PandocMonad m => MarkdownParser m (F Inlines)
strongOrEmph
Char
'*' -> forall (m :: * -> *). PandocMonad m => MarkdownParser m (F Inlines)
strongOrEmph
Char
'^' -> forall (m :: * -> *). PandocMonad m => MarkdownParser m (F Inlines)
superscript forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> forall (m :: * -> *). PandocMonad m => MarkdownParser m (F Inlines)
inlineNote
Char
'[' -> forall (m :: * -> *). PandocMonad m => MarkdownParser m (F Inlines)
note forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> forall (m :: * -> *). PandocMonad m => MarkdownParser m (F Inlines)
cite forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> forall (m :: * -> *). PandocMonad m => MarkdownParser m (F Inlines)
bracketedSpan forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> forall (m :: * -> *).
PandocMonad m =>
(Attr -> Text -> Text -> Inlines -> Inlines)
-> MarkdownParser m (F Inlines)
wikilink Attr -> Text -> Text -> Inlines -> Inlines
B.linkWith forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> forall (m :: * -> *). PandocMonad m => MarkdownParser m (F Inlines)
link
Char
'!' -> forall (m :: * -> *). PandocMonad m => MarkdownParser m (F Inlines)
image
Char
'$' -> forall (m :: * -> *). PandocMonad m => MarkdownParser m (F Inlines)
math
Char
'~' -> forall (m :: * -> *). PandocMonad m => MarkdownParser m (F Inlines)
strikeout forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> forall (m :: * -> *). PandocMonad m => MarkdownParser m (F Inlines)
subscript
Char
'=' -> forall (m :: * -> *). PandocMonad m => MarkdownParser m (F Inlines)
mark
Char
'<' -> forall (m :: * -> *). PandocMonad m => MarkdownParser m (F Inlines)
autoLink forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> forall (m :: * -> *). PandocMonad m => MarkdownParser m (F Inlines)
spanHtml forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> forall (m :: * -> *). PandocMonad m => MarkdownParser m (F Inlines)
rawHtmlInline forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> forall (m :: * -> *). PandocMonad m => MarkdownParser m (F Inlines)
ltSign
Char
'\\' -> forall (m :: * -> *). PandocMonad m => MarkdownParser m (F Inlines)
math forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> forall (m :: * -> *). PandocMonad m => MarkdownParser m (F Inlines)
escapedNewline forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> forall (m :: * -> *). PandocMonad m => MarkdownParser m (F Inlines)
escapedChar forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> forall (m :: * -> *). PandocMonad m => MarkdownParser m (F Inlines)
rawLaTeXInline'
Char
'@' -> forall (m :: * -> *). PandocMonad m => MarkdownParser m (F Inlines)
cite forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> forall (m :: * -> *). PandocMonad m => MarkdownParser m (F Inlines)
exampleRef
Char
'"' -> forall (m :: * -> *). PandocMonad m => MarkdownParser m (F Inlines)
smart
Char
'\'' -> forall (m :: * -> *). PandocMonad m => MarkdownParser m (F Inlines)
smart
Char
'\8216' -> forall (m :: * -> *). PandocMonad m => MarkdownParser m (F Inlines)
smart
Char
'\145' -> forall (m :: * -> *). PandocMonad m => MarkdownParser m (F Inlines)
smart
Char
'\8220' -> forall (m :: * -> *). PandocMonad m => MarkdownParser m (F Inlines)
smart
Char
'\147' -> forall (m :: * -> *). PandocMonad m => MarkdownParser m (F Inlines)
smart
Char
'-' -> forall (m :: * -> *). PandocMonad m => MarkdownParser m (F Inlines)
smart
Char
'.' -> forall (m :: * -> *). PandocMonad m => MarkdownParser m (F Inlines)
smart
Char
'&' -> forall (m :: * -> *) a. Monad m => a -> m a
return forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. a -> Many a
B.singleton 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 Inline
charRef
Char
':' -> forall (m :: * -> *). PandocMonad m => MarkdownParser m (F Inlines)
emoji
Char
_ -> forall (m :: * -> *) a. MonadPlus m => m a
mzero)
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> forall (m :: * -> *). PandocMonad m => MarkdownParser m (F Inlines)
bareURL
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> forall (m :: * -> *). PandocMonad m => MarkdownParser m (F Inlines)
str
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> forall (m :: * -> *). PandocMonad m => MarkdownParser m (F Inlines)
symbol) forall s u (m :: * -> *) a.
ParsecT s u m a -> FilePath -> ParsecT s u m a
<?> FilePath
"inline"
escapedChar' :: PandocMonad m => MarkdownParser m Char
escapedChar' :: forall (m :: * -> *). PandocMonad m => MarkdownParser m Char
escapedChar' = 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 s (m :: * -> *) a st.
(Stream s m a, HasReaderOptions st) =>
Extension -> ParsecT s st m ()
guardEnabled Extension
Ext_all_symbols_escapable 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 -> Bool) -> ParsecT s u m Char
satisfy (Bool -> Bool
not forall b c a. (b -> c) -> (a -> b) -> a -> c
. Char -> Bool
isAlphaNum))
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> (forall s (m :: * -> *) a st.
(Stream s m a, HasReaderOptions st) =>
Extension -> ParsecT s st m ()
guardEnabled Extension
Ext_angle_brackets_escapable 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) =>
FilePath -> ParsecT s u m Char
oneOf FilePath
"\\`*_{}[]()>#+-.!~\"<>")
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) =>
FilePath -> ParsecT s u m Char
oneOf FilePath
"\\`*_{}[]()>#+-.!"
escapedNewline :: PandocMonad m => MarkdownParser m (F Inlines)
escapedNewline :: forall (m :: * -> *). PandocMonad m => MarkdownParser m (F Inlines)
escapedNewline = do
forall s (m :: * -> *) a st.
(Stream s m a, HasReaderOptions st) =>
Extension -> ParsecT s st m ()
guardEnabled Extension
Ext_escaped_line_breaks
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 s (m :: * -> *) t u a.
Stream s m t =>
ParsecT s u m a -> ParsecT s u m a
lookAhead (forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
Char -> ParsecT s u m Char
char Char
'\n')
forall (m :: * -> *) a. Monad m => a -> m a
return forall a b. (a -> b) -> a -> b
$ forall (m :: * -> *) a. Monad m => a -> m a
return Inlines
B.linebreak
escapedChar :: PandocMonad m => MarkdownParser m (F Inlines)
escapedChar :: forall (m :: * -> *). PandocMonad m => MarkdownParser m (F Inlines)
escapedChar = do
Char
result <- forall (m :: * -> *). PandocMonad m => MarkdownParser m Char
escapedChar'
case Char
result of
Char
' ' -> forall (m :: * -> *) a. Monad m => a -> m a
return forall a b. (a -> b) -> a -> b
$ forall (m :: * -> *) a. Monad m => a -> m a
return forall a b. (a -> b) -> a -> b
$ Text -> Inlines
B.str Text
"\160"
Char
_ -> forall (m :: * -> *) a. Monad m => a -> m a
return forall a b. (a -> b) -> a -> b
$ forall (m :: * -> *) a. Monad m => a -> m a
return forall a b. (a -> b) -> a -> b
$ Text -> Inlines
B.str forall a b. (a -> b) -> a -> b
$ Char -> Text
T.singleton Char
result
ltSign :: PandocMonad m => MarkdownParser m (F Inlines)
ltSign :: forall (m :: * -> *). PandocMonad m => MarkdownParser m (F Inlines)
ltSign = do
forall s (m :: * -> *) a st.
(Stream s m a, HasReaderOptions st) =>
Extension -> ParsecT s st m ()
guardDisabled Extension
Ext_raw_html
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> (forall (m :: * -> *). PandocMonad m => MarkdownParser m ()
notFollowedByHtmlCloser forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> forall b s (m :: * -> *) a st.
(Show b, Stream s m a) =>
ParsecT s st m b -> ParsecT s st m ()
notFollowedBy' (forall st (m :: * -> *).
(HasReaderOptions st, Monad m) =>
(Tag Text -> Bool) -> ParsecT Sources st m (Tag Text, Text)
htmlTag Tag Text -> Bool
isBlockTag))
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
$ forall (m :: * -> *) a. Monad m => a -> m a
return forall a b. (a -> b) -> a -> b
$ Text -> Inlines
B.str Text
"<"
exampleRef :: PandocMonad m => MarkdownParser m (F Inlines)
exampleRef :: forall (m :: * -> *). PandocMonad m => MarkdownParser m (F Inlines)
exampleRef = do
forall s (m :: * -> *) a st.
(Stream s m a, HasReaderOptions st) =>
Extension -> ParsecT s st m ()
guardEnabled Extension
Ext_example_lists
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
lab <- forall a. Monoid a => [a] -> a
mconcat forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a b. (a -> b) -> [a] -> [b]
map FilePath -> 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 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
alphaNum 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 (do Char
c <- forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
Char -> ParsecT s u m Char
char Char
'_' forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
Char -> ParsecT s u m Char
char Char
'-'
FilePath
cs <- 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
alphaNum
forall (m :: * -> *) a. Monad m => a -> m a
return (Char
cforall a. a -> [a] -> [a]
:FilePath
cs)))
forall (m :: * -> *) a. Monad m => a -> m a
return forall a b. (a -> b) -> a -> b
$ do
ParserState
st <- forall s. Future s s
askF
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
lab (ParserState -> Map Text Int
stateExamples ParserState
st) of
Just Int
n -> Text -> Inlines
B.str forall a b. (a -> b) -> a -> b
$ forall a. Show a => a -> Text
tshow Int
n
Maybe Int
Nothing -> Text -> Inlines
B.str forall a b. (a -> b) -> a -> b
$ Text
"@" forall a. Semigroup a => a -> a -> a
<> Text
lab
symbol :: PandocMonad m => MarkdownParser m (F Inlines)
symbol :: forall (m :: * -> *). PandocMonad m => MarkdownParser m (F Inlines)
symbol = do
Char
result <- forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
FilePath -> ParsecT s u m Char
noneOf FilePath
"<\\\n\t "
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 (do forall s (m :: * -> *) t u a.
Stream s m t =>
ParsecT s u m a -> ParsecT s u m a
lookAhead forall a b. (a -> b) -> a -> b
$ forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
Char -> ParsecT s u m Char
char Char
'\\'
forall b s (m :: * -> *) a st.
(Show b, Stream s m a) =>
ParsecT s st m b -> ParsecT s st m ()
notFollowedBy' (() forall (f :: * -> *) a b. Functor f => a -> f b -> f a
<$ forall (m :: * -> *). PandocMonad m => MarkdownParser m (F Blocks)
rawTeXBlock)
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
$ forall (m :: * -> *) a. Monad m => a -> m a
return forall a b. (a -> b) -> a -> b
$ Text -> Inlines
B.str forall a b. (a -> b) -> a -> b
$! Char -> Text
T.singleton Char
result
code :: PandocMonad m => MarkdownParser m (F Inlines)
code :: forall (m :: * -> *). PandocMonad m => MarkdownParser m (F Inlines)
code = forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try forall a b. (a -> b) -> a -> b
$ do
FilePath
starts <- forall s (m :: * -> *) t u a.
Stream s m t =>
ParsecT s u m a -> ParsecT s u m [a]
many1 (forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
Char -> ParsecT s u m Char
char Char
'`')
forall s (m :: * -> *) st.
(Stream s m Char, UpdateSourcePos s Char) =>
ParsecT s st m ()
skipSpaces
Text
result <- Text -> Text
trim forall b c a. (b -> c) -> (a -> b) -> a -> c
. [Text] -> Text
T.concat
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall s (m :: * -> *) t u a sep.
Stream s m t =>
ParsecT s u m a -> ParsecT s u m sep -> ParsecT s u m [a]
manyTill
( forall s (m :: * -> *) t st.
Stream s m t =>
ParsecT s st m Char -> ParsecT s st m Text
many1Char (forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
FilePath -> ParsecT s u m Char
noneOf FilePath
"`\n")
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> forall s (m :: * -> *) t st.
Stream s m t =>
ParsecT s st m Char -> ParsecT s st m Text
many1Char (forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
Char -> ParsecT s u m Char
char Char
'`')
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> (forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
Char -> ParsecT s u m Char
char Char
'\n'
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> forall s (m :: * -> *) t a u.
(Stream s m t, Show a) =>
ParsecT s u m a -> ParsecT s u m ()
notFollowedBy (forall (m :: * -> *). PandocMonad m => MarkdownParser m ()
inList forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> forall (m :: * -> *). PandocMonad m => MarkdownParser m ()
listStart)
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> forall b s (m :: * -> *) a st.
(Show b, Stream s m a) =>
ParsecT s st m b -> ParsecT s st m ()
notFollowedBy' forall s (m :: * -> *) st.
(Stream s m Char, UpdateSourcePos s Char) =>
ParsecT s st m Char
blankline
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> forall (m :: * -> *) a. Monad m => a -> m a
return Text
" "))
(forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try forall a b. (a -> b) -> a -> b
$ forall s (m :: * -> *) st.
(Stream s m Char, UpdateSourcePos s Char) =>
ParsecT s st m ()
skipSpaces
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> forall s (m :: * -> *) t u a.
Stream s m t =>
Int -> ParsecT s u m a -> ParsecT s u m [a]
count (forall (t :: * -> *) a. Foldable t => t a -> Int
length FilePath
starts) (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) =>
Char -> ParsecT s u m Char
char Char
'`'))
Either Text Attr
rawattr <-
(forall a b. a -> Either a b
Left forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (forall s (m :: * -> *) a st.
(Stream s m a, HasReaderOptions st) =>
Extension -> ParsecT s st m ()
guardEnabled Extension
Ext_raw_attribute 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 => MarkdownParser m Text
rawAttribute))
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|>
(forall a b. b -> Either a b
Right forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall s (m :: * -> *) t a u.
Stream s m t =>
a -> ParsecT s u m a -> ParsecT s u m a
option (Text
"",[],[])
(forall s (m :: * -> *) a st.
(Stream s m a, HasReaderOptions st) =>
Extension -> ParsecT s st m ()
guardEnabled Extension
Ext_inline_code_attributes 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 => MarkdownParser m Attr
attributes))
forall (m :: * -> *) a. Monad m => a -> m a
return forall a b. (a -> b) -> a -> b
$ forall (m :: * -> *) a. Monad m => a -> m a
return forall a b. (a -> b) -> a -> b
$
case Either Text Attr
rawattr of
Left Text
syn -> Text -> Text -> Inlines
B.rawInline Text
syn forall a b. (a -> b) -> a -> b
$! Text
result
Right Attr
attr -> Attr -> Text -> Inlines
B.codeWith Attr
attr forall a b. (a -> b) -> a -> b
$! Text
result
math :: PandocMonad m => MarkdownParser m (F Inlines)
math :: forall (m :: * -> *). PandocMonad m => MarkdownParser m (F Inlines)
math = (forall (m :: * -> *) a. Monad m => a -> m a
return forall b c a. (b -> c) -> (a -> b) -> a -> c
. Text -> Inlines
B.displayMath forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (forall st s (m :: * -> *).
(HasReaderOptions st, Stream s m Char, UpdateSourcePos s Char) =>
ParsecT s st m Text
mathDisplay forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= forall (m :: * -> *) s.
(PandocMonad m, HasMacros s, HasReaderOptions s) =>
Text -> ParsecT Sources s m Text
applyMacros))
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 forall b c a. (b -> c) -> (a -> b) -> a -> c
. Text -> Inlines
B.math forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (forall st s (m :: * -> *).
(HasReaderOptions st, Stream s m Char, UpdateSourcePos s Char) =>
ParsecT s st m Text
mathInline forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= forall (m :: * -> *) s.
(PandocMonad m, HasMacros s, HasReaderOptions s) =>
Text -> ParsecT Sources s m Text
applyMacros)) forall a s st (m :: * -> *).
Monoid a =>
ParsecT s st m a -> ParsecT s st m a -> ParsecT s st m a
<+?>
(forall s (m :: * -> *) a st.
(Stream s m a, HasReaderOptions st) =>
Extension -> ParsecT s st m ()
guardEnabled Extension
Ext_smart forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> (forall (m :: * -> *) a. Monad m => a -> m a
return 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 Inlines
apostrophe)
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
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) =>
(Char -> Bool) -> ParsecT s u m Char
satisfy Char -> Bool
isPunctuation))
enclosure :: PandocMonad m
=> Char
-> MarkdownParser m (F Inlines)
enclosure :: forall (m :: * -> *).
PandocMonad m =>
Char -> MarkdownParser m (F Inlines)
enclosure Char
c = do
forall s (m :: * -> *) a st.
(Stream s m a, HasReaderOptions st) =>
Extension -> ParsecT s st m ()
guardDisabled Extension
Ext_intraword_underscores
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> forall (f :: * -> *). Alternative f => Bool -> f ()
guard (Char
c forall a. Eq a => a -> a -> Bool
== Char
'*')
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> (forall (f :: * -> *). Alternative f => Bool -> f ()
guard forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< forall s (m :: * -> *) a st.
(Stream s m a, HasLastStrPosition st) =>
ParsecT s st m Bool
notAfterString)
Text
cs <- forall s (m :: * -> *) t st.
Stream s m t =>
ParsecT s st m Char -> ParsecT s st m Text
many1Char (forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
Char -> ParsecT s u m Char
char Char
c)
(forall (m :: * -> *) a. Monad m => a -> m a
return (Text -> Inlines
B.str Text
cs) forall a. Semigroup a => a -> a -> a
<>) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall (m :: * -> *). PandocMonad m => MarkdownParser m (F Inlines)
whitespace
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|>
case Text -> Int
T.length Text
cs of
Int
3 -> forall (m :: * -> *).
PandocMonad m =>
Char -> MarkdownParser m (F Inlines)
three Char
c
Int
2 -> forall (m :: * -> *).
PandocMonad m =>
Char -> F Inlines -> MarkdownParser m (F Inlines)
two Char
c forall a. Monoid a => a
mempty
Int
1 -> forall (m :: * -> *).
PandocMonad m =>
Char -> F Inlines -> MarkdownParser m (F Inlines)
one Char
c forall a. Monoid a => a
mempty
Int
_ -> forall (m :: * -> *) a. Monad m => a -> m a
return (forall (m :: * -> *) a. Monad m => a -> m a
return forall a b. (a -> b) -> a -> b
$ Text -> Inlines
B.str Text
cs)
ender :: PandocMonad m => Char -> Int -> MarkdownParser m ()
ender :: forall (m :: * -> *).
PandocMonad m =>
Char -> Int -> MarkdownParser m ()
ender Char
c Int
n = 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 =>
Int -> ParsecT s u m a -> ParsecT s u m [a]
count Int
n (forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
Char -> ParsecT s u m Char
char Char
c)
forall (f :: * -> *). Alternative f => Bool -> f ()
guard (Char
c forall a. Eq a => a -> a -> Bool
== Char
'*')
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> forall s (m :: * -> *) a st.
(Stream s m a, HasReaderOptions st) =>
Extension -> ParsecT s st m ()
guardDisabled Extension
Ext_intraword_underscores
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m 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
three :: PandocMonad m => Char -> MarkdownParser m (F Inlines)
three :: forall (m :: * -> *).
PandocMonad m =>
Char -> MarkdownParser m (F Inlines)
three Char
c = do
F Inlines
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 (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 =>
Char -> Int -> MarkdownParser m ()
ender Char
c Int
1) forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> forall (m :: * -> *). PandocMonad m => MarkdownParser m (F Inlines)
inline)
(forall (m :: * -> *).
PandocMonad m =>
Char -> Int -> MarkdownParser m ()
ender Char
c Int
3 forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> forall s (m :: * -> *) a st.
(Stream s m a, HasLastStrPosition st) =>
ParsecT s st m ()
updateLastStrPos forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> forall (m :: * -> *) a. Monad m => a -> m a
return (Inlines -> Inlines
B.strong forall b c a. (b -> c) -> (a -> b) -> a -> c
. Inlines -> Inlines
B.emph forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> F Inlines
contents))
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> (forall (m :: * -> *).
PandocMonad m =>
Char -> Int -> MarkdownParser m ()
ender Char
c Int
2 forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> forall s (m :: * -> *) a st.
(Stream s m a, HasLastStrPosition st) =>
ParsecT s st m ()
updateLastStrPos forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> forall (m :: * -> *).
PandocMonad m =>
Char -> F Inlines -> MarkdownParser m (F Inlines)
one Char
c (Inlines -> Inlines
B.strong forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> F Inlines
contents))
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> (forall (m :: * -> *).
PandocMonad m =>
Char -> Int -> MarkdownParser m ()
ender Char
c Int
1 forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> forall s (m :: * -> *) a st.
(Stream s m a, HasLastStrPosition st) =>
ParsecT s st m ()
updateLastStrPos forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> forall (m :: * -> *).
PandocMonad m =>
Char -> F Inlines -> MarkdownParser m (F Inlines)
two Char
c (Inlines -> Inlines
B.emph forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> F Inlines
contents))
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 (forall (m :: * -> *) a. Monad m => a -> m a
return (Text -> Inlines
B.str forall a b. (a -> b) -> a -> b
$ FilePath -> Text
T.pack [Char
c,Char
c,Char
c]) forall a. Semigroup a => a -> a -> a
<> F Inlines
contents)
two :: PandocMonad m => Char -> F Inlines -> MarkdownParser m (F Inlines)
two :: forall (m :: * -> *).
PandocMonad m =>
Char -> F Inlines -> MarkdownParser m (F Inlines)
two Char
c F Inlines
prefix' = do
F Inlines
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 (forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try forall a b. (a -> b) -> a -> b
$ forall s (m :: * -> *) t a u.
(Stream s m t, Show a) =>
ParsecT s u m a -> ParsecT s u m ()
notFollowedBy (forall (m :: * -> *).
PandocMonad m =>
Char -> Int -> MarkdownParser m ()
ender Char
c Int
2) forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> forall (m :: * -> *). PandocMonad m => MarkdownParser m (F Inlines)
inline)
(forall (m :: * -> *).
PandocMonad m =>
Char -> Int -> MarkdownParser m ()
ender Char
c Int
2 forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> forall s (m :: * -> *) a st.
(Stream s m a, HasLastStrPosition st) =>
ParsecT s st m ()
updateLastStrPos forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>>
forall (m :: * -> *) a. Monad m => a -> m a
return (Inlines -> Inlines
B.strong forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (F Inlines
prefix' forall a. Semigroup a => a -> a -> a
<> F Inlines
contents)))
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 (forall (m :: * -> *) a. Monad m => a -> m a
return (Text -> Inlines
B.str forall a b. (a -> b) -> a -> b
$ FilePath -> Text
T.pack [Char
c,Char
c]) forall a. Semigroup a => a -> a -> a
<> (F Inlines
prefix' forall a. Semigroup a => a -> a -> a
<> F Inlines
contents))
one :: PandocMonad m => Char -> F Inlines -> MarkdownParser m (F Inlines)
one :: forall (m :: * -> *).
PandocMonad m =>
Char -> F Inlines -> MarkdownParser m (F Inlines)
one Char
c F Inlines
prefix' = do
F Inlines
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 ( (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 =>
Char -> Int -> MarkdownParser m ()
ender Char
c Int
1) forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> forall (m :: * -> *). PandocMonad m => MarkdownParser m (F 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) =>
FilePath -> ParsecT s u m FilePath
string [Char
c,Char
c] forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>>
forall s (m :: * -> *) t a u.
(Stream s m t, Show a) =>
ParsecT s u m a -> ParsecT s u m ()
notFollowedBy (forall (m :: * -> *).
PandocMonad m =>
Char -> Int -> MarkdownParser m ()
ender Char
c Int
1) forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>>
forall (m :: * -> *).
PandocMonad m =>
Char -> F Inlines -> MarkdownParser m (F Inlines)
two Char
c forall a. Monoid a => a
mempty) )
(forall (m :: * -> *).
PandocMonad m =>
Char -> Int -> MarkdownParser m ()
ender Char
c Int
1 forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> forall s (m :: * -> *) a st.
(Stream s m a, HasLastStrPosition st) =>
ParsecT s st m ()
updateLastStrPos forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> forall (m :: * -> *) a. Monad m => a -> m a
return (Inlines -> Inlines
B.emph forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (F Inlines
prefix' forall a. Semigroup a => a -> a -> a
<> F Inlines
contents)))
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 (forall (m :: * -> *) a. Monad m => a -> m a
return (Text -> Inlines
B.str forall a b. (a -> b) -> a -> b
$ Char -> Text
T.singleton Char
c) forall a. Semigroup a => a -> a -> a
<> (F Inlines
prefix' forall a. Semigroup a => a -> a -> a
<> F Inlines
contents))
strongOrEmph :: PandocMonad m => MarkdownParser m (F Inlines)
strongOrEmph :: forall (m :: * -> *). PandocMonad m => MarkdownParser m (F Inlines)
strongOrEmph = forall (m :: * -> *).
PandocMonad m =>
Char -> MarkdownParser m (F Inlines)
enclosure Char
'*' forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> forall (m :: * -> *).
PandocMonad m =>
Char -> MarkdownParser m (F Inlines)
enclosure Char
'_'
inlinesBetween :: PandocMonad m
=> (Show b)
=> MarkdownParser m a
-> MarkdownParser m b
-> MarkdownParser m (F Inlines)
inlinesBetween :: forall (m :: * -> *) b a.
(PandocMonad m, Show b) =>
MarkdownParser m a
-> MarkdownParser m b -> MarkdownParser m (F Inlines)
inlinesBetween MarkdownParser m a
start MarkdownParser m b
end =
forall s. Future s Inlines -> Future s Inlines
trimInlinesF 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
try (MarkdownParser m a
start forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> forall end s (m :: * -> *) t st a.
(Show end, Stream s m t) =>
ParsecT s st m a -> ParsecT s st m end -> ParsecT s st m [a]
many1Till ParsecT Sources ParserState m (F Inlines)
inner MarkdownParser m b
end)
where inner :: ParsecT Sources ParserState m (F Inlines)
inner = ParsecT Sources ParserState m (F Inlines)
innerSpace forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|>
(forall b s (m :: * -> *) a st.
(Show b, Stream s m a) =>
ParsecT s st m b -> ParsecT s st m ()
notFollowedBy' (() forall (f :: * -> *) a b. Functor f => a -> f b -> f a
<$ forall (m :: * -> *). PandocMonad m => MarkdownParser m (F Inlines)
whitespace) forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> forall (m :: * -> *). PandocMonad m => MarkdownParser m (F Inlines)
inline)
innerSpace :: ParsecT Sources ParserState m (F Inlines)
innerSpace = 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 => MarkdownParser m (F Inlines)
whitespace forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
<* forall b s (m :: * -> *) a st.
(Show b, Stream s m a) =>
ParsecT s st m b -> ParsecT s st m ()
notFollowedBy' MarkdownParser m b
end
strikeout :: PandocMonad m => MarkdownParser m (F Inlines)
strikeout :: forall (m :: * -> *). PandocMonad m => MarkdownParser m (F Inlines)
strikeout = forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap Inlines -> Inlines
B.strikeout forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$>
(forall s (m :: * -> *) a st.
(Stream s m a, HasReaderOptions st) =>
Extension -> ParsecT s st m ()
guardEnabled Extension
Ext_strikeout forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> forall (m :: * -> *) b a.
(PandocMonad m, Show b) =>
MarkdownParser m a
-> MarkdownParser m b -> MarkdownParser m (F Inlines)
inlinesBetween forall {u}. ParsecT Sources u m ()
strikeStart forall {u}. ParsecT Sources u m FilePath
strikeEnd)
where strikeStart :: ParsecT Sources u m ()
strikeStart = forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
FilePath -> ParsecT s u m FilePath
string FilePath
"~~" forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> forall s (m :: * -> *) t u a.
Stream s m t =>
ParsecT s u m a -> ParsecT s u m a
lookAhead forall s (m :: * -> *) st.
(Stream s m Char, UpdateSourcePos s Char) =>
ParsecT s st m Char
nonspaceChar
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) =>
Char -> ParsecT s u m Char
char Char
'~')
strikeEnd :: ParsecT Sources u m FilePath
strikeEnd = 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) =>
FilePath -> ParsecT s u m FilePath
string FilePath
"~~"
mark :: PandocMonad m => MarkdownParser m (F Inlines)
mark :: forall (m :: * -> *). PandocMonad m => MarkdownParser m (F Inlines)
mark = forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (Attr -> Inlines -> Inlines
B.spanWith (Text
"",[Text
"mark"],[])) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$>
(forall s (m :: * -> *) a st.
(Stream s m a, HasReaderOptions st) =>
Extension -> ParsecT s st m ()
guardEnabled Extension
Ext_mark forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> forall (m :: * -> *) b a.
(PandocMonad m, Show b) =>
MarkdownParser m a
-> MarkdownParser m b -> MarkdownParser m (F Inlines)
inlinesBetween forall {u}. ParsecT Sources u m ()
markStart forall {u}. ParsecT Sources u m FilePath
markEnd)
where markStart :: ParsecT Sources u m ()
markStart = forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
FilePath -> ParsecT s u m FilePath
string FilePath
"==" forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> forall s (m :: * -> *) t u a.
Stream s m t =>
ParsecT s u m a -> ParsecT s u m a
lookAhead forall s (m :: * -> *) st.
(Stream s m Char, UpdateSourcePos s Char) =>
ParsecT s st m Char
nonspaceChar
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) =>
Char -> ParsecT s u m Char
char Char
'=')
markEnd :: ParsecT Sources u m FilePath
markEnd = 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) =>
FilePath -> ParsecT s u m FilePath
string FilePath
"=="
superscript :: PandocMonad m => MarkdownParser m (F Inlines)
superscript :: forall (m :: * -> *). PandocMonad m => MarkdownParser m (F Inlines)
superscript = do
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap Inlines -> Inlines
B.superscript 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
forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
Char -> ParsecT s u m Char
char Char
'^'
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
try ParsecT Sources ParserState m [F Inlines]
regularSuperscript 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 ParsecT Sources ParserState m [F Inlines]
mmdShortSuperscript))
where regularSuperscript :: ParsecT Sources ParserState m [F Inlines]
regularSuperscript = 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 (do forall s (m :: * -> *) a st.
(Stream s m a, HasReaderOptions st) =>
Extension -> ParsecT s st m ()
guardEnabled Extension
Ext_superscript
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 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 :: * -> *). PandocMonad m => MarkdownParser m (F Inlines)
inline) (forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
Char -> ParsecT s u m Char
char Char
'^')
mmdShortSuperscript :: ParsecT Sources ParserState m [F Inlines]
mmdShortSuperscript = do forall s (m :: * -> *) a st.
(Stream s m a, HasReaderOptions st) =>
Extension -> ParsecT s st m ()
guardEnabled Extension
Ext_short_subsuperscripts
Text
result <- FilePath -> 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) =>
ParsecT s u m Char
alphaNum
forall (m :: * -> *) a. Monad m => a -> m a
return forall a b. (a -> b) -> a -> b
$ forall (m :: * -> *) a. Monad m => a -> m a
return forall a b. (a -> b) -> a -> b
$ forall (m :: * -> *) a. Monad m => a -> m a
return forall a b. (a -> b) -> a -> b
$ Text -> Inlines
B.str Text
result
subscript :: PandocMonad m => MarkdownParser m (F Inlines)
subscript :: forall (m :: * -> *). PandocMonad m => MarkdownParser m (F Inlines)
subscript = do
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap Inlines -> Inlines
B.subscript 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
forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
Char -> ParsecT s u m Char
char Char
'~'
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
try ParsecT Sources ParserState m [F Inlines]
regularSubscript forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> ParsecT Sources ParserState m [F Inlines]
mmdShortSubscript))
where regularSubscript :: ParsecT Sources ParserState m [F Inlines]
regularSubscript = 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 (do forall s (m :: * -> *) a st.
(Stream s m a, HasReaderOptions st) =>
Extension -> ParsecT s st m ()
guardEnabled Extension
Ext_subscript
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 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 :: * -> *). PandocMonad m => MarkdownParser m (F Inlines)
inline) (forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
Char -> ParsecT s u m Char
char Char
'~')
mmdShortSubscript :: ParsecT Sources ParserState m [F Inlines]
mmdShortSubscript = do forall s (m :: * -> *) a st.
(Stream s m a, HasReaderOptions st) =>
Extension -> ParsecT s st m ()
guardEnabled Extension
Ext_short_subsuperscripts
Text
result <- FilePath -> 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) =>
ParsecT s u m Char
alphaNum
forall (m :: * -> *) a. Monad m => a -> m a
return forall a b. (a -> b) -> a -> b
$ forall (m :: * -> *) a. Monad m => a -> m a
return forall a b. (a -> b) -> a -> b
$ forall (m :: * -> *) a. Monad m => a -> m a
return forall a b. (a -> b) -> a -> b
$ Text -> Inlines
B.str Text
result
whitespace :: PandocMonad m => MarkdownParser m (F Inlines)
whitespace :: forall (m :: * -> *). PandocMonad m => MarkdownParser m (F Inlines)
whitespace = 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 forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (ParsecT Sources ParserState m Inlines
lb forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> forall {u}. ParsecT Sources u m Inlines
regsp) forall s u (m :: * -> *) a.
ParsecT s u m a -> FilePath -> ParsecT s u m a
<?> FilePath
"whitespace"
where lb :: ParsecT Sources ParserState m Inlines
lb = forall s (m :: * -> *) st.
(Stream s m Char, UpdateSourcePos s Char) =>
ParsecT s st m Char
spaceChar forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> forall s 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 :: * -> *) a b. Monad m => m a -> m b -> m b
>> forall s (m :: * -> *) t a u.
Stream s m t =>
a -> ParsecT s u m a -> ParsecT s u m a
option Inlines
B.space (forall (m :: * -> *). PandocMonad m => MarkdownParser m (F Inlines)
endline forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> forall (m :: * -> *) a. Monad m => a -> m a
return Inlines
B.linebreak)
regsp :: ParsecT Sources u m Inlines
regsp = 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 :: * -> *) a b. Monad m => m a -> m b -> m b
>> forall (m :: * -> *) a. Monad m => a -> m a
return Inlines
B.space
nonEndline :: PandocMonad m => ParsecT Sources st m Char
nonEndline :: forall (m :: * -> *) st. PandocMonad m => ParsecT Sources st m Char
nonEndline = 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')
str :: PandocMonad m => MarkdownParser m (F Inlines)
str :: forall (m :: * -> *). PandocMonad m => MarkdownParser m (F Inlines)
str = do
!Text
result <- 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
( FilePath -> 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) =>
ParsecT s u m Char
alphaNum)
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> Text
"." 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
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
'.')) )
forall s (m :: * -> *) a st.
(Stream s m a, HasLastStrPosition st) =>
ParsecT s st m ()
updateLastStrPos
(do forall s (m :: * -> *) a st.
(Stream s m a, HasReaderOptions st) =>
Extension -> ParsecT s st m ()
guardEnabled Extension
Ext_smart
Set Text
abbrevs <- forall st s (m :: * -> *) t b.
(HasReaderOptions st, Stream s m t) =>
(ReaderOptions -> b) -> ParsecT s st m b
getOption ReaderOptions -> Set Text
readerAbbreviations
if Text
result forall a. Ord a => a -> Set a -> Bool
`Set.member` Set Text
abbrevs
then forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try (do F Inlines
ils <- forall (m :: * -> *). PandocMonad m => MarkdownParser m (F 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 (f :: * -> *) a b. Functor f => a -> f b -> f a
<$ forall (m :: * -> *). PandocMonad m => MarkdownParser m (F Inlines)
cite 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 => MarkdownParser m (F Inlines)
note)
forall (m :: * -> *) a. Monad m => a -> m a
return forall a b. (a -> b) -> a -> b
$ do
Inlines
ils' <- F Inlines
ils
case forall a. Many a -> [a]
B.toList Inlines
ils' of
[Inline
Space] ->
forall (m :: * -> *) a. Monad m => a -> m a
return forall a b. (a -> b) -> a -> b
$! (Text -> Inlines
B.str Text
result forall a. Semigroup a => a -> a -> a
<> Text -> Inlines
B.str Text
"\160")
[Inline]
_ -> forall (m :: * -> *) a. Monad m => a -> m a
return forall a b. (a -> b) -> a -> b
$! (Text -> Inlines
B.str Text
result forall a. Semigroup a => a -> a -> a
<> Inlines
ils'))
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 (forall (m :: * -> *) a. Monad m => a -> m a
return forall a b. (a -> b) -> a -> b
$! Text -> Inlines
B.str Text
result)
else forall (m :: * -> *) a. Monad m => a -> m a
return (forall (m :: * -> *) a. Monad m => a -> m a
return forall a b. (a -> b) -> a -> b
$! Text -> Inlines
B.str Text
result))
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 (forall (m :: * -> *) a. Monad m => a -> m a
return forall a b. (a -> b) -> a -> b
$! Text -> Inlines
B.str Text
result)
endline :: PandocMonad m => MarkdownParser m (F Inlines)
endline :: forall (m :: * -> *). PandocMonad m => MarkdownParser m (F 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 (m :: * -> *) s u. Monad m => ParsecT s u m u
getState forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= forall (f :: * -> *). Alternative f => Bool -> f ()
guard forall b c a. (b -> c) -> (a -> b) -> a -> c
. ParserState -> Bool
stateAllowLineBreaks
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 => MarkdownParser m ()
inList forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> forall (m :: * -> *). PandocMonad m => MarkdownParser m ()
listStart)
forall s (m :: * -> *) a st.
(Stream s m a, HasReaderOptions st) =>
Extension -> ParsecT s st m ()
guardDisabled Extension
Ext_lists_without_preceding_blankline forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> forall s (m :: * -> *) t a u.
(Stream s m t, Show a) =>
ParsecT s u m a -> ParsecT s u m ()
notFollowedBy forall (m :: * -> *). PandocMonad m => MarkdownParser m ()
listStart
forall s (m :: * -> *) a st.
(Stream s m a, HasReaderOptions st) =>
Extension -> ParsecT s st m ()
guardEnabled Extension
Ext_blank_before_blockquote forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> forall s (m :: * -> *) t a u.
(Stream s m t, Show a) =>
ParsecT s u m a -> ParsecT s u m ()
notFollowedBy forall (m :: * -> *). PandocMonad m => MarkdownParser m Char
emailBlockQuoteStart
forall s (m :: * -> *) a st.
(Stream s m a, HasReaderOptions st) =>
Extension -> ParsecT s st m ()
guardEnabled Extension
Ext_blank_before_header forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> (forall s (m :: * -> *) t a u.
(Stream s m t, Show a) =>
ParsecT s u m a -> ParsecT s u m ()
notFollowedBy forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
Char -> ParsecT s u m Char
char forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< forall (m :: * -> *). PandocMonad m => MarkdownParser m Char
atxChar)
forall s (m :: * -> *) a st.
(Stream s m a, HasReaderOptions st) =>
Extension -> ParsecT s st m ()
guardDisabled Extension
Ext_backtick_code_blocks forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|>
forall s (m :: * -> *) t a u.
(Stream s m t, Show a) =>
ParsecT s u m a -> ParsecT s u m ()
notFollowedBy (() 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
lookAhead (forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
Char -> ParsecT s u m Char
char Char
'`') forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> forall (m :: * -> *). PandocMonad m => MarkdownParser m (F Blocks)
codeBlockFenced))
forall (m :: * -> *). PandocMonad m => MarkdownParser m ()
notFollowedByHtmlCloser
forall (m :: * -> *). PandocMonad m => MarkdownParser m ()
notFollowedByDivCloser
(forall s (m :: * -> *) t u.
(Stream s m t, Show t) =>
ParsecT s u m ()
eof forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> forall (m :: * -> *) a. Monad m => a -> m a
return forall a. Monoid a => a
mempty)
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> (forall s (m :: * -> *) a st.
(Stream s m a, HasReaderOptions st) =>
Extension -> ParsecT s st m ()
guardEnabled Extension
Ext_hard_line_breaks forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> forall (m :: * -> *) a. Monad m => a -> m a
return (forall (m :: * -> *) a. Monad m => a -> m a
return Inlines
B.linebreak))
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> (forall s (m :: * -> *) a st.
(Stream s m a, HasReaderOptions st) =>
Extension -> ParsecT s st m ()
guardEnabled Extension
Ext_ignore_line_breaks forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> forall (m :: * -> *) a. Monad m => a -> m a
return forall a. Monoid a => a
mempty)
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 ()
skipMany 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 (forall (m :: * -> *) a. Monad m => a -> m a
return Inlines
B.softbreak))
reference :: PandocMonad m => MarkdownParser m (F Inlines, Text)
reference :: forall (m :: * -> *).
PandocMonad m =>
MarkdownParser m (F Inlines, Text)
reference = do
forall s (m :: * -> *) a st.
(Stream s m a, HasReaderOptions st) =>
Extension -> ParsecT s st m ()
guardDisabled Extension
Ext_footnotes forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> forall b s (m :: * -> *) a st.
(Show b, Stream s m a) =>
ParsecT s st m b -> ParsecT s st m ()
notFollowedBy' (forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
FilePath -> ParsecT s u m FilePath
string FilePath
"[^")
forall (m :: * -> *) st a.
Monad m =>
ParsecT Sources st m a -> ParsecT Sources st m (a, Text)
withRaw forall a b. (a -> b) -> a -> b
$ forall s. Future s Inlines -> Future s Inlines
trimInlinesF forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall (m :: * -> *). PandocMonad m => MarkdownParser m (F Inlines)
inlinesInBalancedBrackets
parenthesizedChars :: PandocMonad m => MarkdownParser m Text
parenthesizedChars :: forall (m :: * -> *). PandocMonad m => MarkdownParser m Text
parenthesizedChars = do
Text
result <- forall s (m :: * -> *) st.
(Stream s m Char, UpdateSourcePos s Char) =>
Char -> Char -> ParsecT s st m Text -> ParsecT s st m Text
charsInBalanced Char
'(' Char
')' forall (m :: * -> *). PandocMonad m => MarkdownParser m Text
litChar
forall (m :: * -> *) a. Monad m => a -> m a
return forall a b. (a -> b) -> a -> b
$ Text
"(" forall a. Semigroup a => a -> a -> a
<> Text
result forall a. Semigroup a => a -> a -> a
<> Text
")"
source :: PandocMonad m => MarkdownParser m (Text, Text)
source :: forall (m :: * -> *). PandocMonad m => MarkdownParser m Target
source = do
forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
Char -> ParsecT s u m Char
char Char
'('
forall s (m :: * -> *) st.
(Stream s m Char, UpdateSourcePos s Char) =>
ParsecT s st m ()
skipSpaces
let urlChunk :: ParsecT Sources ParserState m Text
urlChunk =
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try forall (m :: * -> *). PandocMonad m => MarkdownParser m Text
parenthesizedChars
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m 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) =>
FilePath -> ParsecT s u m Char
oneOf FilePath
" )") forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> forall (m :: * -> *). PandocMonad m => MarkdownParser m Text
litChar)
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 st.
Stream s m t =>
ParsecT s st m Char -> ParsecT s st m Text
many1Char forall s (m :: * -> *) st.
(Stream s m Char, UpdateSourcePos s Char) =>
ParsecT s st m Char
spaceChar forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
<* forall s (m :: * -> *) t 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) =>
FilePath -> ParsecT s u m Char
oneOf FilePath
"\"')"))
let sourceURL :: ParsecT Sources ParserState m Text
sourceURL = [Text] -> Text
T.unwords forall b c a. (b -> c) -> (a -> b) -> a -> c
. Text -> [Text]
T.words forall b c a. (b -> c) -> (a -> b) -> a -> c
. [Text] -> Text
T.concat 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 ParsecT Sources ParserState m Text
urlChunk
let betweenAngles :: ParsecT Sources ParserState m Text
betweenAngles = 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 a. Monoid a => [a] -> a
mconcat forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (forall s (m :: * -> *) t u a sep.
Stream s m t =>
ParsecT s u m a -> ParsecT s u m sep -> ParsecT s u m [a]
manyTill forall (m :: * -> *). PandocMonad m => MarkdownParser m Text
litChar (forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
Char -> ParsecT s u m Char
char Char
'>'))
Text
src <- forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try ParsecT Sources ParserState m Text
betweenAngles forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> ParsecT Sources ParserState m Text
sourceURL
Text
tit <- forall s (m :: * -> *) t a u.
Stream s m t =>
a -> ParsecT s u m a -> ParsecT s u m a
option Text
"" 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 :: * -> *) st. PandocMonad m => ParsecT Sources st m ()
spnl forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> forall (m :: * -> *). PandocMonad m => MarkdownParser m Text
linkTitle
forall s (m :: * -> *) st.
(Stream s m Char, UpdateSourcePos s Char) =>
ParsecT s st m ()
skipSpaces
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 (Text -> Text
escapeURI forall a b. (a -> b) -> a -> b
$ Text -> Text
trimr Text
src, Text
tit)
linkTitle :: PandocMonad m => MarkdownParser m Text
linkTitle :: forall (m :: * -> *). PandocMonad m => MarkdownParser m Text
linkTitle = forall (m :: * -> *).
PandocMonad m =>
Char -> MarkdownParser m Text
quotedTitle Char
'"' forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> forall (m :: * -> *).
PandocMonad m =>
Char -> MarkdownParser m Text
quotedTitle Char
'\''
wikilink :: PandocMonad m
=> (Attr -> Text -> Text -> Inlines -> Inlines)
-> MarkdownParser m (F Inlines)
wikilink :: forall (m :: * -> *).
PandocMonad m =>
(Attr -> Text -> Text -> Inlines -> Inlines)
-> MarkdownParser m (F Inlines)
wikilink Attr -> Text -> Text -> Inlines -> Inlines
constructor =
(forall s (m :: * -> *) a st.
(Stream s m a, HasReaderOptions st) =>
Extension -> ParsecT s st m ()
guardEnabled Extension
Ext_wikilinks_title_after_pipe forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> forall {s} {m :: * -> *} {f :: * -> *} {u}.
(Stream s m Char, UpdateSourcePos s Char, Applicative f) =>
(Target -> Target) -> ParsecT s u m (f Inlines)
wikilink' forall {b} {a}. (b, a) -> (a, b)
swap) forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|>
(forall s (m :: * -> *) a st.
(Stream s m a, HasReaderOptions st) =>
Extension -> ParsecT s st m ()
guardEnabled Extension
Ext_wikilinks_title_before_pipe forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> forall {s} {m :: * -> *} {f :: * -> *} {u}.
(Stream s m Char, UpdateSourcePos s Char, Applicative f) =>
(Target -> Target) -> ParsecT s u m (f Inlines)
wikilink' forall a. a -> a
id)
where
swap :: (b, a) -> (a, b)
swap (b
a, a
b) = (a
b, b
a)
wikilink' :: (Target -> Target) -> ParsecT s u m (f Inlines)
wikilink' Target -> Target
order = 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) =>
FilePath -> ParsecT s u m FilePath
string FilePath
"[["
forall b s (m :: * -> *) a st.
(Show b, Stream s m a) =>
ParsecT s st m b -> ParsecT s st m ()
notFollowedBy' (forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
Char -> ParsecT s u m Char
char Char
'[')
Text
raw <- forall end s (m :: * -> *) t st.
(Show end, Stream s m t) =>
ParsecT s st m Char -> ParsecT s st m end -> ParsecT s st m Text
many1TillChar (forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
FilePath -> ParsecT s u m Char
noneOf FilePath
"\n\r\f\t") (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) =>
FilePath -> ParsecT s u m FilePath
string FilePath
"]]")
let (Text
title, Text
url) = case (Char -> Bool) -> Text -> Target
T.break (forall a. Eq a => a -> a -> Bool
== Char
'|') Text
raw of
(Text
before, Text
"") -> (Text
before, Text
before)
(Text
before, Text
after) -> Target -> Target
order (Text
before, Int -> Text -> Text
T.drop Int
1 Text
after)
forall (m :: * -> *) a. Monad m => a -> m a
return forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (f :: * -> *) a. Applicative f => a -> f a
pure forall b c a. (b -> c) -> (a -> b) -> a -> c
. Attr -> Text -> Text -> Inlines -> Inlines
constructor Attr
nullAttr Text
url Text
"wikilink" forall a b. (a -> b) -> a -> b
$ Text -> Inlines
B.str Text
title
link :: PandocMonad m => MarkdownParser m (F Inlines)
link :: forall (m :: * -> *). PandocMonad m => MarkdownParser m (F 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
ParserState
st <- forall (m :: * -> *) s u. Monad m => ParsecT s u m u
getState
forall (f :: * -> *). Alternative f => Bool -> f ()
guard forall a b. (a -> b) -> a -> b
$ ParserState -> Bool
stateAllowLinks ParserState
st
forall (m :: * -> *) u s. Monad m => u -> ParsecT s u m ()
setState forall a b. (a -> b) -> a -> b
$ ParserState
st{ stateAllowLinks :: Bool
stateAllowLinks = Bool
False }
(F Inlines
lab,Text
raw) <- forall (m :: * -> *).
PandocMonad m =>
MarkdownParser m (F Inlines, Text)
reference
forall (m :: * -> *) u s. Monad m => u -> ParsecT s u m ()
setState forall a b. (a -> b) -> a -> b
$ ParserState
st{ stateAllowLinks :: Bool
stateAllowLinks = Bool
True }
forall (m :: * -> *).
PandocMonad m =>
(Attr -> Text -> Text -> Inlines -> Inlines)
-> F Inlines -> MarkdownParser m (F Inlines)
regLink Attr -> Text -> Text -> Inlines -> Inlines
B.linkWith F Inlines
lab forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> forall (m :: * -> *).
PandocMonad m =>
(Attr -> Text -> Text -> Inlines -> Inlines)
-> (F Inlines, Text) -> MarkdownParser m (F Inlines)
referenceLink Attr -> Text -> Text -> Inlines -> Inlines
B.linkWith (F Inlines
lab,Text
raw)
bracketedSpan :: PandocMonad m => MarkdownParser m (F Inlines)
bracketedSpan :: forall (m :: * -> *). PandocMonad m => MarkdownParser m (F Inlines)
bracketedSpan = do
forall s (m :: * -> *) a st.
(Stream s m a, HasReaderOptions st) =>
Extension -> ParsecT s st m ()
guardEnabled Extension
Ext_bracketed_spans
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try forall a b. (a -> b) -> a -> b
$ do
(F Inlines
lab,Text
_) <- forall (m :: * -> *).
PandocMonad m =>
MarkdownParser m (F Inlines, Text)
reference
Attr
attr <- forall (m :: * -> *). PandocMonad m => MarkdownParser m Attr
attributes
forall (m :: * -> *) a. Monad m => a -> m a
return forall a b. (a -> b) -> a -> b
$ Attr -> Inlines -> Inlines
wrapSpan Attr
attr forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> F Inlines
lab
wrapSpan :: Attr -> Inlines -> Inlines
wrapSpan :: Attr -> Inlines -> Inlines
wrapSpan (Text
ident, [Text]
classes, [Target]
kvs) =
let (Maybe (Inlines -> Inlines)
initConst, [Target]
kvs') = case forall a b. Eq a => a -> [(a, b)] -> Maybe b
lookup Text
"style" [Target]
kvs of
Just Text
s | Text -> Bool
isSmallCapsFontVariant Text
s ->
let kvsNoStyle :: [Target]
kvsNoStyle = [(Text
k, Text
v) | (Text
k, Text
v) <- [Target]
kvs, Text
k forall a. Eq a => a -> a -> Bool
/= Text
"style"]
in (forall a. a -> Maybe a
Just Inlines -> Inlines
B.smallcaps, [Target]
kvsNoStyle)
Maybe Text
_ -> (forall a. Maybe a
Nothing, [Target]
kvs)
(Maybe (Inlines -> Inlines)
mConstr, [Text]
remainingClasses) = forall (t :: * -> *) a b.
Foldable t =>
(a -> b -> b) -> b -> t a -> b
foldr forall {a}.
(Eq a, IsString a) =>
a
-> (Maybe (Inlines -> Inlines), [a])
-> (Maybe (Inlines -> Inlines), [a])
go (Maybe (Inlines -> Inlines)
initConst, []) [Text]
classes
wrapInConstr :: (b -> c) -> Maybe (b -> b) -> b -> c
wrapInConstr b -> c
c = forall b a. b -> (a -> b) -> Maybe a -> b
maybe b -> c
c (b -> c
c forall b c a. (b -> c) -> (a -> b) -> a -> c
.)
go :: a
-> (Maybe (Inlines -> Inlines), [a])
-> (Maybe (Inlines -> Inlines), [a])
go a
cls (Maybe (Inlines -> Inlines)
accConstr, [a]
other) =
case a
cls of
a
"smallcaps" -> (forall a. a -> Maybe a
Just forall a b. (a -> b) -> a -> b
$ forall {b} {c}. (b -> c) -> Maybe (b -> b) -> b -> c
wrapInConstr Inlines -> Inlines
B.smallcaps Maybe (Inlines -> Inlines)
accConstr, [a]
other)
a
"ul" -> (forall a. a -> Maybe a
Just forall a b. (a -> b) -> a -> b
$ forall {b} {c}. (b -> c) -> Maybe (b -> b) -> b -> c
wrapInConstr Inlines -> Inlines
B.underline Maybe (Inlines -> Inlines)
accConstr, [a]
other)
a
"underline" -> (forall a. a -> Maybe a
Just forall a b. (a -> b) -> a -> b
$ forall {b} {c}. (b -> c) -> Maybe (b -> b) -> b -> c
wrapInConstr Inlines -> Inlines
B.underline Maybe (Inlines -> Inlines)
accConstr, [a]
other)
a
_ -> (Maybe (Inlines -> Inlines)
accConstr, a
clsforall a. a -> [a] -> [a]
:[a]
other)
in case (Text
ident, [Text]
remainingClasses, [Target]
kvs') of
(Text
"", [], []) -> forall a. a -> Maybe a -> a
fromMaybe (Attr -> Inlines -> Inlines
B.spanWith Attr
nullAttr) Maybe (Inlines -> Inlines)
mConstr
Attr
attr -> forall {b} {c}. (b -> c) -> Maybe (b -> b) -> b -> c
wrapInConstr (Attr -> Inlines -> Inlines
B.spanWith Attr
attr) Maybe (Inlines -> Inlines)
mConstr
isSmallCapsFontVariant :: Text -> Bool
isSmallCapsFontVariant :: Text -> Bool
isSmallCapsFontVariant Text
s =
Text -> Text
T.toLower ((Char -> Bool) -> Text -> Text
T.filter (forall (t :: * -> *) a. (Foldable t, Eq a) => a -> t a -> Bool
`notElem` [Char
' ', Char
'\t', Char
';']) Text
s) forall a. Eq a => a -> a -> Bool
==
Text
"font-variant:small-caps"
regLink :: PandocMonad m
=> (Attr -> Text -> Text -> Inlines -> Inlines)
-> F Inlines
-> MarkdownParser m (F Inlines)
regLink :: forall (m :: * -> *).
PandocMonad m =>
(Attr -> Text -> Text -> Inlines -> Inlines)
-> F Inlines -> MarkdownParser m (F Inlines)
regLink Attr -> Text -> Text -> Inlines -> Inlines
constructor F Inlines
lab = forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try forall a b. (a -> b) -> a -> b
$ do
(!Text
src, !Text
tit) <- forall (m :: * -> *). PandocMonad m => MarkdownParser m Target
source
Bool
rebase <- 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 s (m :: * -> *) a st.
(Stream s m a, HasReaderOptions st) =>
Extension -> ParsecT s st m ()
guardEnabled Extension
Ext_rebase_relative_paths)
SourcePos
pos <- forall (m :: * -> *) s u. Monad m => ParsecT s u m SourcePos
getPosition
let !src' :: Text
src' = if Bool
rebase then SourcePos -> Text -> Text
rebasePath SourcePos
pos Text
src else Text
src
!Attr
attr <- forall s (m :: * -> *) t a u.
Stream s m t =>
a -> ParsecT s u m a -> ParsecT s u m a
option Attr
nullAttr forall a b. (a -> b) -> a -> b
$ forall s (m :: * -> *) a st.
(Stream s m a, HasReaderOptions st) =>
Extension -> ParsecT s st m ()
guardEnabled Extension
Ext_link_attributes forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> forall (m :: * -> *). PandocMonad m => MarkdownParser m Attr
attributes
forall (m :: * -> *) a. Monad m => a -> m a
return forall a b. (a -> b) -> a -> b
$ Attr -> Text -> Text -> Inlines -> Inlines
constructor Attr
attr Text
src' Text
tit forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> F Inlines
lab
referenceLink :: PandocMonad m
=> (Attr -> Text -> Text -> Inlines -> Inlines)
-> (F Inlines, Text)
-> MarkdownParser m (F Inlines)
referenceLink :: forall (m :: * -> *).
PandocMonad m =>
(Attr -> Text -> Text -> Inlines -> Inlines)
-> (F Inlines, Text) -> MarkdownParser m (F Inlines)
referenceLink Attr -> Text -> Text -> Inlines -> Inlines
constructor (F Inlines
lab, Text
raw) = do
Bool
sp <- (Bool
True 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
lookAhead (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
(F Inlines
_,!Text
raw') <- 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, Text
"") forall a b. (a -> b) -> a -> b
$
forall s (m :: * -> *) t u a.
Stream s m t =>
ParsecT s u m a -> ParsecT s u m a
lookAhead (forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try (do forall s (m :: * -> *) a st.
(Stream s m a, HasReaderOptions st) =>
Extension -> ParsecT s st m ()
guardEnabled Extension
Ext_citations
forall s (m :: * -> *) a st.
(Stream s m a, HasReaderOptions st) =>
Extension -> ParsecT s st m ()
guardDisabled Extension
Ext_spaced_reference_links forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> forall (m :: * -> *) st. PandocMonad m => ParsecT Sources st m ()
spnl
forall (m :: * -> *).
PandocMonad m =>
MarkdownParser m (F [Citation])
normalCite
forall (m :: * -> *) a. Monad m => a -> m a
return (forall a. Monoid a => a
mempty, Text
"")))
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 :: * -> *) a st.
(Stream s m a, HasReaderOptions st) =>
Extension -> ParsecT s st m ()
guardDisabled Extension
Ext_spaced_reference_links forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> forall (m :: * -> *) st. PandocMonad m => ParsecT Sources st m ()
spnl) forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> forall (m :: * -> *).
PandocMonad m =>
MarkdownParser m (F Inlines, Text)
reference)
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
when (Text
raw' forall a. Eq a => a -> a -> Bool
== Text
"") forall a b. (a -> b) -> a -> b
$ forall s (m :: * -> *) a st.
(Stream s m a, HasReaderOptions st) =>
Extension -> ParsecT s st m ()
guardEnabled Extension
Ext_shortcut_reference_links
let !labIsRef :: Bool
labIsRef = Text
raw' forall a. Eq a => a -> a -> Bool
== Text
"" Bool -> Bool -> Bool
|| Text
raw' forall a. Eq a => a -> a -> Bool
== Text
"[]"
let (Bool
exclam, Text
rawsuffix) =
case Text -> Maybe (Char, Text)
T.uncons Text
raw of
Just (Char
'!', Text
rest) -> (Bool
True, Text
rest)
Maybe (Char, Text)
_ -> (Bool
False, Text
raw)
let !key :: Key
key = Text -> Key
toKey forall a b. (a -> b) -> a -> b
$ if Bool
labIsRef then Text
rawsuffix else Text
raw'
F Inlines
parsedRaw <- forall (m :: * -> *) u a.
(Monad m, HasLastStrPosition u) =>
ParsecT Sources u m a -> Text -> ParsecT Sources u m a
parseFromString' forall (m :: * -> *). PandocMonad m => MarkdownParser m (F Inlines)
inlines Text
raw'
F Inlines
fallback <- forall (m :: * -> *) u a.
(Monad m, HasLastStrPosition u) =>
ParsecT Sources u m a -> Text -> ParsecT Sources u m a
parseFromString' forall (m :: * -> *). PandocMonad m => MarkdownParser m (F Inlines)
inlines forall a b. (a -> b) -> a -> b
$ if Bool
exclam
then Text
rawsuffix
else Text -> Text
dropBrackets Text
rawsuffix
Bool
implicitHeaderRefs <- forall s (m :: * -> *) t a u.
Stream s m t =>
a -> ParsecT s u m a -> ParsecT s u m a
option Bool
False forall a b. (a -> b) -> a -> b
$
Bool
True forall (f :: * -> *) a b. Functor f => a -> f b -> f a
<$ forall s (m :: * -> *) a st.
(Stream s m a, HasReaderOptions st) =>
Extension -> ParsecT s st m ()
guardEnabled Extension
Ext_implicit_header_references
let makeFallback :: F Inlines
makeFallback = do
Inlines
parsedRaw' <- F Inlines
parsedRaw
Inlines
fallback' <- F Inlines
fallback
forall (m :: * -> *) a. Monad m => a -> m a
return forall a b. (a -> b) -> a -> b
$ (if Bool
exclam
then Inlines
"!" forall a. Semigroup a => a -> a -> a
<> Inlines
fallback'
else Text -> Inlines
B.str Text
"[" forall a. Semigroup a => a -> a -> a
<> Inlines
fallback' forall a. Semigroup a => a -> a -> a
<> Text -> Inlines
B.str Text
"]") forall a. Semigroup a => a -> a -> a
<>
(if Bool
sp Bool -> Bool -> Bool
&& Bool -> Bool
not (Text -> Bool
T.null Text
raw) then Inlines
B.space else forall a. Monoid a => a
mempty) forall a. Semigroup a => a -> a -> a
<>
Inlines
parsedRaw'
forall (m :: * -> *) a. Monad m => a -> m a
return forall a b. (a -> b) -> a -> b
$ do
KeyTable
keys <- forall s a. (s -> a) -> Future s a
asksF ParserState -> KeyTable
stateKeys
case forall k a. Ord k => k -> Map k a -> Maybe a
M.lookup Key
key KeyTable
keys of
Maybe (Target, Attr)
Nothing ->
if Bool
implicitHeaderRefs
then do
KeyTable
headerKeys <- forall s a. (s -> a) -> Future s a
asksF ParserState -> KeyTable
stateHeaderKeys
case forall k a. Ord k => k -> Map k a -> Maybe a
M.lookup Key
key KeyTable
headerKeys of
Just ((Text
src, Text
tit), Attr
_) -> Attr -> Text -> Text -> Inlines -> Inlines
constructor Attr
nullAttr Text
src Text
tit forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> F Inlines
lab
Maybe (Target, Attr)
Nothing -> F Inlines
makeFallback
else F Inlines
makeFallback
Just ((Text
src,Text
tit), Attr
attr) ->
Attr -> Text -> Text -> Inlines -> Inlines
constructor Attr
attr Text
src Text
tit forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> F Inlines
lab
dropBrackets :: Text -> Text
dropBrackets :: Text -> Text
dropBrackets = Text -> Text
dropRB forall b c a. (b -> c) -> (a -> b) -> a -> c
. Text -> Text
dropLB
where dropRB :: Text -> Text
dropRB (Text -> Maybe (Text, Char)
T.unsnoc -> Just (Text
xs,Char
']')) = Text
xs
dropRB Text
xs = Text
xs
dropLB :: Text -> Text
dropLB (Text -> Maybe (Char, Text)
T.uncons -> Just (Char
'[',Text
xs)) = Text
xs
dropLB Text
xs = Text
xs
bareURL :: PandocMonad m => MarkdownParser m (F Inlines)
bareURL :: forall (m :: * -> *). PandocMonad m => MarkdownParser m (F Inlines)
bareURL = do
forall s (m :: * -> *) a st.
(Stream s m a, HasReaderOptions st) =>
Extension -> ParsecT s st m ()
guardEnabled Extension
Ext_autolink_bare_uris
forall (m :: * -> *) s u. Monad m => ParsecT s u m u
getState forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= forall (f :: * -> *). Alternative f => Bool -> f ()
guard forall b c a. (b -> c) -> (a -> b) -> a -> c
. ParserState -> Bool
stateAllowLinks
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try forall a b. (a -> b) -> a -> b
$ do
(Text
cls, (Text
orig, Text
src)) <- ((Text
"uri",) 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 Target
uri) forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> ((Text
"email",) 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 Target
emailAddress)
forall s (m :: * -> *) t a u.
(Stream s m t, Show a) =>
ParsecT s u m a -> ParsecT s u m ()
notFollowedBy 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) =>
ParsecT s u m ()
spaces forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> forall st (m :: * -> *).
(HasReaderOptions st, Monad m) =>
(Tag Text -> Bool) -> ParsecT Sources st m (Tag Text, Text)
htmlTag (forall str t. (StringLike str, TagRep t) => Tag str -> t -> Bool
~== forall str. str -> Tag str
TagClose (Text
"a" :: Text))
forall (m :: * -> *) a. Monad m => a -> m a
return forall a b. (a -> b) -> a -> b
$ forall (m :: * -> *) a. Monad m => a -> m a
return forall a b. (a -> b) -> a -> b
$ Attr -> Text -> Text -> Inlines -> Inlines
B.linkWith (Text
"",[Text
cls],[]) Text
src Text
"" (Text -> Inlines
B.str Text
orig)
autoLink :: PandocMonad m => MarkdownParser m (F Inlines)
autoLink :: forall (m :: * -> *). PandocMonad m => MarkdownParser m (F Inlines)
autoLink = 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 => ParsecT s u m u
getState forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= forall (f :: * -> *). Alternative f => Bool -> f ()
guard forall b c a. (b -> c) -> (a -> b) -> a -> c
. ParserState -> Bool
stateAllowLinks
forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
Char -> ParsecT s u m Char
char Char
'<'
(Text
cls, (Text
orig, Text
src)) <- ((Text
"uri",) 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 Target
uri) forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> ((Text
"email",) 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 Target
emailAddress)
Text
extra <- Text -> Text
fromEntities forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall s (m :: * -> *) t st a.
Stream s m t =>
ParsecT s st m Char -> ParsecT s st m a -> ParsecT s st m Text
manyTillChar forall 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
'>')
Attr
attr <- forall s (m :: * -> *) t a u.
Stream s m t =>
a -> ParsecT s u m a -> ParsecT s u m a
option (Text
"", [Text
cls], []) 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 s (m :: * -> *) a st.
(Stream s m a, HasReaderOptions st) =>
Extension -> ParsecT s st m ()
guardEnabled Extension
Ext_link_attributes forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> forall (m :: * -> *). PandocMonad m => MarkdownParser m Attr
attributes
forall (m :: * -> *) a. Monad m => a -> m a
return forall a b. (a -> b) -> a -> b
$ forall (m :: * -> *) a. Monad m => a -> m a
return forall a b. (a -> b) -> a -> b
$ Attr -> Text -> Text -> Inlines -> Inlines
B.linkWith Attr
attr (Text
src forall a. Semigroup a => a -> a -> a
<> Text -> Text
escapeURI Text
extra) Text
""
(Text -> Inlines
B.str forall a b. (a -> b) -> a -> b
$ Text
orig forall a. Semigroup a => a -> a -> a
<> Text
extra)
rebasePath :: SourcePos -> Text -> Text
rebasePath :: SourcePos -> Text -> Text
rebasePath SourcePos
pos Text
path = do
let fp :: FilePath
fp = SourcePos -> FilePath
sourceName SourcePos
pos
isFragment :: Bool
isFragment = Int -> Text -> Text
T.take Int
1 Text
path forall a. Eq a => a -> a -> Bool
== Text
"#"
path' :: FilePath
path' = Text -> FilePath
T.unpack Text
path
isAbsolutePath :: Bool
isAbsolutePath = FilePath -> Bool
Posix.isAbsolute FilePath
path' Bool -> Bool -> Bool
|| FilePath -> Bool
Windows.isAbsolute FilePath
path'
in if Text -> Bool
T.null Text
path Bool -> Bool -> Bool
|| Bool
isFragment Bool -> Bool -> Bool
|| Bool
isAbsolutePath Bool -> Bool -> Bool
|| Text -> Bool
isURI Text
path
then Text
path
else
case FilePath -> FilePath
takeDirectory FilePath
fp of
FilePath
"" -> Text
path
FilePath
"." -> Text
path
FilePath
d -> FilePath -> Text
T.pack FilePath
d forall a. Semigroup a => a -> a -> a
<> Text
"/" forall a. Semigroup a => a -> a -> a
<> Text
path
image :: PandocMonad m => MarkdownParser m (F Inlines)
image :: forall (m :: * -> *). PandocMonad m => MarkdownParser m (F 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 :: * -> *).
PandocMonad m =>
(Attr -> Text -> Text -> Inlines -> Inlines)
-> MarkdownParser m (F Inlines)
wikilink Attr -> Text -> Text -> Inlines -> Inlines
B.imageWith forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|>
do (F Inlines
lab,Text
raw) <- forall (m :: * -> *).
PandocMonad m =>
MarkdownParser m (F Inlines, Text)
reference
Text
defaultExt <- forall st s (m :: * -> *) t b.
(HasReaderOptions st, Stream s m t) =>
(ReaderOptions -> b) -> ParsecT s st m b
getOption ReaderOptions -> Text
readerDefaultImageExtension
let constructor :: Attr -> Text -> Text -> Inlines -> Inlines
constructor Attr
attr' Text
src =
case FilePath -> FilePath
takeExtension (Text -> FilePath
T.unpack Text
src) of
FilePath
"" -> Attr -> Text -> Text -> Inlines -> Inlines
B.imageWith Attr
attr' (FilePath -> Text
T.pack forall a b. (a -> b) -> a -> b
$ FilePath -> FilePath -> FilePath
addExtension (Text -> FilePath
T.unpack Text
src)
forall a b. (a -> b) -> a -> b
$ Text -> FilePath
T.unpack Text
defaultExt)
FilePath
_ -> Attr -> Text -> Text -> Inlines -> Inlines
B.imageWith Attr
attr' Text
src
forall (m :: * -> *).
PandocMonad m =>
(Attr -> Text -> Text -> Inlines -> Inlines)
-> F Inlines -> MarkdownParser m (F Inlines)
regLink Attr -> Text -> Text -> Inlines -> Inlines
constructor F Inlines
lab forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> forall (m :: * -> *).
PandocMonad m =>
(Attr -> Text -> Text -> Inlines -> Inlines)
-> (F Inlines, Text) -> MarkdownParser m (F Inlines)
referenceLink Attr -> Text -> Text -> Inlines -> Inlines
constructor (F Inlines
lab, Text
"!" forall a. Semigroup a => a -> a -> a
<> Text
raw)
note :: PandocMonad m => MarkdownParser m (F Inlines)
note :: forall (m :: * -> *). PandocMonad m => MarkdownParser m (F 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
forall s (m :: * -> *) a st.
(Stream s m a, HasReaderOptions st) =>
Extension -> ParsecT s st m ()
guardEnabled Extension
Ext_footnotes
Text
ref <- forall (m :: * -> *). PandocMonad m => MarkdownParser m Text
noteMarker
forall (m :: * -> *) u s. Monad m => (u -> u) -> ParsecT s u m ()
updateState forall a b. (a -> b) -> a -> b
$ \ParserState
st -> ParserState
st{ stateNoteRefs :: Set Text
stateNoteRefs = forall a. Ord a => a -> Set a -> Set a
Set.insert Text
ref (ParserState -> Set Text
stateNoteRefs ParserState
st)
, stateNoteNumber :: Int
stateNoteNumber = ParserState -> Int
stateNoteNumber ParserState
st forall a. Num a => a -> a -> a
+ Int
1 }
Int
noteNum <- ParserState -> Int
stateNoteNumber forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> 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
$ do
NoteTable'
notes <- forall s a. (s -> a) -> Future s a
asksF ParserState -> NoteTable'
stateNotes'
case forall k a. Ord k => k -> Map k a -> Maybe a
M.lookup Text
ref NoteTable'
notes of
Maybe (SourcePos, F Blocks)
Nothing -> forall (m :: * -> *) a. Monad m => a -> m a
return forall a b. (a -> b) -> a -> b
$ Text -> Inlines
B.str forall a b. (a -> b) -> a -> b
$ Text
"[^" forall a. Semigroup a => a -> a -> a
<> Text
ref forall a. Semigroup a => a -> a -> a
<> Text
"]"
Just (SourcePos
_pos, F Blocks
contents) -> do
ParserState
st <- forall s. Future s s
askF
let contents' :: Blocks
contents' = forall s a. Future s a -> s -> a
runF F Blocks
contents ParserState
st{ stateNotes' :: NoteTable'
stateNotes' = forall k a. Map k a
M.empty }
let addCitationNoteNum :: Citation -> Citation
addCitationNoteNum c :: Citation
c@Citation{} =
Citation
c{ citationNoteNum :: Int
citationNoteNum = Int
noteNum }
let adjustCite :: Inline -> Inline
adjustCite (Cite [Citation]
cs [Inline]
ils) =
[Citation] -> [Inline] -> Inline
Cite (forall a b. (a -> b) -> [a] -> [b]
map Citation -> Citation
addCitationNoteNum [Citation]
cs) [Inline]
ils
adjustCite Inline
x = Inline
x
forall (m :: * -> *) a. Monad m => a -> m a
return forall a b. (a -> b) -> a -> b
$ Blocks -> Inlines
B.note forall a b. (a -> b) -> a -> b
$ forall a b. Walkable a b => (a -> a) -> b -> b
walk Inline -> Inline
adjustCite Blocks
contents'
inlineNote :: PandocMonad m => MarkdownParser m (F Inlines)
inlineNote :: forall (m :: * -> *). PandocMonad m => MarkdownParser m (F Inlines)
inlineNote = do
forall s (m :: * -> *) a st.
(Stream s m a, HasReaderOptions st) =>
Extension -> ParsecT s st m ()
guardEnabled Extension
Ext_inline_notes
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 :: * -> *) u s. Monad m => (u -> u) -> ParsecT s u m ()
updateState forall a b. (a -> b) -> a -> b
$ \ParserState
st -> ParserState
st{ stateInNote :: Bool
stateInNote = Bool
True
, stateNoteNumber :: Int
stateNoteNumber = ParserState -> Int
stateNoteNumber ParserState
st forall a. Num a => a -> a -> a
+ Int
1 }
F Inlines
contents <- forall (m :: * -> *). PandocMonad m => MarkdownParser m (F Inlines)
inlinesInBalancedBrackets
forall (m :: * -> *) u s. Monad m => (u -> u) -> ParsecT s u m ()
updateState forall a b. (a -> b) -> a -> b
$ \ParserState
st -> ParserState
st{ stateInNote :: Bool
stateInNote = Bool
False }
forall (m :: * -> *) a. Monad m => a -> m a
return forall a b. (a -> b) -> a -> b
$ Blocks -> Inlines
B.note forall b c a. (b -> c) -> (a -> b) -> a -> c
. Inlines -> Blocks
B.para forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> F Inlines
contents
rawLaTeXInline' :: PandocMonad m => MarkdownParser m (F Inlines)
rawLaTeXInline' :: forall (m :: * -> *). PandocMonad m => MarkdownParser m (F Inlines)
rawLaTeXInline' = do
forall s (m :: * -> *) a st.
(Stream s m a, HasReaderOptions st) =>
Extension -> ParsecT s st m ()
guardEnabled Extension
Ext_raw_tex
forall b s (m :: * -> *) a st.
(Show b, Stream s m a) =>
ParsecT s st m b -> ParsecT s st m ()
notFollowedBy' forall (m :: * -> *) st. PandocMonad m => ParsecT Sources st m Text
rawConTeXtEnvironment
!Text
s <- forall (m :: * -> *) s.
(PandocMonad m, HasMacros s, HasReaderOptions s) =>
ParsecT Sources s m Text
rawLaTeXInline
forall (m :: * -> *) a. Monad m => a -> m a
return forall a b. (a -> b) -> a -> b
$ forall (m :: * -> *) a. Monad m => a -> m a
return forall a b. (a -> b) -> a -> b
$ Text -> Text -> Inlines
B.rawInline Text
"tex" Text
s
rawConTeXtEnvironment :: PandocMonad m => ParsecT Sources st m Text
rawConTeXtEnvironment :: forall (m :: * -> *) st. PandocMonad m => ParsecT Sources st m Text
rawConTeXtEnvironment = 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) =>
FilePath -> ParsecT s u m FilePath
string FilePath
"\\start"
Text
completion <- forall (m :: * -> *) st.
PandocMonad m =>
ParsecT Sources st m Char -> ParsecT Sources st m Text
inBrackets (forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
ParsecT s u m Char
letter 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
digit forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> forall s (m :: * -> *) st.
(Stream s m Char, UpdateSourcePos s Char) =>
ParsecT s st m Char
spaceChar)
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> forall s (m :: * -> *) t st.
Stream s m t =>
ParsecT s st m Char -> ParsecT s st m Text
many1Char forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
ParsecT s u m Char
letter
![Text]
contents <- forall s (m :: * -> *) t u a sep.
Stream s m t =>
ParsecT s u m a -> ParsecT s u m sep -> ParsecT s u m [a]
manyTill (forall (m :: * -> *) st. PandocMonad m => ParsecT Sources st m Text
rawConTeXtEnvironment forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> forall s (m :: * -> *) st.
(Stream s m Char, UpdateSourcePos s Char, Monad m) =>
Int -> ParsecT s st m Char -> ParsecT s st m Text
countChar Int
1 forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
ParsecT s u m Char
anyChar)
(forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try forall a b. (a -> b) -> a -> b
$ forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
FilePath -> ParsecT s u m FilePath
string FilePath
"\\stop" forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> forall s (m :: * -> *) u.
(Stream s m Char, UpdateSourcePos s Char) =>
Text -> ParsecT s u m Text
textStr Text
completion)
forall (m :: * -> *) a. Monad m => a -> m a
return forall a b. (a -> b) -> a -> b
$! Text
"\\start" forall a. Semigroup a => a -> a -> a
<> Text
completion forall a. Semigroup a => a -> a -> a
<> [Text] -> Text
T.concat [Text]
contents forall a. Semigroup a => a -> a -> a
<> Text
"\\stop" forall a. Semigroup a => a -> a -> a
<> Text
completion
inBrackets :: PandocMonad m => ParsecT Sources st m Char -> ParsecT Sources st m Text
inBrackets :: forall (m :: * -> *) st.
PandocMonad m =>
ParsecT Sources st m Char -> ParsecT Sources st m Text
inBrackets ParsecT Sources st m Char
parser = do
forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
Char -> ParsecT s u m Char
char Char
'['
Text
contents <- forall s (m :: * -> *) t st.
Stream s m t =>
ParsecT s st m Char -> ParsecT s st m Text
manyChar ParsecT Sources st m Char
parser
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
"[" forall a. Semigroup a => a -> a -> a
<> Text
contents forall a. Semigroup a => a -> a -> a
<> Text
"]"
spanHtml :: PandocMonad m => MarkdownParser m (F Inlines)
spanHtml :: forall (m :: * -> *). PandocMonad m => MarkdownParser m (F Inlines)
spanHtml = do
forall s (m :: * -> *) a st.
(Stream s m a, HasReaderOptions st) =>
Extension -> ParsecT s st m ()
guardEnabled Extension
Ext_native_spans
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try forall a b. (a -> b) -> a -> b
$ do
(TagOpen Text
_ [Target]
attrs, Text
_) <- forall st (m :: * -> *).
(HasReaderOptions st, Monad m) =>
(Tag Text -> Bool) -> ParsecT Sources st m (Tag Text, Text)
htmlTag (forall str t. (StringLike str, TagRep t) => Tag str -> t -> Bool
~== forall str. str -> [Attribute str] -> Tag str
TagOpen (Text
"span" :: Text) [])
F Inlines
contents <- forall a. Monoid a => [a] -> a
mconcat forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall s (m :: * -> *) t u a sep.
Stream s m t =>
ParsecT s u m a -> ParsecT s u m sep -> ParsecT s u m [a]
manyTill forall (m :: * -> *). PandocMonad m => MarkdownParser m (F Inlines)
inline (forall st (m :: * -> *).
(HasReaderOptions st, Monad m) =>
(Tag Text -> Bool) -> ParsecT Sources st m (Tag Text, Text)
htmlTag (forall str t. (StringLike str, TagRep t) => Tag str -> t -> Bool
~== forall str. str -> Tag str
TagClose (Text
"span" :: Text)))
let ident :: Text
ident = forall a. a -> Maybe a -> a
fromMaybe Text
"" forall a b. (a -> b) -> a -> b
$ forall a b. Eq a => a -> [(a, b)] -> Maybe b
lookup Text
"id" [Target]
attrs
let classes :: [Text]
classes = forall b a. b -> (a -> b) -> Maybe a -> b
maybe [] Text -> [Text]
T.words forall a b. (a -> b) -> a -> b
$ forall a b. Eq a => a -> [(a, b)] -> Maybe b
lookup Text
"class" [Target]
attrs
let keyvals :: [Target]
keyvals = [(Text
k,Text
v) | (Text
k,Text
v) <- [Target]
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 -> Inlines -> Inlines
wrapSpan (Text
ident, [Text]
classes, [Target]
keyvals) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> F Inlines
contents
divHtml :: PandocMonad m => MarkdownParser m (F Blocks)
divHtml :: forall (m :: * -> *). PandocMonad m => MarkdownParser m (F Blocks)
divHtml = do
forall s (m :: * -> *) a st.
(Stream s m a, HasReaderOptions st) =>
Extension -> ParsecT s st m ()
guardEnabled Extension
Ext_native_divs
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try forall a b. (a -> b) -> a -> b
$ do
(TagOpen Text
_ [Target]
attrs, Text
rawtag) <- forall st (m :: * -> *).
(HasReaderOptions st, Monad m) =>
(Tag Text -> Bool) -> ParsecT Sources st m (Tag Text, Text)
htmlTag (forall str t. (StringLike str, TagRep t) => Tag str -> t -> Bool
~== forall str. str -> [Attribute str] -> Tag str
TagOpen (Text
"div" :: Text) [])
Maybe Text
oldInHtmlBlock <- ParserState -> Maybe Text
stateInHtmlBlock forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall (m :: * -> *) s u. Monad m => ParsecT s u m u
getState
forall (m :: * -> *) u s. Monad m => (u -> u) -> ParsecT s u m ()
updateState forall a b. (a -> b) -> a -> b
$ \ParserState
st -> ParserState
st{ stateInHtmlBlock :: Maybe Text
stateInHtmlBlock = forall a. a -> Maybe a
Just Text
"div" }
Text
bls <- forall s (m :: * -> *) t a u.
Stream s m t =>
a -> ParsecT s u m a -> ParsecT s u m a
option Text
"" (forall s (m :: * -> *) st.
(Stream s m Char, UpdateSourcePos s Char) =>
ParsecT s st m Char
blankline forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> forall s (m :: * -> *) t a u.
Stream s m t =>
a -> ParsecT s u m a -> ParsecT s u m a
option Text
"" forall s (m :: * -> *) st.
(Stream s m Char, UpdateSourcePos s Char) =>
ParsecT s st m Text
blanklines)
F Blocks
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 (forall b s (m :: * -> *) a st.
(Show b, Stream s m a) =>
ParsecT s st m b -> ParsecT s st m ()
notFollowedBy' (forall st (m :: * -> *).
(HasReaderOptions st, Monad m) =>
(Tag Text -> Bool) -> ParsecT Sources st m (Tag Text, Text)
htmlTag (forall str t. (StringLike str, TagRep t) => Tag str -> t -> Bool
~== forall str. str -> Tag str
TagClose (Text
"div" :: Text)))
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> forall (m :: * -> *). PandocMonad m => MarkdownParser m (F Blocks)
block)
Bool
closed <- 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 st (m :: * -> *).
(HasReaderOptions st, Monad m) =>
(Tag Text -> Bool) -> ParsecT Sources st m (Tag Text, Text)
htmlTag (forall str t. (StringLike str, TagRep t) => Tag str -> t -> Bool
~== forall str. str -> Tag str
TagClose (Text
"div" :: Text)))
if Bool
closed
then do
forall (m :: * -> *) u s. Monad m => (u -> u) -> ParsecT s u m ()
updateState forall a b. (a -> b) -> a -> b
$ \ParserState
st -> ParserState
st{ stateInHtmlBlock :: Maybe Text
stateInHtmlBlock = Maybe Text
oldInHtmlBlock }
let ident :: Text
ident = forall a. a -> Maybe a -> a
fromMaybe Text
"" forall a b. (a -> b) -> a -> b
$ forall a b. Eq a => a -> [(a, b)] -> Maybe b
lookup Text
"id" [Target]
attrs
let classes :: [Text]
classes = forall b a. b -> (a -> b) -> Maybe a -> b
maybe [] Text -> [Text]
T.words forall a b. (a -> b) -> a -> b
$ forall a b. Eq a => a -> [(a, b)] -> Maybe b
lookup Text
"class" [Target]
attrs
let keyvals :: [Target]
keyvals = [(Text
k,Text
v) | (Text
k,Text
v) <- [Target]
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 -> Blocks -> Blocks
B.divWith (Text
ident, [Text]
classes, [Target]
keyvals) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> F Blocks
contents
else
forall (m :: * -> *) a. Monad m => a -> m a
return forall a b. (a -> b) -> a -> b
$ forall (m :: * -> *) a. Monad m => a -> m a
return (Text -> Text -> Blocks
B.rawBlock Text
"html" (Text
rawtag forall a. Semigroup a => a -> a -> a
<> Text
bls)) forall a. Semigroup a => a -> a -> a
<> F Blocks
contents
divFenced :: PandocMonad m => MarkdownParser m (F Blocks)
divFenced :: forall (m :: * -> *). PandocMonad m => MarkdownParser m (F Blocks)
divFenced = do
forall s (m :: * -> *) a st.
(Stream s m a, HasReaderOptions st) =>
Extension -> ParsecT s st m ()
guardEnabled Extension
Ext_fenced_divs
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) =>
FilePath -> ParsecT s u m FilePath
string FilePath
":::"
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m ()
skipMany (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 ()
skipMany forall s (m :: * -> *) st.
(Stream s m Char, UpdateSourcePos s Char) =>
ParsecT s st m Char
spaceChar
Attr
attribs <- forall (m :: * -> *). PandocMonad m => MarkdownParser m Attr
attributes forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> ((\Text
x -> (Text
"",[Text
x],[])) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall s (m :: * -> *) t st.
Stream s m t =>
ParsecT s st m Char -> ParsecT s st m Text
many1Char forall s (m :: * -> *) st.
(Stream s m Char, UpdateSourcePos s Char) =>
ParsecT s st m Char
nonspaceChar)
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 ()
skipMany (forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
Char -> ParsecT s u m Char
char Char
':')
forall s (m :: * -> *) st.
(Stream s m Char, UpdateSourcePos s Char) =>
ParsecT s st m Char
blankline
forall (m :: * -> *) u s. Monad m => (u -> u) -> ParsecT s u m ()
updateState forall a b. (a -> b) -> a -> b
$ \ParserState
st ->
ParserState
st{ stateFencedDivLevel :: Int
stateFencedDivLevel = ParserState -> Int
stateFencedDivLevel ParserState
st forall a. Num a => a -> a -> a
+ Int
1 }
F Blocks
bs <- 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 sep.
Stream s m t =>
ParsecT s u m a -> ParsecT s u m sep -> ParsecT s u m [a]
manyTill forall (m :: * -> *). PandocMonad m => MarkdownParser m (F Blocks)
block forall (m :: * -> *). PandocMonad m => MarkdownParser m ()
divFenceEnd
forall (m :: * -> *) u s. Monad m => (u -> u) -> ParsecT s u m ()
updateState forall a b. (a -> b) -> a -> b
$ \ParserState
st ->
ParserState
st{ stateFencedDivLevel :: Int
stateFencedDivLevel = ParserState -> Int
stateFencedDivLevel ParserState
st 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
$ Attr -> Blocks -> Blocks
B.divWith Attr
attribs forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> F Blocks
bs
divFenceEnd :: PandocMonad m => MarkdownParser m ()
divFenceEnd :: forall (m :: * -> *). PandocMonad m => MarkdownParser m ()
divFenceEnd = 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) =>
FilePath -> ParsecT s u m FilePath
string FilePath
":::"
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m ()
skipMany (forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
Char -> ParsecT s u m Char
char Char
':')
forall s (m :: * -> *) st.
(Stream s m Char, UpdateSourcePos s Char) =>
ParsecT s st m Text
blanklines
forall (m :: * -> *) a. Monad m => a -> m a
return ()
rawHtmlInline :: PandocMonad m => MarkdownParser m (F Inlines)
rawHtmlInline :: forall (m :: * -> *). PandocMonad m => MarkdownParser m (F Inlines)
rawHtmlInline = do
forall s (m :: * -> *) a st.
(Stream s m a, HasReaderOptions st) =>
Extension -> ParsecT s st m ()
guardEnabled Extension
Ext_raw_html
Maybe Text
inHtmlBlock <- ParserState -> Maybe Text
stateInHtmlBlock forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall (m :: * -> *) s u. Monad m => ParsecT s u m u
getState
let isCloseBlockTag :: Tag str -> Bool
isCloseBlockTag Tag str
t = case Maybe Text
inHtmlBlock of
Just Text
t' -> Tag str
t forall str t. (StringLike str, TagRep t) => Tag str -> t -> Bool
~== forall str. str -> Tag str
TagClose Text
t'
Maybe Text
Nothing -> Bool
False
Bool
mdInHtml <- forall s (m :: * -> *) t a u.
Stream s m t =>
a -> ParsecT s u m a -> ParsecT s u m a
option Bool
False forall a b. (a -> b) -> a -> b
$
( forall s (m :: * -> *) a st.
(Stream s m a, HasReaderOptions st) =>
Extension -> ParsecT s st m ()
guardEnabled Extension
Ext_markdown_in_html_blocks
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> forall s (m :: * -> *) a st.
(Stream s m a, HasReaderOptions st) =>
Extension -> ParsecT s st m ()
guardEnabled Extension
Ext_markdown_attribute
) forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> forall (m :: * -> *) a. Monad m => a -> m a
return Bool
True
(Tag Text
_,Text
result) <- 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
$ if Bool
mdInHtml
then (\Tag Text
x -> Tag Text -> Bool
isInlineTag Tag Text
x Bool -> Bool -> Bool
&&
Bool -> Bool
not (forall {str}. StringLike str => Tag str -> Bool
isCloseBlockTag Tag Text
x))
else Bool -> Bool
not forall b c a. (b -> c) -> (a -> b) -> a -> c
. Tag Text -> Bool
isTextTag
forall (m :: * -> *) a. Monad m => a -> m a
return forall a b. (a -> b) -> a -> b
$ forall (m :: * -> *) a. Monad m => a -> m a
return forall a b. (a -> b) -> a -> b
$ Text -> Text -> Inlines
B.rawInline Text
"html" Text
result
emoji :: PandocMonad m => MarkdownParser m (F Inlines)
emoji :: forall (m :: * -> *). PandocMonad m => MarkdownParser m (F Inlines)
emoji = do
forall s (m :: * -> *) a st.
(Stream s m a, HasReaderOptions st) =>
Extension -> ParsecT s st m ()
guardEnabled Extension
Ext_emoji
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
emojikey <- forall s (m :: * -> *) t st.
Stream s m t =>
ParsecT s st m Char -> ParsecT s st m Text
many1Char (forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
ParsecT s u m Char
alphaNum 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) =>
FilePath -> ParsecT s u m Char
oneOf FilePath
"_+-")
forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
Char -> ParsecT s u m Char
char Char
':'
case Text -> Maybe Inline
emojiToInline Text
emojikey of
Just Inline
i -> forall (m :: * -> *) a. Monad m => a -> m a
return (forall (m :: * -> *) a. Monad m => a -> m a
return forall a b. (a -> b) -> a -> b
$ forall a. a -> Many a
B.singleton Inline
i)
Maybe Inline
Nothing -> forall (m :: * -> *) a. MonadPlus m => m a
mzero
cite :: PandocMonad m => MarkdownParser m (F Inlines)
cite :: forall (m :: * -> *). PandocMonad m => MarkdownParser m (F Inlines)
cite = do
forall s (m :: * -> *) a st.
(Stream s m a, HasReaderOptions st) =>
Extension -> ParsecT s st m ()
guardEnabled Extension
Ext_citations
Bool
inNote <- ParserState -> Bool
stateInNote forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall (m :: * -> *) s u. Monad m => ParsecT s u m u
getState
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
unless Bool
inNote forall a b. (a -> b) -> a -> b
$
forall (m :: * -> *) u s. Monad m => (u -> u) -> ParsecT s u m ()
updateState forall a b. (a -> b) -> a -> b
$ \ParserState
st -> ParserState
st{ stateNoteNumber :: Int
stateNoteNumber = ParserState -> Int
stateNoteNumber ParserState
st forall a. Num a => a -> a -> a
+ Int
1 }
forall (m :: * -> *). PandocMonad m => MarkdownParser m (F Inlines)
textualCite
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> do (F [Citation]
cs, Text
raw) <- forall (m :: * -> *) st a.
Monad m =>
ParsecT Sources st m a -> ParsecT Sources st m (a, Text)
withRaw forall (m :: * -> *).
PandocMonad m =>
MarkdownParser m (F [Citation])
normalCite
forall (m :: * -> *) a. Monad m => a -> m a
return forall a b. (a -> b) -> a -> b
$ forall a b c. (a -> b -> c) -> b -> a -> c
flip [Citation] -> Inlines -> Inlines
B.cite (Text -> Inlines
B.text Text
raw) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> F [Citation]
cs
textualCite :: PandocMonad m => MarkdownParser m (F Inlines)
textualCite :: forall (m :: * -> *). PandocMonad m => MarkdownParser m (F Inlines)
textualCite = 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
suppressAuthor, Text
key) <- forall s (m :: * -> *) st.
(Stream s m Char, UpdateSourcePos s Char, HasLastStrPosition st) =>
Bool -> ParsecT s st m (Bool, Text)
citeKey Bool
True
forall (m :: * -> *) s u. Monad m => ParsecT s u m u
getState forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= forall (f :: * -> *). Alternative f => Bool -> f ()
guard forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. Maybe a -> Bool
isNothing forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall k a. Ord k => k -> Map k a -> Maybe a
M.lookup Text
key forall b c a. (b -> c) -> (a -> b) -> a -> c
. ParserState -> Map Text Int
stateExamples
Int
noteNum <- ParserState -> Int
stateNoteNumber forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall (m :: * -> *) s u. Monad m => ParsecT s u m u
getState
let first :: Citation
first = Citation{ citationId :: Text
citationId = Text
key
, citationPrefix :: [Inline]
citationPrefix = []
, citationSuffix :: [Inline]
citationSuffix = []
, citationMode :: CitationMode
citationMode = if Bool
suppressAuthor
then CitationMode
SuppressAuthor
else CitationMode
AuthorInText
, citationNoteNum :: Int
citationNoteNum = Int
noteNum
, citationHash :: Int
citationHash = Int
0
}
(do
(F [Citation]
cs, Text
raw) <- forall (m :: * -> *) st a.
Monad m =>
ParsecT Sources st m a -> ParsecT Sources st m (a, Text)
withRaw forall a b. (a -> b) -> a -> b
$
(forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (Citation
firstforall a. a -> [a] -> [a]
:) 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 :: * -> *) st. PandocMonad m => ParsecT Sources st m ()
spnl forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> forall (m :: * -> *).
PandocMonad m =>
MarkdownParser m (F [Citation])
normalCite))
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> forall (m :: * -> *).
PandocMonad m =>
Citation -> MarkdownParser m (F [Citation])
bareloc Citation
first
let (Text
spaces',Text
raw') = (Char -> Bool) -> Text -> Target
T.span Char -> Bool
isSpace Text
raw
spc :: Inlines
spc | Text -> Bool
T.null Text
spaces' = forall a. Monoid a => a
mempty
| Bool
otherwise = Inlines
B.space
F Inlines
lab <- forall (m :: * -> *) u a.
(Monad m, HasLastStrPosition u) =>
ParsecT Sources u m a -> Text -> ParsecT Sources u m a
parseFromString' forall (m :: * -> *). PandocMonad m => MarkdownParser m (F Inlines)
inlines forall a b. (a -> b) -> a -> b
$ Text -> Text
dropBrackets Text
raw'
F Inlines
fallback <- forall (m :: * -> *).
PandocMonad m =>
(Attr -> Text -> Text -> Inlines -> Inlines)
-> (F Inlines, Text) -> MarkdownParser m (F Inlines)
referenceLink Attr -> Text -> Text -> Inlines -> Inlines
B.linkWith (F Inlines
lab,Text
raw')
forall (m :: * -> *) u s. Monad m => (u -> u) -> ParsecT s u m ()
updateState forall a b. (a -> b) -> a -> b
$ \ParserState
st -> ParserState
st{ stateNoteNumber :: Int
stateNoteNumber = Int
noteNum }
forall (m :: * -> *) a. Monad m => a -> m a
return forall a b. (a -> b) -> a -> b
$ do
Inlines
fallback' <- F Inlines
fallback
[Citation]
cs' <- F [Citation]
cs
forall (m :: * -> *) a. Monad m => a -> m a
return forall a b. (a -> b) -> a -> b
$
case forall a. Many a -> [a]
B.toList Inlines
fallback' of
Link{}:[Inline]
_ -> [Citation] -> Inlines -> Inlines
B.cite [Citation
first] (Text -> Inlines
B.str forall a b. (a -> b) -> a -> b
$ Text
"@" forall a. Semigroup a => a -> a -> a
<> Text
key) forall a. Semigroup a => a -> a -> a
<> Inlines
spc forall a. Semigroup a => a -> a -> a
<> Inlines
fallback'
[Inline]
_ -> [Citation] -> Inlines -> Inlines
B.cite [Citation]
cs' (Text -> Inlines
B.text forall a b. (a -> b) -> a -> b
$ Text
"@" forall a. Semigroup a => a -> a -> a
<> Text
key forall a. Semigroup a => a -> a -> a
<> Text
" " forall a. Semigroup a => a -> a -> a
<> Text
raw))
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 (do ParserState
st <- forall s. Future s s
askF
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 (ParserState -> Map Text Int
stateExamples ParserState
st) of
Just Int
n -> Text -> Inlines
B.str forall a b. (a -> b) -> a -> b
$ forall a. Show a => a -> Text
tshow Int
n
Maybe Int
_ -> [Citation] -> Inlines -> Inlines
B.cite [Citation
first] forall a b. (a -> b) -> a -> b
$ Text -> Inlines
B.str forall a b. (a -> b) -> a -> b
$ Text
"@" forall a. Semigroup a => a -> a -> a
<> Text
key)
bareloc :: PandocMonad m => Citation -> MarkdownParser m (F [Citation])
bareloc :: forall (m :: * -> *).
PandocMonad m =>
Citation -> MarkdownParser m (F [Citation])
bareloc Citation
c = 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 :: * -> *) st. PandocMonad m => ParsecT Sources st m ()
spnl
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 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
'^'
F Inlines
suff <- forall (m :: * -> *). PandocMonad m => MarkdownParser m (F Inlines)
suffix
F [Citation]
rest <- forall s (m :: * -> *) t a u.
Stream s m t =>
a -> ParsecT s u m a -> ParsecT s u m a
option (forall (m :: * -> *) a. Monad m => a -> m a
return []) 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 (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> forall (m :: * -> *) st. PandocMonad m => ParsecT Sources st m ()
spnl forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> forall (m :: * -> *).
PandocMonad m =>
MarkdownParser m (F [Citation])
citeList
forall (m :: * -> *) st. PandocMonad m => ParsecT Sources st m ()
spnl
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 a b. (a -> b) -> a -> b
$ forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
FilePath -> ParsecT s u m Char
oneOf FilePath
"[("
forall (m :: * -> *) a. Monad m => a -> m a
return forall a b. (a -> b) -> a -> b
$ do
Inlines
suff' <- F Inlines
suff
[Citation]
rest' <- F [Citation]
rest
forall (m :: * -> *) a. Monad m => a -> m a
return forall a b. (a -> b) -> a -> b
$ Citation
c{ citationSuffix :: [Inline]
citationSuffix = forall a. Many a -> [a]
B.toList Inlines
suff' } forall a. a -> [a] -> [a]
: [Citation]
rest'
normalCite :: PandocMonad m => MarkdownParser m (F [Citation])
normalCite :: forall (m :: * -> *).
PandocMonad m =>
MarkdownParser m (F [Citation])
normalCite = 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 :: * -> *) st. PandocMonad m => ParsecT Sources st m ()
spnl
F [Citation]
citations <- forall (m :: * -> *).
PandocMonad m =>
MarkdownParser m (F [Citation])
citeList
forall (m :: * -> *) st. PandocMonad m => ParsecT Sources st m ()
spnl
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 (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
FilePath -> ParsecT s u m Char
oneOf FilePath
"{([")
forall (m :: * -> *) a. Monad m => a -> m a
return F [Citation]
citations
suffix :: PandocMonad m => MarkdownParser m (F Inlines)
suffix :: forall (m :: * -> *). PandocMonad m => MarkdownParser m (F Inlines)
suffix = 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
hasSpace <- forall s (m :: * -> *) t a u.
Stream s m t =>
a -> ParsecT s u m a -> ParsecT s u m a
option Bool
False (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
nonspaceChar forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> forall (m :: * -> *) a. Monad m => a -> m a
return Bool
True)
forall (m :: * -> *) st. PandocMonad m => ParsecT Sources st m ()
spnl
F Inlines
rest <- forall s. Future s Inlines -> Future s Inlines
trimInlinesF 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 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) =>
FilePath -> ParsecT s u m Char
oneOf FilePath
";]") forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> forall (m :: * -> *). PandocMonad m => MarkdownParser m (F Inlines)
inline)
forall (m :: * -> *) a. Monad m => a -> m a
return forall a b. (a -> b) -> a -> b
$ if Bool
hasSpace
then (Inlines
B.space forall a. Semigroup a => a -> a -> a
<>) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> F Inlines
rest
else F Inlines
rest
prefix :: PandocMonad m => MarkdownParser m (F Inlines)
prefix :: forall (m :: * -> *). PandocMonad m => MarkdownParser m (F Inlines)
prefix = forall s. Future s Inlines -> Future s Inlines
trimInlinesF 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 sep.
Stream s m t =>
ParsecT s u m a -> ParsecT s u m sep -> 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) =>
Char -> ParsecT s u m Char
char Char
';') forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> forall (m :: * -> *). PandocMonad m => MarkdownParser m (F Inlines)
inline) (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 s (m :: * -> *) t u a.
Stream s m t =>
ParsecT s u m a -> ParsecT s u m a
lookAhead
(forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
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 s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try (forall (m :: * -> *) s u.
(Monad m, Stream s m Char, UpdateSourcePos s Char) =>
Char -> ParsecT s u m Char
char Char
';' forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> forall (m :: * -> *) st. PandocMonad m => ParsecT Sources st m ()
spnl))
forall s (m :: * -> *) st.
(Stream s m Char, UpdateSourcePos s Char, HasLastStrPosition st) =>
Bool -> ParsecT s st m (Bool, Text)
citeKey Bool
True
forall (m :: * -> *) a. Monad m => a -> m a
return Char
']'))
citeList :: PandocMonad m => MarkdownParser m (F [Citation])
citeList :: forall (m :: * -> *).
PandocMonad m =>
MarkdownParser m (F [Citation])
citeList = forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap forall (t :: * -> *) (m :: * -> *) a.
(Traversable t, Monad m) =>
t (m a) -> m (t a)
sequence forall a b. (a -> b) -> a -> b
$ forall s (m :: * -> *) t u a sep.
Stream s m t =>
ParsecT s u m a -> ParsecT s u m sep -> ParsecT s u m [a]
sepBy1 forall (m :: * -> *).
PandocMonad m =>
MarkdownParser m (F Citation)
citation (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 :: * -> *) st. PandocMonad m => ParsecT Sources st m ()
spnl)
citation :: PandocMonad m => MarkdownParser m (F Citation)
citation :: forall (m :: * -> *).
PandocMonad m =>
MarkdownParser m (F Citation)
citation = forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try forall a b. (a -> b) -> a -> b
$ do
F Inlines
pref <- forall (m :: * -> *). PandocMonad m => MarkdownParser m (F Inlines)
prefix
(Bool
suppress_author, Text
key) <- forall s (m :: * -> *) st.
(Stream s m Char, UpdateSourcePos s Char, HasLastStrPosition st) =>
Bool -> ParsecT s st m (Bool, Text)
citeKey Bool
True
F Inlines
suff <- forall (m :: * -> *). PandocMonad m => MarkdownParser m (F Inlines)
suffix
Int
noteNum <- ParserState -> Int
stateNoteNumber forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> 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
$ do
Inlines
x <- F Inlines
pref
Inlines
y <- F Inlines
suff
forall (m :: * -> *) a. Monad m => a -> m a
return Citation{ citationId :: Text
citationId = Text
key
, citationPrefix :: [Inline]
citationPrefix = forall a. Many a -> [a]
B.toList Inlines
x
, citationSuffix :: [Inline]
citationSuffix = forall a. Many a -> [a]
B.toList Inlines
y
, citationMode :: CitationMode
citationMode = if Bool
suppress_author
then CitationMode
SuppressAuthor
else CitationMode
NormalCitation
, citationNoteNum :: Int
citationNoteNum = Int
noteNum
, citationHash :: Int
citationHash = Int
0
}
smart :: PandocMonad m => MarkdownParser m (F Inlines)
smart :: forall (m :: * -> *). PandocMonad m => MarkdownParser m (F Inlines)
smart = do
forall s (m :: * -> *) a st.
(Stream s m a, HasReaderOptions st) =>
Extension -> ParsecT s st m ()
guardEnabled Extension
Ext_smart
forall (m :: * -> *). PandocMonad m => MarkdownParser m (F Inlines)
doubleQuoted forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> forall (m :: * -> *). PandocMonad m => MarkdownParser m (F Inlines)
singleQuoted 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 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 Inlines
doubleCloseQuote) 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 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 Inlines
apostrophe) 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 forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall st s (m :: * -> *).
(HasReaderOptions st, Stream s m Char, UpdateSourcePos s Char) =>
ParsecT s st m Inlines
dash) 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 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 Inlines
ellipses)
singleQuoted :: PandocMonad m => MarkdownParser m (F Inlines)
singleQuoted :: forall (m :: * -> *). PandocMonad m => MarkdownParser m (F Inlines)
singleQuoted = do
forall st (m :: * -> *) s.
(HasLastStrPosition st, HasQuoteContext st m, Stream s m Char,
UpdateSourcePos s Char) =>
ParsecT s st m ()
singleQuoteStart
(forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try (forall st (m :: * -> *) s a.
HasQuoteContext st m =>
QuoteContext -> ParsecT s st m a -> ParsecT s st m a
withQuoteContext QuoteContext
InSingleQuote forall a b. (a -> b) -> a -> b
$
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap Inlines -> Inlines
B.singleQuoted forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall s. Future s Inlines -> Future s Inlines
trimInlinesF 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 => MarkdownParser m (F Inlines)
inline forall s (m :: * -> *) st.
(Stream s m Char, UpdateSourcePos s Char) =>
ParsecT s st m ()
singleQuoteEnd))
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 (forall (m :: * -> *) a. Monad m => a -> m a
return (Text -> Inlines
B.str Text
"\8217")))
doubleQuoted :: PandocMonad m => MarkdownParser m (F Inlines)
doubleQuoted :: forall (m :: * -> *). PandocMonad m => MarkdownParser m (F Inlines)
doubleQuoted = do
forall st (m :: * -> *) s.
(HasLastStrPosition st, HasQuoteContext st m, Stream s m Char,
UpdateSourcePos s Char) =>
ParsecT s st m ()
doubleQuoteStart
(forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try (forall st (m :: * -> *) s a.
HasQuoteContext st m =>
QuoteContext -> ParsecT s st m a -> ParsecT s st m a
withQuoteContext QuoteContext
InDoubleQuote forall a b. (a -> b) -> a -> b
$
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap Inlines -> Inlines
B.doubleQuoted forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall s. Future s Inlines -> Future s Inlines
trimInlinesF 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 => MarkdownParser m (F Inlines)
inline forall s (m :: * -> *) st.
(Stream s m Char, UpdateSourcePos s Char) =>
ParsecT s st m ()
doubleQuoteEnd))
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 (forall (m :: * -> *) a. Monad m => a -> m a
return (Text -> Inlines
B.str Text
"\8220")))