Skip to content

Commit 5132f1e

Browse files
committed
T.P.RoffChar: escape - as \-.
The groff_man (7)` man page indicates that `-` characters will be treated as typographic hyphens and are not appropriate for cases where the output should be copy-pasteable as an ASCII hyphen-minus character. (E.g. in command line options.) However, until a recent update groff man did not actually do this; it treated `-` and `\-` the same. With the new update (1.23.0) the two are distinguished (see https://lwn.net/Articles/947941/ for background), so now it is important that pandoc escape `-`. This reverts ee60ba5. That change was motivated by a problem with backslash-escaping `-` in a filename for .PSPIC. That's simply a separate issue; we shouldn't do the normal escapes in such a context. It has been addressed in the previous commit.
1 parent 051fa7d commit 5132f1e

File tree

4 files changed

+21
-20
lines changed

4 files changed

+21
-20
lines changed

src/Text/Pandoc/RoffChar.hs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ standardEscapes =
3434
, ('`', "\\[ga]")
3535
, ('^', "\\[ha]")
3636
, ('~', "\\[ti]")
37+
, ('-', "\\-")
3738
, ('\\', "\\[rs]")
3839
, ('@', "\\[at]") -- because we use @ as a table and math delimiter
3940
, ('\x2026', "\\&...") -- because u2026 doesn't render on tty

test/command/5620.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@
44
: Write output to *OUTFILE* instead of `stdout`(3)
55
^D
66
.TP
7-
\f[CR]-o\f[R], \f[CR]--output=\f[R]\f[I]OUTFILE\f[R]
7+
\f[CR]\-o\f[R], \f[CR]\-\-output=\f[R]\f[I]OUTFILE\f[R]
88
Write output to \f[I]OUTFILE\f[R] instead of \f[CR]stdout\f[R](3)
99
```

test/writer.man

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ Here\[cq]s a regular paragraph.
2323
In Markdown 1.0.0 and earlier.
2424
Version 8.
2525
This line turns into a list item.
26-
Because a hard-wrapped line in the middle of a paragraph looked like a list
26+
Because a hard\-wrapped line in the middle of a paragraph looked like a list
2727
item.
2828
.PP
2929
Here\[cq]s one with a bullet.
@@ -37,7 +37,7 @@ here.
3737
.PP
3838
* * * * *
3939
.SH Block Quotes
40-
E-mail style:
40+
E\-mail style:
4141
.RS
4242
.PP
4343
This is a block quote.
@@ -79,7 +79,7 @@ And a following paragraph.
7979
Code:
8080
.IP
8181
.EX
82-
---- (should be four hyphens)
82+
\-\-\-\- (should be four hyphens)
8383
8484
sub status {
8585
print \[dq]working\[dq];
@@ -430,7 +430,7 @@ Multiline:
430430
Code block:
431431
.IP
432432
.EX
433-
<!-- Comment -->
433+
<!\-\- Comment \-\->
434434
.EE
435435
.PP
436436
Just plain comment, with trailing spaces on the line:
@@ -507,11 +507,11 @@ Ellipses\&...and\&...and\&....
507507
.IP \[bu] 2
508508
223
509509
.IP \[bu] 2
510-
\f[I]p\f[R]-Tree
510+
\f[I]p\f[R]\-Tree
511511
.IP \[bu] 2
512512
Here\[cq]s some display math:
513513
.RS
514-
$$\[rs]frac{d}{dx}f(x)=\[rs]lim_{h\[rs]to 0}\[rs]frac{f(x+h)-f(x)}{h}$$
514+
$$\[rs]frac{d}{dx}f(x)=\[rs]lim_{h\[rs]to 0}\[rs]frac{f(x+h)\-f(x)}{h}$$
515515
.RE
516516
.IP \[bu] 2
517517
Here\[cq]s one that has a line break in it:
@@ -575,7 +575,7 @@ Left paren: (
575575
.PP
576576
Right paren: )
577577
.PP
578-
Greater-than: >
578+
Greater\-than: >
579579
.PP
580580
Hash: #
581581
.PP
@@ -585,7 +585,7 @@ Bang: !
585585
.PP
586586
Plus: +
587587
.PP
588-
Minus: -
588+
Minus: \-
589589
.PP
590590
* * * * *
591591
.SH Links
@@ -661,7 +661,7 @@ In a list?
661661
.IP \[bu] 2
662662
It should.
663663
.PP
664-
An e-mail address: \c
664+
An e\-mail address: \c
665665
666666
.ME \c
667667
.RS
@@ -671,7 +671,7 @@ Blockquoted: \c
671671
.UE \c
672672
.RE
673673
.PP
674-
Auto-links should not occur here: \f[CR]<http://example.com/>\f[R]
674+
Auto\-links should not occur here: \f[CR]<http://example.com/>\f[R]
675675
.IP
676676
.EX
677677
or here: <http://example.com/>

test/writer.ms

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ Here\[cq]s a regular paragraph.
134134
In Markdown 1.0.0 and earlier.
135135
Version 8.
136136
This line turns into a list item.
137-
Because a hard-wrapped line in the middle of a paragraph looked like a list
137+
Because a hard\-wrapped line in the middle of a paragraph looked like a list
138138
item.
139139
.PP
140140
Here\[cq]s one with a bullet.
@@ -149,7 +149,7 @@ Block Quotes
149149
.pdfhref O 1 "Block Quotes"
150150
.pdfhref M "block-quotes"
151151
.LP
152-
E-mail style:
152+
E\-mail style:
153153
.QS
154154
.LP
155155
This is a block quote.
@@ -197,7 +197,7 @@ Code:
197197
.IP
198198
.nf
199199
\f[C]
200-
---- (should be four hyphens)
200+
\-\-\-\- (should be four hyphens)
201201

202202
sub status {
203203
print \[dq]working\[dq];
@@ -605,7 +605,7 @@ Code block:
605605
.IP
606606
.nf
607607
\f[C]
608-
<!-- Comment -->
608+
<!\-\- Comment \-\->
609609
\f[]
610610
.fi
611611
.LP
@@ -695,7 +695,7 @@ LaTeX
695695
.IP \[bu] 3
696696
@223@
697697
.IP \[bu] 3
698-
@p@-Tree
698+
@p@\-Tree
699699
.IP \[bu] 3
700700
Here\[cq]s some display math:
701701
.EQ
@@ -765,7 +765,7 @@ Left paren: (
765765
.PP
766766
Right paren: )
767767
.PP
768-
Greater-than: >
768+
Greater\-than: >
769769
.PP
770770
Hash: #
771771
.PP
@@ -775,7 +775,7 @@ Bang: !
775775
.PP
776776
Plus: +
777777
.PP
778-
Minus: -
778+
Minus: \-
779779
.HLINE
780780
.SH 1
781781
Links
@@ -925,7 +925,7 @@ In a list?
925925
.IP \[bu] 3
926926
It should.
927927
.LP
928-
An e-mail address: \c
928+
An e\-mail address: \c
929929
.pdfhref W -D "mailto:nobody%40nowhere.net" -A "\c" \
930930
-- "nobody\[at]nowhere.net"
931931
\&
@@ -937,7 +937,7 @@ Blockquoted: \c
937937
\&
938938
.QE
939939
.LP
940-
Auto-links should not occur here: \f[CR]<http://example.com/>\f[R]
940+
Auto\-links should not occur here: \f[CR]<http://example.com/>\f[R]
941941
.IP
942942
.nf
943943
\f[C]

0 commit comments

Comments
 (0)