Skip to content

Commit

Permalink
T.P.RoffChar: escape - as \-.
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
jgm committed Nov 3, 2023
1 parent 051fa7d commit 5132f1e
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 20 deletions.
1 change: 1 addition & 0 deletions src/Text/Pandoc/RoffChar.hs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ standardEscapes =
, ('`', "\\[ga]")
, ('^', "\\[ha]")
, ('~', "\\[ti]")
, ('-', "\\-")
, ('\\', "\\[rs]")
, ('@', "\\[at]") -- because we use @ as a table and math delimiter
, ('\x2026', "\\&...") -- because u2026 doesn't render on tty
Expand Down
2 changes: 1 addition & 1 deletion test/command/5620.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
: Write output to *OUTFILE* instead of `stdout`(3)
^D
.TP
\f[CR]-o\f[R], \f[CR]--output=\f[R]\f[I]OUTFILE\f[R]
\f[CR]\-o\f[R], \f[CR]\-\-output=\f[R]\f[I]OUTFILE\f[R]
Write output to \f[I]OUTFILE\f[R] instead of \f[CR]stdout\f[R](3)
```
20 changes: 10 additions & 10 deletions test/writer.man
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,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.
Expand All @@ -37,7 +37,7 @@ here.
.PP
* * * * *
.SH Block Quotes
E-mail style:
E\-mail style:
.RS
.PP
This is a block quote.
Expand Down Expand Up @@ -79,7 +79,7 @@ And a following paragraph.
Code:
.IP
.EX
---- (should be four hyphens)
\-\-\-\- (should be four hyphens)
sub status {
print \[dq]working\[dq];
Expand Down Expand Up @@ -430,7 +430,7 @@ Multiline:
Code block:
.IP
.EX
<!-- Comment -->
<!\-\- Comment \-\->
.EE
.PP
Just plain comment, with trailing spaces on the line:
Expand Down Expand Up @@ -507,11 +507,11 @@ Ellipses\&...and\&...and\&....
.IP \[bu] 2
223
.IP \[bu] 2
\f[I]p\f[R]-Tree
\f[I]p\f[R]\-Tree
.IP \[bu] 2
Here\[cq]s some display math:
.RS
$$\[rs]frac{d}{dx}f(x)=\[rs]lim_{h\[rs]to 0}\[rs]frac{f(x+h)-f(x)}{h}$$
$$\[rs]frac{d}{dx}f(x)=\[rs]lim_{h\[rs]to 0}\[rs]frac{f(x+h)\-f(x)}{h}$$
.RE
.IP \[bu] 2
Here\[cq]s one that has a line break in it:
Expand Down Expand Up @@ -575,7 +575,7 @@ Left paren: (
.PP
Right paren: )
.PP
Greater-than: >
Greater\-than: >
.PP
Hash: #
.PP
Expand All @@ -585,7 +585,7 @@ Bang: !
.PP
Plus: +
.PP
Minus: -
Minus: \-
.PP
* * * * *
.SH Links
Expand Down Expand Up @@ -661,7 +661,7 @@ In a list?
.IP \[bu] 2
It should.
.PP
An e-mail address: \c
An e\-mail address: \c
.MT [email protected]
.ME \c
.RS
Expand All @@ -671,7 +671,7 @@ Blockquoted: \c
.UE \c
.RE
.PP
Auto-links should not occur here: \f[CR]<http://example.com/>\f[R]
Auto\-links should not occur here: \f[CR]<http://example.com/>\f[R]
.IP
.EX
or here: <http://example.com/>
Expand Down
18 changes: 9 additions & 9 deletions test/writer.ms
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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.
Expand Down Expand Up @@ -197,7 +197,7 @@ Code:
.IP
.nf
\f[C]
---- (should be four hyphens)
\-\-\-\- (should be four hyphens)

sub status {
print \[dq]working\[dq];
Expand Down Expand Up @@ -605,7 +605,7 @@ Code block:
.IP
.nf
\f[C]
<!-- Comment -->
<!\-\- Comment \-\->
\f[]
.fi
.LP
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -765,7 +765,7 @@ Left paren: (
.PP
Right paren: )
.PP
Greater-than: >
Greater\-than: >
.PP
Hash: #
.PP
Expand All @@ -775,7 +775,7 @@ Bang: !
.PP
Plus: +
.PP
Minus: -
Minus: \-
.HLINE
.SH 1
Links
Expand Down Expand Up @@ -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"
\&
Expand All @@ -937,7 +937,7 @@ Blockquoted: \c
\&
.QE
.LP
Auto-links should not occur here: \f[CR]<http://example.com/>\f[R]
Auto\-links should not occur here: \f[CR]<http://example.com/>\f[R]
.IP
.nf
\f[C]
Expand Down

0 comments on commit 5132f1e

Please sign in to comment.