Robustness fix: cope with \index{Poincar\'e}
5 files changed, 82 insertions(+), 12 deletions(-)

M Makefile
M showlabels.html
A => t/t19.tex
M t/t4.tex
M Makefile +5 -1
@@ 2,7 2,11 @@ 
 # Just for packaging -- not distributed
+# FIXME: add the usual step-by-step instructions for distribution,
+# and check that the bundle does match the suggestions at
+# <>.
 RELEASEDATE=2016 June 9
 #  following must be yyyy/mm/dd

M +18 -5
@@ 479,8 479,14 @@ 
 % \begin{macro}{\SL@prlabelname}
 % Expansion is label name with all catcodes `other' (Appendix~D trickery
-% abounds!).  Use |\r@#1|, rather then just |\#1| to avoid defining any new
-% control sequences.
+% abounds!).  Use |\r@#1| (defined by |\ref|), rather then just |\#1|
+% to avoid defining any new control sequences.
+% Note that this catcode magic, and the |\@sanitize| in
+% |\SL@showlabels| below, are doing much the same job, and indeed are
+% almost redundant with each other.  But this |\SL@prlabelname|
+% doesn't cope with eg |\index{Poincar\'e}|, and the |\@sanitize|
+% below doesn't cope with |\section{\label{a_b}Foo}| (see tests t4 and t19).
 %    \begin{macrocode}

@@ 585,9 591,16 @@ 
 % We actually handle three distinct cases here, for |\foo{label}|,
 % |\foo[opt]{label}| and |\foo*{label}| (the last is to handle the
 % \Lpackage{hyperref} package's |\ref*{label}| variant; see test case t14).
+% We open a group in order to call |\@sanitize|; we're able to close
+% it immediately, within the called macros.  We call |\@sanitize| in
+% order to cope with eg |\index{Poincar\'e}| (see discussion of
+% |\SL@prlabelname| above).
 %    \begin{macrocode}
+  \@bsphack
   \expandafter\let\expandafter\SL@orig@@next\csname SL@orig#1\endcsname
+  \begingroup\@sanitize

@@ 595,19 608,19 @@ 
-  \@bsphack
+  \endgroup
   \ifhmode \spacefactor\@savsf \ifdim\@savsk>\z@ \hskip1sp \fi\fi
-  \@bsphack
+  \endgroup
   \ifhmode \spacefactor\@savsf \ifdim\@savsk>\z@ \hskip1sp \fi\fi
-  \@bsphack
+  \endgroup
   \ifhmode \spacefactor\@savsf \ifdim\@savsk>\z@ \hskip1sp \fi\fi

M showlabels.html +12 -3
@@ 30,8 30,6 @@ whenever either the <code>\label</code> 
 equation is automatically numbered.  It is compatible with the
 <code>amsmath</code> and <code>hyperref</code> packages.</p>
-<p>It is similar to, but does a little more than, the showkeys package.</p>
 <p>You invoke this package with the command
 <code>\usepackage{showlabels}</code> in the preamble.  You can control
 where the labels appear – in the margins or in the interline gaps –

@@ 58,6 56,13 @@ conflict in either case).  The package c
 in the wrong margins, near the top of a page – see the documentation
 for a discussion of this.</p>
+<p>The <code>{showlabels}</code> package has a large overlap in
+functionality with David Carlisle's <code>{showkeys}</code>, although
+the latter will only handle <code>\label</code> and <code>\cite</code> keys.  If
+<code>{showlabels}</code> fails in some particular situation, you might
+want to try using <code>{showkeys}</code>, but please do mention the
+problem, typically by email to me.</p>
 <h3>Download and installation</h3>

@@ 100,7 105,11 @@ either version 1.3 of this licence or (a
-<dt><span class='attention'><strong>1.8, 2016 June 9</strong></span></dt>
+<dt><span class='attention'><strong>1.8.X, YYYY MMM DD</strong></span></dt>
+<dd>Robustness fix: macros in arguments are now handled, so that
+<code>\index{Poincar\'e}</code> doesn't cause an error.</dd>
+<dt><strong>1.8, 2016 June 9</strong></dt>
 <dd>The <code>ntheorem</code> package exposed an apparently
 long-standing incompleteness in the handling of <code>amsmath</code>

A => t/t19.tex +43 -0
@@ 0,0 1,43 @@ 
+%%% Testing: \index with macros; like t4, but not inline
+% Compare t4
+% Setup for using this with XeLaTeX --
+% the underscores look odd with a non-tt TeX font, but are OK
+% with native fonts.
+\section{\label{s:s1_a sect}This is a section}
+The labels in this file have underscores and spaces in them, and
+should be formatted without error.
+We talk about Poincar\'e\index{Poincar\'e}.
+This is \label{s:s1_b text} some text.
+And an equation:
+\label{e:e a_1} % label with space and underscore
+which we can refer to as
+\item Eq.\ref{e:e a_1}, and
+\item \cite{nobody_bar\'e}.

M t/t4.tex +4 -3
@@ 1,5 1,5 @@ 
-%%% Testing:[inline] option, and \showlabelfont, and labels with space
-%%% and underscore.
+%%% Testing:[inline] option, and \showlabelfont, and labels with space and underscore.
+% Compare t19

@@ 17,6 17,7 @@ 

@@ 33,7 34,7 @@ as the showlabelfont, these underscores 
 Each of the begin, ref and cite commands in the file should have an
-inline label attached to it.
+inline label attached to it.  As should Poincar\'e\index{Poincar\'e}.
 This is \label{s:s1_b text} some text, with an equation.