summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/xelatex/xeindex/xeindex.sty
blob: e43c202238c109ffa409377120b93da49f61177f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
% This is xeindex, produced by the CodeDoc class 
% with the `produce' option on. 
% 
% To create the documentation, compile xeindex.tex
% without the `produce' option. 
% 
% SOURCE: xeindex.tex
% DATE: 2014/12/05
% VERSION: v.0.3
\ProvidesPackage{xeindex}[2014/12/05 v.0.3 Automatic index for XeLaTeX.]
\RequirePackage{makeidx,xesearch}
\makeatletter
\newif\ifxi@mark
\DeclareOption{mark}{\xi@marktrue}
\ProcessOptions
\ifxi@mark
  \def\xi@Mark#1{***[#1:\the\inputlineno] }
\else
  \def\xi@Mark#1{}
\fi
\def\xi@empty{}
\def\xi@end{\xi@end}
\def\xi@Lists{}
\def\IndexList{%
  \@ifstar{\def\xi@cs{*}\xi@IndexList}{\def\xi@cs{}\xi@IndexList}%
  }
\def\xi@IndexList#1#2{%
  \def\xi@ListName{#1}%
  \edef\xi@Lists{\xi@Lists#1,}%
  \unless\ifcsname#1@xeindex\endcsname
    \csname#1@xeindex\endcsname
    \SearchList{#1@xeindex@ncs@normal@list}{%
      \def\xi@Word{##1}%
      \lowercase{\expandafter\index\expandafter{\xi@Mark\xi@Word##1}}}{}%
    \SearchList{#1@xeindex@cs@normal@list}{%
      \expandafter\index\expandafter{\xi@Mark{##1}##1}}{}%
    \SearchList{#1@xeindex@ncs@special@list}{%
      \lowercase{\csname##1@#1@xeindex@entry\endcsname}{##1}}{}%
    \SearchList{#1@xeindex@cs@special@list}{%
      \csname##1@#1@xeindex@entry\endcsname{##1}}{}%
    \SearchList{#1@xeindex@affix@special@list}{%
      \csname\AffixFound @#1@xeindex@entry\endcsname{##1}}{}%
  \fi
  \xi@ParseList#2,\xi@end,%
  }
\def\xi@ParseList#1,{%
  \def\xi@temp{#1}%
  \ifx\xi@temp\xi@end
    \let\xi@next\relax
  \else
    \expandafter\xi@ParseEntry\xi@cs#1=\xi@end
    \let\xi@next\xi@ParseList
  \fi\xi@next
  }
\def\xi@ParseEntry#1#2=#3\xi@end{%
  \def\xi@temp{#3}%
  \ifx\xi@temp\xi@empty
    \expandafter\if\noexpand#1*%
      \AddToList!{\xi@ListName @xeindex@cs@normal@list}{#1#2}%
    \else
      \AddToList!{\xi@ListName @xeindex@ncs@normal@list}{#1#2}%
    \fi
  \else
    \xi@MakeEntry#3%
    \expandafter\if\noexpand#1*%
      \xi@CheckAffix#2?\xi@end
      \ifxi@Affix
          \AddToList!{\xi@ListName @xeindex@affix@special@list}{#1#2}%
          \expandafter\edef\csname\xi@Affix @\xi@ListName @xeindex@entry\endcsname##1{%
            \unexpanded{\expandafter\index\expandafter}{%
              \noexpand\xi@Mark{##1}\ifxi@NoWord##1\fi\unexpanded\expandafter{\xi@temp}}%
            }%
      \else
        \AddToList!{\xi@ListName @xeindex@cs@special@list}{#1#2}%
          \expandafter\edef\csname#2@\xi@ListName @xeindex@entry\endcsname##1{%
            \unexpanded{\expandafter\index\expandafter}{%
              \noexpand\xi@Mark{##1}\ifxi@NoWord#2\fi\unexpanded\expandafter{\xi@temp}}%
            }%
      \fi
    \else
      \xi@CheckAffix#1#2?\xi@end
      \ifxi@Affix
          \AddToList!{\xi@ListName @xeindex@affix@special@list}{#1#2}%
          \expandafter\edef\csname\xi@lcAffix @\xi@ListName @xeindex@entry\endcsname##1{%
            \unexpanded{\def\xi@Word}{##1}%
            \noexpand\lowercase{%
              \unexpanded{\expandafter\index\expandafter}{%
                \unexpanded{\xi@Mark{\xi@Word}}%
                \ifxi@NoWord##1\fi\unexpanded\expandafter{\xi@temp}}%
              }%
            }%
      \else
        \AddToList!{\xi@ListName @xeindex@ncs@special@list}{#1#2}%
        \lowercase{%
          \expandafter\edef\csname#1#2@\xi@ListName @xeindex@entry\endcsname##1{%
            \unexpanded{\def\xi@Word}{##1}%
            \unexpanded{\expandafter\index\expandafter}{%
              \unexpanded{\xi@Mark{\xi@Word}}%
              \ifxi@NoWord#1#2\fi\unexpanded\expandafter{\xi@temp}}%
            }%
          }%
      \fi
    \fi
  \fi
  }
\newif\ifxi@NoWord
\def\xi@exclam{!} \def\xi@at{@} \def\xi@bar{|}
\def\xi@MakeEntry#1#2={%
  \def\xi@temp{#1#2}%
  \xi@NoWordtrue
  \unless\ifx\xi@temp\xi@exclam
    \unless\ifx\xi@temp\xi@at
      \unless\ifx\xi@temp\xi@bar
        \xi@NoWordfalse
      \fi
    \fi
  \fi
  }
\newif\ifxi@Affix
\def\xi@CheckAffix#1#2?#3\xi@end{%
  \xi@Affixfalse
  \expandafter\if\noexpand#1?%
    \xi@Affixtrue
    \def\xi@Affix{#2}%
    \lowercase{\def\xi@lcAffix{#2}}%
  \else
    \def\xi@@temp{#3}%
    \unless\ifx\xi@@temp\xi@empty
      \xi@Affixtrue
      \def\xi@Affix{#1#2}%
      \lowercase{\def\xi@lcAffix{#1#2}}%
    \fi
  \fi
  }
\def\StopIndexList#1{%
  \xi@StopIndexList#1,\xi@end,%
  }%
\def\xi@StopIndexList#1,{%
  \def\xi@temp{#1}%
  \ifx\xi@temp\xi@end
    \let\xi@next\relax
  \else
    \StopList{%
      #1@xeindex@ncs@normal@list,%
      #1@xeindex@cs@normal@list,%
      #1@xeindex@cs@normal@list,%
      #1@xeindex@ncs@special@list,%
      #1@xeindex@cs@special@list,%
      #1@xeindex@affix@special@list%
      }%
    \let\xi@next\xi@StopIndexList
  \fi\xi@next
  }
\def\StopIndex{%
  \expandafter\xi@StopIndexList\xi@Lists\xi@end,%
  }
\def\NoIndex#1{%
  \bgroup
  \StopIndex
  #1%
  \egroup
  }
\let\xi@PrintIndex\printindex \def\printindex{\StopIndex\xi@PrintIndex}
\SortByLength{pPsS} \SearchOnlyOne{pPsS}
\makeatother