Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

- should be escaped as \- in man, but not in ms output #10536

Closed
tkurtbond opened this issue Jan 14, 2025 Discussed in #10533 · 0 comments
Closed

- should be escaped as \- in man, but not in ms output #10536

tkurtbond opened this issue Jan 14, 2025 Discussed in #10533 · 0 comments

Comments

@tkurtbond
Copy link

Discussed in #10533

Originally posted by tkurtbond January 13, 2025
Why does pandoc convert hyphen-minus to minus signs in text when outputing to ms?

For instance, why does running

# Trying out Hyphen-Minus in pandoc -w ms

This is a hyphen-minus, -, which pandoc -w ms turns into a Unicode minus sign.

Use the command ``ls -a`` to see all the dotfiles in a directory.

through

pandoc -r markdown -w ms --output=hyphen-minus.ms  hyphen-minus.md

become

.SH 1
Trying out Hyphen\-Minus in pandoc \-w ms
.pdfhref O 1 "Trying out Hyphen-Minus in pandoc -w ms"
.pdfhref M "trying-out-hyphen-minus-in-pandoc--w-ms"
.LP
This is a hyphen\-minus, \-, which pandoc \-w ms turns into a Unicode
minus sign.
.PP
Use the command \f[CR]ls \-a\f[R] to see all the dotfiles in a
directory.

with all those blasted \-s, which are the troff form for entering a minus sign?

Automagically changing hypen-minus to minus signs is never a good thing to do. It changes the example ls -a command to something that won't work because instead of a hyphen-minus it has a stupid minus sign, which is not the character that introduces an option in a command line program, so the command doesn't work right.

The discussion of thesmart extension in the documents doesn't say anything aobut translating hypen-minus to minus, but I tried -r markdown-smart, which didn't seem to do anything.

$ pandoc --version
pandoc 3.6.2
Features: +server +lua
Scripting engine: Lua 5.4
User data directory: /home/tkb/.pandoc

(Didn't I have this discussion on the old pandoc-discuss mailing list once?)

@jgm jgm changed the title Why does hyphen-minus get converted to minus in text when outputing to ms? - should be escaped as \- in man, but not in ms output Jan 14, 2025
@jgm jgm closed this as completed in c9460c8 Jan 14, 2025
jgm added a commit that referenced this issue Jan 14, 2025
In 5132f1e we added `-` to
the list of characters needing backslash escaping, to accommodate
a change in groff man's behavior, described here:
https://lwn.net/Articles/947941/

This change also led `-` to be escaped in ms output, but that
is wrong; `\-` in ms is a unicode minus sign.

To fix this, we add a Boolean parameter to `escapeString` in
Text.Pandoc.Writers.Roff that determines whether `-` is to
be escaped.  (NB: This is not an exported function in the API.)

The list `standardEscapes` in Text.Pandoc.RoffChar no longer
contains `-`.

Closes #10536.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant