aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/Text/Pandoc/Readers/Roff.hs12
-rw-r--r--test/command/5039.md27
2 files changed, 33 insertions, 6 deletions
diff --git a/src/Text/Pandoc/Readers/Roff.hs b/src/Text/Pandoc/Readers/Roff.hs
index fdf9a7f06..0559bab42 100644
--- a/src/Text/Pandoc/Readers/Roff.hs
+++ b/src/Text/Pandoc/Readers/Roff.hs
@@ -212,6 +212,7 @@ readUnicodeChar _ = Nothing
escapeNormal :: PandocMonad m => RoffLexer m [LinePart]
escapeNormal = do
c <- anyChar
+ optional expandString
case c of
' ' -> return [RoffStr " "]
'"' -> mempty <$ skipMany (satisfy (/='\n')) -- line comment
@@ -313,13 +314,12 @@ signedNumber = try $ do
-- Parses: [..] or (..
escapeArg :: PandocMonad m => RoffLexer m String
escapeArg = choice
- [ char '[' *> manyTill (expanding $ noneOf ['\n',']']) (char ']')
- , char '(' *> count 2 (expanding $ satisfy (/='\n'))
+ [ char '[' *> optional expandString *>
+ manyTill (noneOf ['\n',']']) (char ']')
+ , char '(' *> optional expandString *>
+ count 2 (satisfy (/='\n'))
]
-expanding :: PandocMonad m => RoffLexer m a -> RoffLexer m a
-expanding parser = try $ optional expandString >> parser
-
expandString :: PandocMonad m => RoffLexer m ()
expandString = try $ do
pos <- getPosition
@@ -336,7 +336,7 @@ quoteArg = char '\'' *> manyTill (noneOf ['\n','\'']) (char '\'')
escFont :: PandocMonad m => RoffLexer m [LinePart]
escFont = do
- font <- expanding (escapeArg <|> count 1 alphaNum)
+ font <- escapeArg <|> count 1 alphaNum
font' <- if null font || font == "P"
then prevFont <$> getState
else return $ foldr processFontLetter defaultFontSpec font
diff --git a/test/command/5039.md b/test/command/5039.md
new file mode 100644
index 000000000..651a023b7
--- /dev/null
+++ b/test/command/5039.md
@@ -0,0 +1,27 @@
+```
+% pandoc -f man -t plain
+.ds foo bar
+.ds bar baz
+\*[\*[foo]]
+^D
+baz
+```
+
+```
+% pandoc -f man -t plain
+.ds foo [bar]
+.ds bar baz
+\*\*[foo]
+^D
+baz
+```
+
+```
+% pandoc -f man -t html
+.ds B-Font B
+.ds I-Font I
+.ds R-Font R
+\f\*[B-Font]certtool\fP
+^D
+<p><strong>certtool</strong></p>
+```