diff --git a/src/Text/Pandoc/RoffChar.hs b/src/Text/Pandoc/RoffChar.hs
index feeca2ca30bd..f5a4134a1453 100644
--- a/src/Text/Pandoc/RoffChar.hs
+++ b/src/Text/Pandoc/RoffChar.hs
@@ -34,7 +34,6 @@ standardEscapes =
, ('`', "\\[ga]")
, ('^', "\\[ha]")
, ('~', "\\[ti]")
- , ('-', "\\-")
, ('\\', "\\[rs]")
, ('@', "\\[at]") -- because we use @ as a table and math delimiter
, ('\x2026', "\\&...") -- because u2026 doesn't render on tty
diff --git a/src/Text/Pandoc/Writers/Man.hs b/src/Text/Pandoc/Writers/Man.hs
index 3adf15043397..e43caa6e49e2 100644
--- a/src/Text/Pandoc/Writers/Man.hs
+++ b/src/Text/Pandoc/Writers/Man.hs
@@ -86,9 +86,9 @@ pandocToMan opts (Pandoc meta blocks) = do
Just tpl -> renderTemplate tpl context
escString :: WriterOptions -> Text -> Text
-escString opts = escapeString (if writerPreferAscii opts
- then AsciiOnly
- else AllowUTF8)
+escString opts = escapeString True (if writerPreferAscii opts
+ then AsciiOnly
+ else AllowUTF8)
-- | Return man representation of notes.
notesToMan :: PandocMonad m => WriterOptions -> [[Block]] -> StateT WriterState m (Doc Text)
diff --git a/src/Text/Pandoc/Writers/Ms.hs b/src/Text/Pandoc/Writers/Ms.hs
index dc7fb91fe0b5..e2c97044f36f 100644
--- a/src/Text/Pandoc/Writers/Ms.hs
+++ b/src/Text/Pandoc/Writers/Ms.hs
@@ -92,7 +92,7 @@ pandocToMs opts (Pandoc meta blocks) = do
escapeStr :: WriterOptions -> Text -> Text
escapeStr opts =
- escapeString (if writerPreferAscii opts then AsciiOnly else AllowUTF8)
+ escapeString False (if writerPreferAscii opts then AsciiOnly else AllowUTF8)
-- In PDFs we need to escape parentheses and backslash.
-- In PDF we need to encode as UTF-16 BE.
diff --git a/src/Text/Pandoc/Writers/Roff.hs b/src/Text/Pandoc/Writers/Roff.hs
index 989c028267fb..9a891b7a1843 100644
--- a/src/Text/Pandoc/Writers/Roff.hs
+++ b/src/Text/Pandoc/Writers/Roff.hs
@@ -74,13 +74,18 @@ combiningAccentsMap = Map.fromList combiningAccents
essentialEscapes :: Map.Map Char Text
essentialEscapes = Map.fromList standardEscapes
--- | Escape special characters for roff.
-escapeString :: EscapeMode -> Text -> Text
-escapeString e = Text.concat . escapeString' e . Text.unpack
+-- | Escape special characters for roff. If the first parameter is
+-- True, escape @-@ as @\-@, as required by current versions of groff man;
+-- otherwise leave it unescaped, as neededfor ms.
+escapeString :: Bool -> EscapeMode -> Text -> Text
+escapeString escapeHyphen e = Text.concat . escapeString' e . Text.unpack
where
escapeString' _ [] = []
escapeString' escapeMode ('\n':'.':xs) =
"\n\\&." : escapeString' escapeMode xs
+ -- see #10533; we need to escape hyphens as \- in man but not in ms:
+ escapeString' escapeMode ('-':xs) | escapeHyphen =
+ "\\-" : escapeString' escapeMode xs
escapeString' escapeMode (x:xs) =
case Map.lookup x essentialEscapes of
Just s -> s : escapeString' escapeMode xs
diff --git a/test/writer.ms b/test/writer.ms
index 38530829d588..f6a0ac468b94 100644
--- a/test/writer.ms
+++ b/test/writer.ms
@@ -134,7 +134,7 @@ Here\[cq]s a regular paragraph.
In Markdown 1.0.0 and earlier.
Version 8.
This line turns into a list item.
-Because a hard\-wrapped line in the middle of a paragraph looked like a list
+Because a hard-wrapped line in the middle of a paragraph looked like a list
item.
.PP
Here\[cq]s one with a bullet.
@@ -149,7 +149,7 @@ Block Quotes
.pdfhref O 1 "Block Quotes"
.pdfhref M "block-quotes"
.LP
-E\-mail style:
+E-mail style:
.QS
.LP
This is a block quote.
@@ -197,7 +197,7 @@ Code:
.IP
.nf
\f[C]
-\-\-\-\- (should be four hyphens)
+---- (should be four hyphens)
sub status {
print \[dq]working\[dq];
@@ -605,7 +605,7 @@ Code block:
.IP
.nf
\f[C]
-
+
\f[]
.fi
.LP
@@ -695,7 +695,7 @@ LaTeX
.IP \[bu] 3
@223@
.IP \[bu] 3
-@p@\-Tree
+@p@-Tree
.IP \[bu] 3
Here\[cq]s some display math:
.EQ
@@ -765,7 +765,7 @@ Left paren: (
.PP
Right paren: )
.PP
-Greater\-than: >
+Greater-than: >
.PP
Hash: #
.PP
@@ -775,7 +775,7 @@ Bang: !
.PP
Plus: +
.PP
-Minus: \-
+Minus: -
.HLINE
.SH 1
Links
@@ -925,7 +925,7 @@ In a list?
.IP \[bu] 3
It should.
.LP
-An e\-mail address: \c
+An e-mail address: \c
.pdfhref W -D "mailto:nobody%40nowhere.net" -A "\c" \
-- "nobody\[at]nowhere.net"
\&
@@ -937,7 +937,7 @@ Blockquoted: \c
\&
.QE
.LP
-Auto\-links should not occur here: \f[CR]\f[R]
+Auto-links should not occur here: \f[CR]\f[R]
.IP
.nf
\f[C]