aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2018-10-21 12:57:57 -0700
committerJohn MacFarlane <jgm@berkeley.edu>2018-10-21 12:57:57 -0700
commit0ac43ab2a88dd156c6d39380edff4283e954119c (patch)
tree15585fe72bb7ebad1582dd40c2185d84e95e43ba /src
parent6b553c2e2204d82a627847679bf56db062f1750a (diff)
downloadpandoc-0ac43ab2a88dd156c6d39380edff4283e954119c.tar.gz
Man reader: moved all lexer functions to the front.
Diffstat (limited to 'src')
-rw-r--r--src/Text/Pandoc/Readers/Man.hs58
1 files changed, 29 insertions, 29 deletions
diff --git a/src/Text/Pandoc/Readers/Man.hs b/src/Text/Pandoc/Readers/Man.hs
index 9cffb10e8..a47181692 100644
--- a/src/Text/Pandoc/Readers/Man.hs
+++ b/src/Text/Pandoc/Readers/Man.hs
@@ -137,36 +137,9 @@ readMan opts txt = do
mapLeft _ (Right r) = Right r
--
--- String -> ManToken function
+-- Lexer: String -> ManToken
--
-manToken :: PandocMonad m => ManLexer m ManTokens
-manToken = lexComment <|> lexMacro <|> lexLine <|> lexEmptyLine
-
-parseMan :: PandocMonad m => ManParser m Pandoc
-parseMan = do
- bs <- many parseBlock <* eof
- meta <- metadata <$> getState
- let (Pandoc _ blocks) = doc $ mconcat bs
- return $ Pandoc meta blocks
-
-parseBlock :: PandocMonad m => ManParser m Blocks
-parseBlock = choice [ parseList
- , parseDefinitionList
- , parseBlockQuote
- , parseTitle
- , parseNewParagraph
- , parsePara
- , parseCodeBlock
- , parseHeader
- , skipUnkownMacro
- ]
-
-parseNewParagraph :: PandocMonad m => ManParser m Blocks
-parseNewParagraph = do
- mmacro "P" <|> mmacro "PP" <|> mmacro "LP" <|> memptyLine
- return mempty
-
eofline :: Stream s m Char => ParsecT s u m ()
eofline = void newline <|> eof
@@ -429,8 +402,35 @@ spaceTabChar = do
lexEmptyLine :: PandocMonad m => ManLexer m ManTokens
lexEmptyLine = char '\n' >> return (singleTok MEmptyLine)
+manToken :: PandocMonad m => ManLexer m ManTokens
+manToken = lexComment <|> lexMacro <|> lexLine <|> lexEmptyLine
+
+parseMan :: PandocMonad m => ManParser m Pandoc
+parseMan = do
+ bs <- many parseBlock <* eof
+ meta <- metadata <$> getState
+ let (Pandoc _ blocks) = doc $ mconcat bs
+ return $ Pandoc meta blocks
+
+parseBlock :: PandocMonad m => ManParser m Blocks
+parseBlock = choice [ parseList
+ , parseDefinitionList
+ , parseBlockQuote
+ , parseTitle
+ , parseNewParagraph
+ , parsePara
+ , parseCodeBlock
+ , parseHeader
+ , skipUnkownMacro
+ ]
+
+parseNewParagraph :: PandocMonad m => ManParser m Blocks
+parseNewParagraph = do
+ mmacro "P" <|> mmacro "PP" <|> mmacro "LP" <|> memptyLine
+ return mempty
+
--
--- ManToken parsec functions
+-- Parser: [ManToken] -> Pandoc
--
msatisfy :: (Show t, Stream s m t) => (t -> Bool) -> ParserT s st m t