From 02e515cada735d83a870404c6c51ef15a9beef37 Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Thu, 25 Oct 2018 00:16:35 -0700 Subject: Groff reader: got `\f[]` working properly. --- src/Text/Pandoc/Readers/Groff.hs | 11 +++++++---- src/Text/Pandoc/Readers/Man.hs | 1 + 2 files changed, 8 insertions(+), 4 deletions(-) (limited to 'src/Text') diff --git a/src/Text/Pandoc/Readers/Groff.hs b/src/Text/Pandoc/Readers/Groff.hs index e63272682..4b92bd85a 100644 --- a/src/Text/Pandoc/Readers/Groff.hs +++ b/src/Text/Pandoc/Readers/Groff.hs @@ -105,7 +105,8 @@ singleTok :: ManToken -> ManTokens singleTok t = ManTokens (Seq.singleton t) data RoffState = RoffState { customMacros :: M.Map String ManTokens - , lastFont :: FontSpec + , prevFont :: FontSpec + , currentFont :: FontSpec } deriving Show instance Default RoffState where @@ -117,7 +118,8 @@ instance Default RoffState where , ("lq", "\x201C") , ("rq", "\x201D") , ("R", "\x00AE") ] - , lastFont = defaultFontSpec + , prevFont = defaultFontSpec + , currentFont = defaultFontSpec } type ManLexer m = ParserT [Char] RoffState m @@ -261,7 +263,8 @@ escFont = do , ($ defaultFontSpec) <$> letterFontKind , lettersFont ] - modifyState $ \st -> st{ lastFont = font } + modifyState $ \st -> st{ prevFont = currentFont st + , currentFont = font } return [Font font] lettersFont :: PandocMonad m => ManLexer m FontSpec @@ -271,7 +274,7 @@ lettersFont = try $ do skipMany letter char ']' if null fs - then lastFont <$> getState + then prevFont <$> getState else return $ foldr ($) defaultFontSpec fs letterFontKind :: PandocMonad m => ManLexer m (FontSpec -> FontSpec) diff --git a/src/Text/Pandoc/Readers/Man.hs b/src/Text/Pandoc/Readers/Man.hs index 6fa9e4f94..8dda237ba 100644 --- a/src/Text/Pandoc/Readers/Man.hs +++ b/src/Text/Pandoc/Readers/Man.hs @@ -180,6 +180,7 @@ linePartsToInlines = go False go :: Bool -> [LinePart] -> Inlines go _ [] = mempty go mono (MacroArg _:xs) = go mono xs -- shouldn't happen + go mono (RoffStr s : RoffStr t : xs) = go mono (RoffStr (s <> t):xs) go mono (RoffStr s : xs) | mono = code s <> go mono xs | otherwise = text s <> go mono xs -- cgit v1.2.3