diff options
author | John MacFarlane <jgm@berkeley.edu> | 2018-10-25 00:16:35 -0700 |
---|---|---|
committer | John MacFarlane <jgm@berkeley.edu> | 2018-10-25 00:16:35 -0700 |
commit | 02e515cada735d83a870404c6c51ef15a9beef37 (patch) | |
tree | 690a58b2aca6ae8a33dcf5dea8e5da828db1a527 /src/Text/Pandoc/Readers | |
parent | 718a947f7da2e242f6a0232b826a28172234a1ad (diff) | |
download | pandoc-02e515cada735d83a870404c6c51ef15a9beef37.tar.gz |
Groff reader: got `\f[]` working properly.
Diffstat (limited to 'src/Text/Pandoc/Readers')
-rw-r--r-- | src/Text/Pandoc/Readers/Groff.hs | 11 | ||||
-rw-r--r-- | src/Text/Pandoc/Readers/Man.hs | 1 |
2 files changed, 8 insertions, 4 deletions
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 |