-
Notifications
You must be signed in to change notification settings - Fork 5
/
indexing4ht.4ht
99 lines (81 loc) · 2.79 KB
/
indexing4ht.4ht
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
\@ifpackageloaded{imakeidx}{%
\makeatletter
\newcommand\:wrindex[3]{%
\edef\th@idx@entry{\detokenize{#2}}
\imki@wrindexentry{#1}{\th@idx@entry}{#3}
}
\makeatother
}{%ToDo: Provide configuration for index writing without imakeidx
\newcommand\:wrindex[3]{}
}
% because imakeidx has support for multiple indices, we need to select a
% right one
\NewConfigure{indexname}{1}
% default index name is \jobname
% configure variable which is saved on every index call
% section mark is used by default, other possible values may be paragraphs, or
% links to individual index entries
\NewConfigure{indexvalue}{1}
\Configure{indexvalue}{\getCurrentSectionNumber}
\NewConfigure{indexidentifier}{1}
\Configure{indexidentifier}{\CurSecHaddr}
% we need to suppress adding of multiple identical identifiers
\edef\curseccnt{}
\renewcommand\index[2][]{%
\ifx|#1|%
\Configure{indexname}{\jobname}%
\else\Configure{indexname}{#1}%
\fi%
\:wrindex{\a:indexname}{#2}{\a:indexvalue}
% save identifier only if it haven't been used yet
\expandafter\ifcsname usedsec\a:indexvalue\endcsname
\else%
\Tag{sec\a:indexvalue}{\a:indexidentifier}
\fi%
\expandafter\gdef\csname usedsec\a:indexvalue\endcsname{yes}
\let\curseccnt\newseccnt
}
% print index locators. make links to destinations in document
\newcommand\idxlocator[1]{%
\ifTag{sec#1}{\a:locatorlink{\Ref{sec#1}}{}#1\b:locatorlink}{#1} %
%\ifTag{sec#1}{\Link{\Ref{sec#1}}{}#1\EndLink}{#1}%
\typeout{\LikeRef{sec#1}}
}
\NewConfigure{locatorlink}{2}
\Configure{locatorlink}{\Link}{\EndLink}
% to support crossreferencess, we save index keyword with unique identifier
\GetTitleStringSetup{expand}
\GetTitleStringDisableCommands{%
\renewcommand\LaTeX{LaTeX}
}
\newcount\idxkwdcnt
\LinkCommand\IdxKWLink{span,href,id}
\newcommand\idxkeyword[1]{%
\global\advance\idxkwdcnt by 1\relax%
% use tags only one time
\GetTitleString{#1}
\ifcsdef{idxkw\GetTitleStringResult}{}%
%{\Tag{idxkw#1}{idxkw\the\idxkwdcnt}}%
{\expandafter\Tag\expandafter{idxkw\GetTitleStringResult}{idxkw\the\idxkwdcnt}}%
\csgdef{idxkw\GetTitleStringResult}{x}
\a:IdxKW{}{idxkw\the\idxkwdcnt}#1\b:IdxKW
}
\NewConfigure{IdxKW}{2}
\Configure{IdxKW}{\IdxKWLink}{\EndIdxKWLink}
\renewcommand\see[1]{%
\GetTitleString{#1}%
\a:see\ \ifTag{idxkw#1}{\a:seeLink{\Ref{idxkw\GetTitleStringResult}}{}#1\b:seeLink}{#1}
}
% make link configurable, in order to enable user to add custom parameters
\NewConfigure{seeLink}{2}
\Configure{seeLink}{\Link}{\EndLink}
\NewConfigure{see}{1}
\Configure{see}{\textit{see}}
\renewcommand\seealso[1]{%
\GetTitleString{#1}%
\a:seealso\ \ifTag{idxkw#1}{\a:seeAlsoLink{\Ref{idxkw\GetTitleStringResult}}{}#1\b:seeAlsoLink}{#1}
}
\NewConfigure{seeAlsoLink}{2}
\Configure{seeAlsoLink}{\Link}{\EndLink}
\NewConfigure{seealso}{1}
\Configure{seealso}{\textit{see also}}