From 574f9250a795f7baf7a470613b41bd6ff1b3b683 Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Fri, 19 Oct 2018 16:09:56 -0700 Subject: Man reader: got rid of MUnknownMacro and simplified code. --- src/Text/Pandoc/Readers/Man.hs | 25 ++++--------------------- 1 file changed, 4 insertions(+), 21 deletions(-) diff --git a/src/Text/Pandoc/Readers/Man.hs b/src/Text/Pandoc/Readers/Man.hs index 4a1be17e7..f8f984562 100644 --- a/src/Text/Pandoc/Readers/Man.hs +++ b/src/Text/Pandoc/Readers/Man.hs @@ -74,7 +74,6 @@ data ManToken = MStr RoffStr | MEmptyLine | MHeader Int [RoffStr] | MMacro MacroKind [RoffStr] - | MUnknownMacro String [RoffStr] | MComment String deriving Show @@ -387,8 +386,8 @@ mmaybeLink = msatisfy isMMaybeLink where isMMaybeLink (MMaybeLink _) = True isMMaybeLink _ = False -memplyLine :: PandocMonad m => ManParser m ManToken -memplyLine = msatisfy isMEmptyLine where +memptyLine :: PandocMonad m => ManParser m ManToken +memptyLine = msatisfy isMEmptyLine where isMEmptyLine MEmptyLine = True isMEmptyLine _ = False @@ -408,11 +407,6 @@ mmacroAny = msatisfy isMMacro where isMMacro (MMacro _ _) = True isMMacro _ = False -munknownMacro :: PandocMonad m => ManParser m ManToken -munknownMacro = msatisfy isMUnknownMacro where - isMUnknownMacro (MUnknownMacro _ _) = True - isMUnknownMacro _ = False - mcomment :: PandocMonad m => ManParser m ManToken mcomment = msatisfy isMComment where isMComment (MComment _) = True @@ -439,18 +433,7 @@ parseTitle = do pst {stateMeta = metaUp} parseSkippedContent :: PandocMonad m => ManParser m Blocks -parseSkippedContent = do - tok <- munknownMacro <|> mcomment <|> memplyLine - onToken tok - return mempty - - where - - onToken :: PandocMonad m => ManToken -> ManParser m () - onToken (MUnknownMacro mname _) = do - pos <- getPosition - report $ SkippedContent ("Unknown macro: " ++ mname) pos - onToken _ = return () +parseSkippedContent = mempty <$ (mcomment <|> memptyLine) strToInlines :: RoffStr -> Inlines strToInlines (s, fonts) = inner $ S.toList fonts where @@ -514,7 +497,7 @@ parseInlines = do parseCodeBlock :: PandocMonad m => ManParser m Blocks parseCodeBlock = do mmacro "nf" - toks <- many (mstr <|> mline <|> mmaybeLink <|> memplyLine <|> munknownMacro <|> mcomment) + toks <- many (mstr <|> mline <|> mmaybeLink <|> memptyLine <|> mcomment) mmacro "fi" return $ codeBlock (removeFinalNewline $ intercalate "\n" . catMaybes $ -- cgit v1.2.3