|
19 | 19 | \let\sphinxerrortitle \sphinxnotetitle |
20 | 20 | \def\sphinxseealsotitle#1{\sphinxstrong{#1}\par\nopagebreak} |
21 | 21 | % |
22 | | -% A utility to remove a final colon |
23 | | -% (one must be certain the semi-colon is there) |
24 | | -\protected\def\sphinxremovefinalcolon #1{% |
| 22 | +% A utility to remove a final colon. Removing last token is not easy in |
| 23 | +% LaTeX, and there are additional complications: |
| 24 | +% - some languages will make the : "active" in document body, |
| 25 | +% - the generic admonition ends up using "note", so for \sphinxnotetitle to |
| 26 | +% use it safely, the utility has to allow an input not having any final colon. |
| 27 | +% - a bit far-fetched but maybe there is more than one colon inside the input |
| 28 | +% (possible from a generic admonition title). |
| 29 | +% Hence the scary code. |
| 30 | +\def\sphinxremovefinalcolon#1{% #1 is the "active" : TeX token |
| 31 | +\protected\def\sphinxremovefinalcolon ##1{% |
25 | 32 | % complications due to : possibly "active" |
26 | 33 | \begingroup\ifnum\catcode`:=\active |
27 | | - \lccode`~=`:\lowercase{\def\x##1~}{##1}% |
28 | | - \else\def\x##1:{##1}\fi |
29 | | - \expandafter\endgroup\x#1% |
30 | | -}% |
| 34 | + \def\x####1#1\relax{####1}% |
| 35 | + \else\def\x####1:\relax{####1}\fi |
| 36 | + \expandafter\endgroup\x##1\relax |
| 37 | + % trick to let \x work also if input ##1 has no ending colon |
| 38 | + \@gobblefour#1\relax:\relax\relax\relax |
| 39 | + }% |
| 40 | +}% end of wrapper to inject active : |
| 41 | +\begingroup\catcode`:\active\expandafter\endgroup\sphinxremovefinalcolon: |
31 | 42 | % See doc/latex.rst for an example. |
32 | 43 |
|
33 | 44 | % Some custom font markup commands. |
|
0 commit comments