Skip to content

Commit 204d363

Browse files
trastgitster
authored andcommitted
Quote ' as \(aq in manpages
The docbook/xmlto toolchain insists on quoting ' as \'. This does achieve the quoting goal, but modern 'man' implementations turn the apostrophe into a unicode "proper" apostrophe (given the right circumstances), breaking code examples in many of our manpages. Quote them as \(aq instead, which is an "apostrophe quote" as per the groff_char manpage. Unfortunately, as Anders Kaseorg kindly pointed out, this is not portable beyond groff, so we add an extra Makefile variable GNU_ROFF which you need to enable to get the new quoting. Thanks also to Miklos Vajna for documentation. Signed-off-by: Thomas Rast <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent ba7e814 commit 204d363

File tree

3 files changed

+28
-0
lines changed

3 files changed

+28
-0
lines changed

Documentation/Makefile

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,14 @@ ifdef DOCBOOK_SUPPRESS_SP
103103
XMLTO_EXTRA += -m manpage-suppress-sp.xsl
104104
endif
105105

106+
# If your target system uses GNU groff, it may try to render
107+
# apostrophes as a "pretty" apostrophe using unicode. This breaks
108+
# cut&paste, so you should set GNU_ROFF to force them to be ASCII
109+
# apostrophes. Unfortunately does not work with non-GNU roff.
110+
ifdef GNU_ROFF
111+
XMLTO_EXTRA += -m manpage-quote-apos.xsl
112+
endif
113+
106114
SHELL_PATH ?= $(SHELL)
107115
# Shell quote;
108116
SHELL_PATH_SQ = $(subst ','\'',$(SHELL_PATH))

Documentation/manpage-quote-apos.xsl

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
2+
version="1.0">
3+
4+
<!-- work around newer groff/man setups using a prettier apostrophe
5+
that unfortunately does not quote anything when cut&pasting
6+
examples to the shell -->
7+
<xsl:template name="escape.apostrophe">
8+
<xsl:param name="content"/>
9+
<xsl:call-template name="string.subst">
10+
<xsl:with-param name="string" select="$content"/>
11+
<xsl:with-param name="target">'</xsl:with-param>
12+
<xsl:with-param name="replacement">\(aq</xsl:with-param>
13+
</xsl:call-template>
14+
</xsl:template>
15+
16+
</xsl:stylesheet>

Makefile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,10 @@ all::
142142
#
143143
# Define DOCBOOK_XSL_172 if you want to format man pages with DocBook XSL v1.72.
144144
#
145+
# Define GNU_ROFF if your target system uses GNU groff. This forces
146+
# apostrophes to be ASCII so that cut&pasting examples to the shell
147+
# will work.
148+
#
145149
# Define NO_PERL_MAKEMAKER if you cannot use Makefiles generated by perl's
146150
# MakeMaker (e.g. using ActiveState under Cygwin).
147151
#

0 commit comments

Comments
 (0)