diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/Text/Pandoc/Readers/Man.hs | 58 |
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 |