Skip to content

Commit 02e515c

Browse files
committed
Groff reader: got \f[] working properly.
1 parent 718a947 commit 02e515c

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

src/Text/Pandoc/Readers/Groff.hs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,8 @@ singleTok :: ManToken -> ManTokens
105105
singleTok t = ManTokens (Seq.singleton t)
106106

107107
data RoffState = RoffState { customMacros :: M.Map String ManTokens
108-
, lastFont :: FontSpec
108+
, prevFont :: FontSpec
109+
, currentFont :: FontSpec
109110
} deriving Show
110111

111112
instance Default RoffState where
@@ -117,7 +118,8 @@ instance Default RoffState where
117118
, ("lq", "\x201C")
118119
, ("rq", "\x201D")
119120
, ("R", "\x00AE") ]
120-
, lastFont = defaultFontSpec
121+
, prevFont = defaultFontSpec
122+
, currentFont = defaultFontSpec
121123
}
122124

123125
type ManLexer m = ParserT [Char] RoffState m
@@ -261,7 +263,8 @@ escFont = do
261263
, ($ defaultFontSpec) <$> letterFontKind
262264
, lettersFont
263265
]
264-
modifyState $ \st -> st{ lastFont = font }
266+
modifyState $ \st -> st{ prevFont = currentFont st
267+
, currentFont = font }
265268
return [Font font]
266269

267270
lettersFont :: PandocMonad m => ManLexer m FontSpec
@@ -271,7 +274,7 @@ lettersFont = try $ do
271274
skipMany letter
272275
char ']'
273276
if null fs
274-
then lastFont <$> getState
277+
then prevFont <$> getState
275278
else return $ foldr ($) defaultFontSpec fs
276279

277280
letterFontKind :: PandocMonad m => ManLexer m (FontSpec -> FontSpec)

src/Text/Pandoc/Readers/Man.hs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,7 @@ linePartsToInlines = go False
180180
go :: Bool -> [LinePart] -> Inlines
181181
go _ [] = mempty
182182
go mono (MacroArg _:xs) = go mono xs -- shouldn't happen
183+
go mono (RoffStr s : RoffStr t : xs) = go mono (RoffStr (s <> t):xs)
183184
go mono (RoffStr s : xs)
184185
| mono = code s <> go mono xs
185186
| otherwise = text s <> go mono xs

0 commit comments

Comments
 (0)