aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn MacFarlane <[email protected]>2021-09-03 09:20:28 -0700
committerJohn MacFarlane <[email protected]>2022-01-15 12:39:19 -0800
commitc40727bfbb25d5d072a3523d9d6fb3abb7197b5a (patch)
treeaefd729d1856ac4d8bcf9f8c45ab6a050945614c
parenta1cfe04a26309b9bbbc48ee5f816530746d9bc6c (diff)
Man writer: use custom font V for inline code.
The V font is defined conditionally, so that it renders like CB in output formats that support that, and like B in those that don't (e.g. the terminal). We could just redefine C, but this would affect code blocks, too, and putting them all in boldface looks ugly, I think. Possible drawback: fragments created by pandoc's man writer will presuppose a nonstandard V font. Closes #7506. Supersedes 253467a549dcc22384be96041fd6f886c4a7a935.
-rw-r--r--data/templates/default.man8
-rw-r--r--src/Text/Pandoc/Writers/Man.hs4
-rw-r--r--src/Text/Pandoc/Writers/Roff.hs2
-rw-r--r--test/command/3568.md4
-rw-r--r--test/command/5620.md5
-rw-r--r--test/writer.man25
6 files changed, 32 insertions, 16 deletions
diff --git a/data/templates/default.man b/data/templates/default.man
index 58e078914..c752757e7 100644
--- a/data/templates/default.man
+++ b/data/templates/default.man
@@ -5,6 +5,14 @@ $if(pandoc-version)$
.\" Automatically generated by Pandoc $pandoc-version$
.\"
$endif$
+.\" Define V font for inline verbatim, using CB font in formats
+.\" that render this, and otherwise B font.
+.ie "\f[CB]x\f[]"x" \{\
+. ftr V B
+.\}
+.el \{\
+. ftr V CB
+.\}
$if(adjusting)$
.ad $adjusting$
$endif$
diff --git a/src/Text/Pandoc/Writers/Man.hs b/src/Text/Pandoc/Writers/Man.hs
index 391d61752..9371c2541 100644
--- a/src/Text/Pandoc/Writers/Man.hs
+++ b/src/Text/Pandoc/Writers/Man.hs
@@ -287,8 +287,8 @@ inlineToMan opts (Quoted DoubleQuote lst) = do
inlineToMan opts (Cite _ lst) =
inlineListToMan opts lst
inlineToMan opts (Code _ str) =
- withFontFeature 'B' $ withFontFeature 'C' $
- return (literal $ escString opts str)
+ -- note that the V font is specially defined in the default man template
+ withFontFeature 'V' (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/src/Text/Pandoc/Writers/Roff.hs b/src/Text/Pandoc/Writers/Roff.hs
index 7a951d7fe..b1978204c 100644
--- a/src/Text/Pandoc/Writers/Roff.hs
+++ b/src/Text/Pandoc/Writers/Roff.hs
@@ -55,6 +55,7 @@ defaultWriterState = WriterState{ stHasInlineMath = False
('I',False)
, ('B',False)
, ('C',False)
+ , ('V',False)
]
, stHasTables = False
}
@@ -106,6 +107,7 @@ fontChange = do
features <- gets stFontFeatures
inHeader <- gets stInHeader
let filling = ['C' | fromMaybe False $ Map.lookup 'C' features] ++
+ ['V' | fromMaybe False $ Map.lookup 'V' features] ++
['B' | inHeader ||
fromMaybe False (Map.lookup 'B' features)] ++
['I' | fromMaybe False $ Map.lookup 'I' features]
diff --git a/test/command/3568.md b/test/command/3568.md
index d5e96a61e..a6817f4c6 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[R]\f[C]code\f[R]\f[B] more bold\f[R] normal.
+normal \f[B]bold \f[VB]code\f[B] more bold\f[R] normal.
.PP
-normal \f[B]\f[CB]code\f[B]\f[R] normal.
+normal \f[V]code\f[R] normal.
```
diff --git a/test/command/5620.md b/test/command/5620.md
index 97e0ebe82..cb2635bf0 100644
--- a/test/command/5620.md
+++ b/test/command/5620.md
@@ -4,7 +4,6 @@
: Write output to *OUTFILE* instead of `stdout`(3)
^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[B]\f[CB]stdout\f[B]\f[R](3)
+\f[V]-o\f[R], \f[V]--output=\f[R]\f[I]OUTFILE\f[R]
+Write output to \f[I]OUTFILE\f[R] instead of \f[V]stdout\f[R](3)
```
diff --git a/test/writer.man b/test/writer.man
index 9cf069274..7828e6083 100644
--- a/test/writer.man
+++ b/test/writer.man
@@ -1,3 +1,11 @@
+.\" Define V font for inline verbatim, using CB font in formats
+.\" that render this, and otherwise B font.
+.ie "\f[CB]x\f[]"x" \{\
+. ftr V B
+.\}
+.el \{\
+. ftr V CB
+.\}
.TH "Pandoc Test Suite" "" "July 17, 2006" "" ""
.hy
.PP
@@ -487,9 +495,8 @@ 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[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].
+This is code: \f[V]>\f[R], \f[V]$\f[R], \f[V]\[rs]\f[R], \f[V]\[rs]$\f[R],
+\f[V]<html>\f[R].
.PP
[STRIKEOUT:This is \f[I]strikeout\f[R].]
.PP
@@ -513,7 +520,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[B]\f[CB]code\f[B]\f[R]' and a \[lq]quoted
+Here is some quoted `\f[V]code\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.
@@ -546,7 +553,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[B]\f[CB]$e = mc\[ha]2$\f[B]\f[R].
+To get the famous equation, write \f[V]$e = mc\[ha]2$\f[R].
.IP \[bu] 2
$22,000 is a \f[I]lot\f[R] of money.
So is $34,000.
@@ -554,7 +561,7 @@ So is $34,000.
.IP \[bu] 2
Shoes ($20) and socks ($5).
.IP \[bu] 2
-Escaped \f[B]\f[CB]$\f[B]\f[R]: $73 \f[I]this should be emphasized\f[R] 23$.
+Escaped \f[V]$\f[R]: $73 \f[I]this should be emphasized\f[R] 23$.
.PP
Here\[cq]s a LaTeX table:
.PP
@@ -687,7 +694,7 @@ An e-mail address: <[email protected]>
Blockquoted: <http://example.com/>
.RE
.PP
-Auto-links should not occur here: \f[B]\f[CB]<http://example.com/>\f[B]\f[R]
+Auto-links should not occur here: \f[V]<http://example.com/>\f[R]
.IP
.nf
\f[C]
@@ -743,8 +750,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[B]\f[CB]]\f[B]\f[R]
-verbatim characters, as well as [bracketed text].
+Inline notes may contain links (http://google.com) and \f[V]]\f[R] verbatim
+characters, as well as [bracketed text].
.SS [4]
.PP
In quote.