From 253467a549dcc22384be96041fd6f886c4a7a935 Mon Sep 17 00:00:00 2001
From: John MacFarlane <jgm@berkeley.edu>
Date: Sat, 15 Jan 2022 12:07:18 -0800
Subject: [PATCH] Man writer: Use boldface for inline code.

Closes #7506.

This also allows us to get rid of some special casing
on definition lists that ensured that options in code
spans would be boldface.  (If this change is ever reverted,
we'll need that again.)
---
 src/Text/Pandoc/Writers/Man.hs | 11 +++--------
 test/command/3568.md           |  4 ++--
 test/command/5620.md           |  3 ++-
 test/writer.man                | 17 +++++++++--------
 4 files changed, 16 insertions(+), 19 deletions(-)

diff --git a/src/Text/Pandoc/Writers/Man.hs b/src/Text/Pandoc/Writers/Man.hs
index 32c2dbd78..391d61752 100644
--- a/src/Text/Pandoc/Writers/Man.hs
+++ b/src/Text/Pandoc/Writers/Man.hs
@@ -27,7 +27,6 @@ import Text.Pandoc.Logging
 import Text.Pandoc.Options
 import Text.DocLayout
 import Text.Pandoc.Shared
-import Text.Pandoc.Walk (walk)
 import Text.Pandoc.Templates (renderTemplate)
 import Text.Pandoc.Writers.Math
 import Text.Pandoc.Writers.Shared
@@ -229,7 +228,7 @@ definitionListItemToMan :: PandocMonad m
 definitionListItemToMan opts (label, defs) = do
   -- in most man pages, option and other code in option lists is boldface,
   -- but not other things, so we try to reproduce this style:
-  labelText <- inlineListToMan opts $ makeCodeBold label
+  labelText <- inlineListToMan opts label
   contents <- if null defs
                  then return empty
                  else liftM vcat $ forM defs $ \case
@@ -247,11 +246,6 @@ definitionListItemToMan opts (label, defs) = do
                           [] -> return empty
   return $ literal ".TP" $$ nowrap labelText $$ contents
 
-makeCodeBold :: [Inline] -> [Inline]
-makeCodeBold = walk go
-  where go x@Code{} = Strong [x]
-        go x        = x
-
 -- | Convert list of Pandoc block elements to man.
 blockListToMan :: PandocMonad m
                => WriterOptions -- ^ Options
@@ -293,7 +287,8 @@ inlineToMan opts (Quoted DoubleQuote lst) = do
 inlineToMan opts (Cite _ lst) =
   inlineListToMan opts lst
 inlineToMan opts (Code _ str) =
-  withFontFeature 'C' (return (literal $ escString opts str))
+  withFontFeature 'B' $ withFontFeature 'C' $
+    return (literal $ escString opts str)
 inlineToMan opts (Str str@(T.uncons -> Just ('.',_))) =
   return $ afterBreak "\\&" <> literal (escString opts str)
 inlineToMan opts (Str str) = return $ literal $ escString opts str
diff --git a/test/command/3568.md b/test/command/3568.md
index f88c2fe9a..d5e96a61e 100644
--- a/test/command/3568.md
+++ b/test/command/3568.md
@@ -10,7 +10,7 @@ normal `code` normal.
 normal \f[I]italic \f[BI]bold in the middle\f[I] only italic\f[R]
 normal.
 .PP
-normal \f[B]bold \f[CB]code\f[B] more bold\f[R] normal.
+normal \f[B]bold \f[R]\f[C]code\f[R]\f[B] more bold\f[R] normal.
 .PP
-normal \f[C]code\f[R] normal.
+normal \f[B]\f[CB]code\f[B]\f[R] normal.
 ```
diff --git a/test/command/5620.md b/test/command/5620.md
index c48fefce1..97e0ebe82 100644
--- a/test/command/5620.md
+++ b/test/command/5620.md
@@ -5,5 +5,6 @@
 ^D
 .TP
 \f[B]\f[CB]-o\f[B]\f[R], \f[B]\f[CB]--output=\f[B]\f[R]\f[I]OUTFILE\f[R]
-Write output to \f[I]OUTFILE\f[R] instead of \f[C]stdout\f[R](3)
+Write output to \f[I]OUTFILE\f[R] instead of
+\f[B]\f[CB]stdout\f[B]\f[R](3)
 ```
diff --git a/test/writer.man b/test/writer.man
index d1d3cfd33..9cf069274 100644
--- a/test/writer.man
+++ b/test/writer.man
@@ -487,8 +487,9 @@ So is \f[B]\f[BI]this\f[B]\f[R] word.
 .PP
 So is \f[B]\f[BI]this\f[B]\f[R] word.
 .PP
-This is code: \f[C]>\f[R], \f[C]$\f[R], \f[C]\[rs]\f[R], \f[C]\[rs]$\f[R],
-\f[C]<html>\f[R].
+This is code: \f[B]\f[CB]>\f[B]\f[R], \f[B]\f[CB]$\f[B]\f[R],
+\f[B]\f[CB]\[rs]\f[B]\f[R], \f[B]\f[CB]\[rs]$\f[B]\f[R],
+\f[B]\f[CB]<html>\f[B]\f[R].
 .PP
 [STRIKEOUT:This is \f[I]strikeout\f[R].]
 .PP
@@ -512,7 +513,7 @@ So is `pine.'
 .PP
 `He said, \[lq]I want to go.\[rq]' Were you alive in the 70\[cq]s?
 .PP
-Here is some quoted `\f[C]code\f[R]' and a \[lq]quoted
+Here is some quoted `\f[B]\f[CB]code\f[B]\f[R]' and a \[lq]quoted
 link (http://example.com/?foo=1&bar=2)\[rq].
 .PP
 Some dashes: one\[em]two \[em] three\[em]four \[em] five.
@@ -545,7 +546,7 @@ Here\[cq]s one that has a line break in it:
 .PP
 These shouldn\[cq]t be math:
 .IP \[bu] 2
-To get the famous equation, write \f[C]$e = mc\[ha]2$\f[R].
+To get the famous equation, write \f[B]\f[CB]$e = mc\[ha]2$\f[B]\f[R].
 .IP \[bu] 2
 $22,000 is a \f[I]lot\f[R] of money.
 So is $34,000.
@@ -553,7 +554,7 @@ So is $34,000.
 .IP \[bu] 2
 Shoes ($20) and socks ($5).
 .IP \[bu] 2
-Escaped \f[C]$\f[R]: $73 \f[I]this should be emphasized\f[R] 23$.
+Escaped \f[B]\f[CB]$\f[B]\f[R]: $73 \f[I]this should be emphasized\f[R] 23$.
 .PP
 Here\[cq]s a LaTeX table:
 .PP
@@ -686,7 +687,7 @@ An e-mail address: <nobody@nowhere.net>
 Blockquoted: <http://example.com/>
 .RE
 .PP
-Auto-links should not occur here: \f[C]<http://example.com/>\f[R]
+Auto-links should not occur here: \f[B]\f[CB]<http://example.com/>\f[B]\f[R]
 .IP
 .nf
 \f[C]
@@ -742,8 +743,8 @@ the first line of each block.
 .SS [3]
 .PP
 This is \f[I]easier\f[R] to type.
-Inline notes may contain links (http://google.com) and \f[C]]\f[R] verbatim
-characters, as well as [bracketed text].
+Inline notes may contain links (http://google.com) and \f[B]\f[CB]]\f[B]\f[R]
+verbatim characters, as well as [bracketed text].
 .SS [4]
 .PP
 In quote.