diff options
author | Karl Berry <karl@freefriends.org> | 2012-09-21 22:42:52 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2012-09-21 22:42:52 +0000 |
commit | e6f44970632b8e625130b6c035361aa447dbc398 (patch) | |
tree | 55d1125bff28a4eb2cb16ccd778d319ef6c12569 /Master/texmf-dist/source | |
parent | 001ce1425d9a3d1dcf6d3eade95e7dcd53c5be9b (diff) |
glossaries (21sep12)
git-svn-id: svn://tug.org/texlive/trunk@27766 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/source')
4 files changed, 4150 insertions, 269 deletions
diff --git a/Master/texmf-dist/source/latex/glossaries/glossaries.dtx b/Master/texmf-dist/source/latex/glossaries/glossaries.dtx index 3c3f4e9abeb..d80ad0b707c 100644 --- a/Master/texmf-dist/source/latex/glossaries/glossaries.dtx +++ b/Master/texmf-dist/source/latex/glossaries/glossaries.dtx @@ -1,13 +1,13 @@ %\iffalse % glossaries.dtx generated using makedtx version 0.94b (c) Nicola Talbot % Command line args: -% -macrocode "glossaries\.perl" +% -macrocode ".*\.perl" % -macrocode ".*\.tex" % -macrocode ".*\.xdy" -% -setambles "glossaries\.perl=>\nopreamble\nopostamble" +% -setambles ".*\.perl=>\nopreamble\nopostamble" % -setambles ".*\.tex=>\nopreamble\nopostamble" % -setambles ".*\.xdy=>\nopreamble\nopostamble" -% -comment "glossaries\.perl" +% -comment ".*\.perl" % -comment ".*\.tex" % -comment ".*\.xdy" % -src "glossaries.sty\Z=>glossaries.sty" @@ -22,12 +22,12 @@ % -src "(sample.*\.tex)\Z=>\1" % -src "(samplexdy-mc.*\.xdy)\Z=>\1" % -src "(database.*\.tex)\Z=>\1" -% -src "(glossaries\.perl)\Z=>\1" +% -src "(.*\.perl)\Z=>\1" % -doc "glossaries-manual.tex" % -author "Nicola Talbot" % -codetitle "Main Package Code" % glossaries -% Created on 2012/5/21 14:06 +% Created on 2012/9/21 14:41 %\fi %\iffalse %<*package> @@ -79,7 +79,7 @@ glossaries.dtx \setcounter{IndexColumns}{2} -\CheckSum{13653} +\CheckSum{13761} \newcommand*{\ifirstuse}{\iterm{first use}} \newcommand*{\firstuse}{first use\ifirstuse} @@ -107,7 +107,7 @@ glossaries.dtx %\MakeShortVerb{"} %\DeleteShortVerb{\|} % -% \title{Documented Code For glossaries v3.02} +% \title{Documented Code For glossaries v3.03} % \author{Nicola L.C. Talbot\\[10pt] %School of Computing Sciences\\ %University of East Anglia\\ @@ -115,7 +115,7 @@ glossaries.dtx %NR4 7TJ. United Kingdom.\\ %\url{http://theoval.cmp.uea.ac.uk/~nlct/}} % -% \date{2012-05-21} +% \date{2012-09-21} % \maketitle % %This is the documented code for the \styfmt{glossaries} package. @@ -131,7 +131,7 @@ glossaries.dtx %glossaries package}. % %\item[\url{glossaries-user.pdf}] -%For the main user guide, read \qt{glossaries.sty v3.02: +%For the main user guide, read \qt{glossaries.sty v3.03: %\LaTeX2e\ Package to Assist Generating Glossaries}. % %\item[\url{mfirstuc-manual.pdf}] @@ -172,7 +172,7 @@ glossaries.dtx % This package requires \LaTeXe. % \begin{macrocode} \NeedsTeXFormat{LaTeX2e} -\ProvidesPackage{glossaries}[2012/05/21 v3.02 (NLCT)] +\ProvidesPackage{glossaries}[2012/09/21 v3.03 (NLCT)] % \end{macrocode} % Required packages: % \begin{macrocode} @@ -447,6 +447,32 @@ false,nolabel,autolabel}[nolabel]{% % \end{macrocode} %\end{option} % +%\begin{macro}{\glspostdescription} +% The description terminator is given by \cs{glspostdescription} +% (except for the 3 and 4 column styles). This is a full stop +% by default: +% \begin{macrocode} +\newcommand*{\glspostdescription}{\ifglsnopostdot\else.\fi} +% \end{macrocode} +%\end{macro} +%\begin{option}{nopostdot} +% Boolean option to suppress post description dot +%\changes{3.03}{2012/09/21}{new} +% \begin{macrocode} +\define@boolkey{glossaries.sty}[gls]{nopostdot}[true]{} +\glsnopostdotfalse +% \end{macrocode} +%\end{option} +%\begin{option}{nogroupskip} +% Boolean option to suppress vertical space between groups in the +% pre-defined styles. +%\changes{3.03}{2012/09/21}{new} +% \begin{macrocode} +\define@boolkey{glossaries.sty}[gls]{nogroupskip}[true]{} +\glsnogroupskipfalse +% \end{macrocode} +%\end{option} +% %\begin{option}{ucmark} % Boolean option to determine whether or not to use % \ics{MakeUppercase} in definition of \ics{glossarymark} @@ -531,7 +557,10 @@ false,nolabel,autolabel}[nolabel]{% \ifx\@glo@sort\@glsdefaultsort \let\@glo@sort\@glo@name \fi - \@onelevel@sanitize\@glo@sort +% \end{macrocode} +%\changes{3.03}{2012/09/21}{used \cs{@gls@sanitizesort}} +% \begin{macrocode} + \@gls@sanitizesort \expandafter\protected@xdef\csname glo@##2@sort\endcsname{\@glo@sort}% }% % \end{macrocode} @@ -871,9 +900,12 @@ false,nolabel,autolabel}[nolabel]{% \newcommand*{\@gls@sanitizesymbol}{\@onelevel@sanitize\@glo@symbol} % \end{macrocode} %\end{macro} -% (There is no equivalent for the \gloskey{sort} key, since that -% is only provided for the benefit of \app{makeindex} or -% \app{xindy}, and so will always be sanitized.) +%\begin{macro}{\@gls@sanitizesort} +%\changes{3.03}{2012/09/21}{new} +% \begin{macrocode} +\newcommand*{\@gls@sanitizesort}{\@onelevel@sanitize\@glo@sort} +% \end{macrocode} +%\end{macro} % % Before defining the \pkgopt{sanitize} package option, The % key-value list for the \pkgopt{sanitize} value needs to be defined. @@ -911,6 +943,17 @@ false,nolabel,autolabel}[nolabel]{% \renewcommand*{\@gls@sanitizesymbol}{}% \fi} % \end{macrocode} +% and for the \gloskey{sort} key: +% \begin{macrocode} +\define@boolkey[gls]{sanitize}{sort}[true]{% +\ifgls@sanitize@sort + \renewcommand*{\@gls@sanitizesort}{% +\@onelevel@sanitize\@glo@sort}% +\else + \renewcommand*{\@gls@sanitizesort}{}% +\fi} +% \end{macrocode} +% % %\begin{option}{sanitize} % Now define the \pkgopt{sanitize} option. It can either take @@ -920,11 +963,14 @@ false,nolabel,autolabel}[nolabel]{% % \begin{macrocode} \define@key{glossaries.sty}{sanitize}[description=true,symbol=true, name=true]{% -\ifthenelse{\equal{#1}{none}}{% -\renewcommand*{\@gls@sanitizedesc}{}% -\renewcommand*{\@gls@sanitizename}{}% -\renewcommand*{\@gls@sanitizesymbol}{}% -}{\setkeys[gls]{sanitize}{#1}}% +\ifthenelse{\equal{#1}{none}}% +{% + \renewcommand*{\@gls@sanitizedesc}{}% + \renewcommand*{\@gls@sanitizename}{}% + \renewcommand*{\@gls@sanitizesymbol}{}% +}% +{% + \setkeys[gls]{sanitize}{#1}}% } % \end{macrocode} %\end{option} @@ -1438,15 +1484,6 @@ name=true]{% }} \fi % \end{macrocode} -%\begin{macro}{\glspostdescription} -% The description terminator is given by \cs{glspostdescription} -% (except for the 3 and 4 column styles). This is a full stop -% by default: -% \begin{macrocode} -\newcommand*{\glspostdescription}{.} -% \end{macrocode} -%\end{macro} -% %\begin{macro}{\nopostdesc} % Provide a means to suppress description terminator for a given % entry. (Useful for entries with no description.) Has no @@ -7860,7 +7897,7 @@ name=true]{% % \end{macrocode} %\end{macro} %\vskip5pt -%\cs{glsaddall}\oarg{glossary list}\\[10pt] +%\cs{glsaddall}\oarg{option list}\\[10pt] % Add all terms defined for the listed glossaries (without displaying % any text). If \gloskey[glsaddall]{types} key is omitted, apply to all % glossary types. @@ -8930,6 +8967,10 @@ you % \begin{macrocode} \def\@glo@type{\glsdefaulttype}% \def\glossarytitle{\csname @glotype@\@glo@type @title\endcsname}% +% \end{macrocode} +%\changes{3.03}{2012/09/21}{allow title to override default toctitle} +% \begin{macrocode} + \def\glossarytoctitle{\glossarytitle}% \let\org@glossarytitle\glossarytitle \def\@glossarystyle{}% \def\gls@dotoctitle{\glssettoctitle{\@glo@type}}% @@ -9077,14 +9118,19 @@ you % \end{macrocode} % The \gloskey[printglossary]{title} key sets the title used in the glossary section % header. This overrides the title used in \ics{newglossary}. +%\changes{3.03}{2012/09/21}{allow title to set toctitle} % \begin{macrocode} -\define@key{printgloss}{title}{\def\glossarytitle{#1}} +\define@key{printgloss}{title}{% + \def\glossarytitle{#1}% + \let\gls@dotoctitle\relax +} % \end{macrocode} % The \gloskey[printglossary]{toctitle} sets the text used for the relevant entry % in the table of contents. % \begin{macrocode} -\define@key{printgloss}{toctitle}{\def\glossarytoctitle{#1}% -\let\gls@dotoctitle\relax +\define@key{printgloss}{toctitle}{% + \def\glossarytoctitle{#1}% + \let\gls@dotoctitle\relax } % \end{macrocode} % The \gloskey[printglossary]{style} key sets the glossary style (but only for @@ -11734,7 +11780,7 @@ false,nolabel,autolabel}[nolabel]{% % This defines an in-line style where the entries are % comma-separated with just the name and description displayed. % \begin{macrocode} -\ProvidesPackage{glossary-inline}[2012/05/21 v1.0 (NLCT)] +\ProvidesPackage{glossary-inline}[2012/09/21 v3.03 (NLCT)] % \end{macrocode} % %\begin{style}{inline} @@ -11749,6 +11795,7 @@ false,nolabel,autolabel}[nolabel]{% {% \def\gls@inlinesep{}% \def\gls@inlinesubsep{}% + \def\gls@inlinepostchild{}% }% {\glspostinline}% % \end{macrocode} @@ -11756,37 +11803,44 @@ false,nolabel,autolabel}[nolabel]{% % \begin{macrocode} \renewcommand*{\glossaryheader}{}% % \end{macrocode} -% No group headings: +% No group headings (if heading is required, add +% \ics{glsinlinedopostchild} to start definition in case heading +% follows a child entry): % \begin{macrocode} \renewcommand*{\glsgroupheading}[1]{}% % \end{macrocode} % Just display separator followed by name and description: % \begin{macrocode} - \renewcommand*{\glossaryentryfield}[5]{% + \renewcommand{\glossaryentryfield}[5]{% + \glsinlinedopostchild \gls@inlinesep - \glsentryitem{##1}\glstarget{##1}{##2}% \def\glo@desc{##3}% \def\@no@post@desc{\nopostdesc}% + \glsentryitem{##1}\glsinlinenameformat{##1}{##2}% \ifx\glo@desc\@no@post@desc + \glsinlineemptydescformat{##4}{##5}% \else - \ifstrempty{##3}{}{\space##3}% + \ifstrempty{##3}% + {\glsinlineemptydescformat{##4}{##5}}% + {\glsinlinedescformat{##3}{##4}{##5}}% \fi \ifglshaschildren{##1}% {% \glsresetsubentrycounter \glsinlineparentchildseparator \def\gls@inlinesubsep{}% + \def\gls@inlinepostchild{\glsinlinepostchild}% }% {}% \def\gls@inlinesep{\glsinlineseparator}% }% % \end{macrocode} -% Sub-entries display description but no name: +% Sub-entries display description: % \begin{macrocode} - \renewcommand*{\glossarysubentryfield}[6]{% + \renewcommand{\glossarysubentryfield}[6]{% \gls@inlinesubsep% - \glstarget{##2}{}% - \glssubentryitem{##2}##4% + \glsinlinesubnameformat{##2}{##3}% + \glssubentryitem{##2}\glsinlinesubdescformat{##4}{##5}{##6}% \def\gls@inlinesubsep{\glsinlinesubseparator}% }% % \end{macrocode} @@ -11797,6 +11851,15 @@ false,nolabel,autolabel}[nolabel]{% % \end{macrocode} %\end{style} % +%\begin{macro}{\glsinlinedopostchild} +% \begin{macrocode} +\newcommand*{\glsinlinedopostchild}{% + \gls@inlinepostchild + \def\gls@inlinepostchild{}% +} +% \end{macrocode} +%\end{macro} +% %\begin{macro}{\glsinlineseparator} % Separator to use between entries. % \begin{macrocode} @@ -11818,12 +11881,66 @@ false,nolabel,autolabel}[nolabel]{% % \end{macrocode} %\end{macro} % +%\begin{macro}{\glsinlinepostchild} +%\changes{}{}{new} +% Hook to use between child and next entry +% \begin{macrocode} +\newcommand*{\glsinlinepostchild}{} +% \end{macrocode} +%\end{macro} +% %\begin{macro}{\glspostinline} % Terminator for inline glossary. +%\changes{}{}{replaced ``.'' with \cs{glspostdescription}} +% \begin{macrocode} +\newcommand*{\glspostinline}{\glspostdescription\space} +% \end{macrocode} +%\end{macro} +% +%\begin{macro}{\glsinlinenameformat} +%\changes{}{}{new} +% Formats the name of the entry (first argument label, second +% argument name): +% \begin{macrocode} +\newcommand*{\glsinlinenameformat}[2]{\glstarget{#1}{#2}} +% \end{macrocode} +%\end{macro} +% +%\begin{macro}{\glsinlinedescformat} +%\changes{}{}{new} +% Formats the entry's description, symbol and location list: +% \begin{macrocode} +\newcommand*{\glsinlinedescformat}[3]{\space#1} +% \end{macrocode} +%\end{macro} +% +%\begin{macro}{\glsinlineemptydescformat} +%\changes{}{}{new} +% Formats the entry's symbol and location list when the description +% is empty: +% \begin{macrocode} +\newcommand*{\glsinlineemptydescformat}[2]{} +% \end{macrocode} +%\end{macro} +% +%\begin{macro}{\glsinlinesubnameformat} +%\changes{}{}{new} +% Formats the name of the subentry (first argument label, second +% argument name): +% \begin{macrocode} +\newcommand*{\glsinlinesubnameformat}[2]{\glstarget{#1}{}} +% \end{macrocode} +%\end{macro} +% +%\begin{macro}{\glsinlinesubdescformat} +%\changes{}{}{new} +% Formats the subentry's description, symbol and location list: % \begin{macrocode} -\newcommand*{\glspostinline}{.\space} +\newcommand*{\glsinlinesubdescformat}[3]{#1} % \end{macrocode} %\end{macro} +% +% %\iffalse % \begin{macrocode} %</glossary-inline.sty> @@ -11841,7 +11958,7 @@ false,nolabel,autolabel}[nolabel]{% % \ics{item} command, it will appear in a bold font by % default. % \begin{macrocode} -\ProvidesPackage{glossary-list}[2011/03/28 v3.0 (NLCT)] +\ProvidesPackage{glossary-list}[2012/09/21 v3.03 (NLCT)] % \end{macrocode} %\begin{style}{list} % The \glostyle{list} glossary style @@ -11881,8 +11998,9 @@ false,nolabel,autolabel}[nolabel]{% \glstarget{##2}{\strut}##4\glspostdescription\space ##6.}% % \end{macrocode} % Add vertical space between groups: +%\changes{3.03}{2012/09/21}{added check for glsnogroupskip} % \begin{macrocode} - \renewcommand*{\glsgroupskip}{\indexspace}% + \renewcommand*{\glsgroupskip}{\ifglsnogroupskip\else\indexspace\fi}% } % \end{macrocode} %\end{style} @@ -12067,7 +12185,7 @@ false,nolabel,autolabel}[nolabel]{% % The glossary styles defined in the \isty{glossary-long} package % used the \env{longtable} environment in the glossary. % \begin{macrocode} -\ProvidesPackage{glossary-long}[2011/03/28 v3.0 (NLCT)] +\ProvidesPackage{glossary-long}[2012/09/21 v3.03 (NLCT)] % \end{macrocode} % Requires the \isty{longtable} package: % \begin{macrocode} @@ -12132,8 +12250,9 @@ false,nolabel,autolabel}[nolabel]{% \glstarget{##2}{\strut}##4\glspostdescription\space ##6\\}% % \end{macrocode} % Blank row between groups: +%\changes{3.03}{2012/09/21}{added check for glsnogroupskip} % \begin{macrocode} - \renewcommand*{\glsgroupskip}{ & \\}% + \renewcommand*{\glsgroupskip}{\ifglsnogroupskip\else & \\\fi}% } % \end{macrocode} %\end{style} @@ -12233,8 +12352,9 @@ false,nolabel,autolabel}[nolabel]{% \glstarget{##2}{\strut}##4 & ##6\\}% % \end{macrocode} % Blank row between groups: +%\changes{3.03}{2012/09/21}{added check for glsnogroupskip} % \begin{macrocode} - \renewcommand*{\glsgroupskip}{ & &\\}% + \renewcommand*{\glsgroupskip}{\ifglsnogroupskip\else & &\\\fi}% } % \end{macrocode} %\end{style} @@ -12337,8 +12457,9 @@ false,nolabel,autolabel}[nolabel]{% \glstarget{##2}{\strut}##4 & ##5 & ##6\\}% % \end{macrocode} % Blank row between groups: +%\changes{3.03}{2012/09/21}{added check for glsnogroupskip} % \begin{macrocode} - \renewcommand*{\glsgroupskip}{ & & &\\}% + \renewcommand*{\glsgroupskip}{\ifglsnogroupskip\else & & &\\\fi}% } % \end{macrocode} %\end{style} @@ -12509,7 +12630,7 @@ false,nolabel,autolabel}[nolabel]{% % used the \env{longtable} environment in the glossary and use % ragged right formatting for the multiline columns. % \begin{macrocode} -\ProvidesPackage{glossary-longragged}[2011/03/28 v3.0 (NLCT)] +\ProvidesPackage{glossary-longragged}[2012/09/21 v3.03 (NLCT)] % \end{macrocode} % Requires the \isty{array} package: % \begin{macrocode} @@ -12577,8 +12698,9 @@ false,nolabel,autolabel}[nolabel]{% \tabularnewline}% % \end{macrocode} % Blank row between groups: +%\changes{3.03}{2012/09/21}{added check for glsnogroupskip} % \begin{macrocode} - \renewcommand*{\glsgroupskip}{ & \tabularnewline}% + \renewcommand*{\glsgroupskip}{\ifglsnogroupskip\else & \tabularnewline\fi}% } % \end{macrocode} %\end{style} @@ -12682,8 +12804,9 @@ false,nolabel,autolabel}[nolabel]{% \glstarget{##2}{\strut}##4 & ##6\tabularnewline}% % \end{macrocode} % Blank row between groups: +%\changes{3.03}{2012/09/21}{added check for glsnogroupskip} % \begin{macrocode} - \renewcommand*{\glsgroupskip}{ & &\tabularnewline}% + \renewcommand*{\glsgroupskip}{\ifglsnogroupskip\else & &\tabularnewline\fi}% } % \end{macrocode} %\end{style} @@ -12791,8 +12914,9 @@ false,nolabel,autolabel}[nolabel]{% \glstarget{##2}{\strut}##4 & ##5 & ##6\tabularnewline}% % \end{macrocode} % Blank row between groups: +%\changes{3.03}{2012/09/21}{added check for glsnogroupskip} % \begin{macrocode} - \renewcommand*{\glsgroupskip}{ & & &\tabularnewline}% + \renewcommand*{\glsgroupskip}{\ifglsnogroupskip\else & & &\tabularnewline\fi}% } % \end{macrocode} %\end{style} @@ -13178,7 +13302,7 @@ false,nolabel,autolabel}[nolabel]{% % The glossary styles defined in the \isty{glossary-super} package % use the \env{supertabular} environment. % \begin{macrocode} -\ProvidesPackage{glossary-super}[2011/03/28 v3.0 (NLCT)] +\ProvidesPackage{glossary-super}[2012/09/21 v3.03 (NLCT)] % \end{macrocode} % Requires the \isty{supertabular} package: % \begin{macrocode} @@ -13248,8 +13372,9 @@ false,nolabel,autolabel}[nolabel]{% \glstarget{##2}{\strut}##4\glspostdescription\space ##6\\}% % \end{macrocode} % Blank row between groups: +%\changes{3.03}{2012/09/21}{added check for glsnogroupskip} % \begin{macrocode} - \renewcommand*{\glsgroupskip}{ & \\}% + \renewcommand*{\glsgroupskip}{\ifglsnogroupskip\else & \\\fi}% } % \end{macrocode} %\end{style} @@ -13358,8 +13483,9 @@ false,nolabel,autolabel}[nolabel]{% \glstarget{##2}{\strut}##4 & ##6\\}% % \end{macrocode} % Blank row between groups: +%\changes{3.03}{2012/09/21}{added check for glsnogroupskip} % \begin{macrocode} - \renewcommand*{\glsgroupskip}{ & &\\}% + \renewcommand*{\glsgroupskip}{\ifglsnogroupskip\else & &\\\fi}% } % \end{macrocode} %\end{style} @@ -13472,8 +13598,9 @@ false,nolabel,autolabel}[nolabel]{% \glstarget{##2}{\strut}##4 & ##5 & ##6\\}% % \end{macrocode} % Blank row between groups: +%\changes{3.03}{2012/09/21}{added check for glsnogroupskip} % \begin{macrocode} - \renewcommand*{\glsgroupskip}{ & & &\\}% + \renewcommand*{\glsgroupskip}{\ifglsnogroupskip\else & & &\\\fi}% } % \end{macrocode} %\end{style} @@ -13656,7 +13783,7 @@ false,nolabel,autolabel}[nolabel]{% % are like those provided by the \isty{glossary-super} package, % except that the multiline columns have ragged right justification. % \begin{macrocode} -\ProvidesPackage{glossary-superragged}[2011/03/28 v3.0 (NLCT)] +\ProvidesPackage{glossary-superragged}[2012/09/21 v3.03 (NLCT)] % \end{macrocode} % Requires the \isty{array} package: % \begin{macrocode} @@ -13727,8 +13854,9 @@ false,nolabel,autolabel}[nolabel]{% \tabularnewline}% % \end{macrocode} % Blank row between groups: +%\changes{3.03}{2012/09/21}{added check for glsnogroupskip} % \begin{macrocode} - \renewcommand*{\glsgroupskip}{ & \tabularnewline}% + \renewcommand*{\glsgroupskip}{\ifglsnogroupskip\else & \tabularnewline\fi}% } % \end{macrocode} %\end{style} @@ -13839,8 +13967,9 @@ false,nolabel,autolabel}[nolabel]{% \glstarget{##2}{\strut}##4 & ##6\tabularnewline}% % \end{macrocode} % Blank row between groups: +%\changes{3.03}{2012/09/21}{added check for glsnogroupskip} % \begin{macrocode} - \renewcommand*{\glsgroupskip}{ & &\tabularnewline}% + \renewcommand*{\glsgroupskip}{\ifglsnogroupskip\else & &\tabularnewline\fi}% } % \end{macrocode} %\end{style} @@ -13956,8 +14085,9 @@ false,nolabel,autolabel}[nolabel]{% \glstarget{##2}{\strut}##4 & ##5 & ##6\tabularnewline}% % \end{macrocode} % Blank row between groups: +%\changes{3.03}{2012/09/21}{added check for glsnogroupskip} % \begin{macrocode} - \renewcommand*{\glsgroupskip}{ & & &\tabularnewline}% + \renewcommand*{\glsgroupskip}{\ifglsnogroupskip\else & & &\tabularnewline\fi}% } % \end{macrocode} %\end{style} @@ -14052,7 +14182,7 @@ false,nolabel,autolabel}[nolabel]{% % that have a tree-like structure. These are designed for % hierarchical glossaries. % \begin{macrocode} -\ProvidesPackage{glossary-tree}[2011/03/28 v3.0 (NLCT)] +\ProvidesPackage{glossary-tree}[2012/09/21 v3.03 (NLCT)] % \end{macrocode} % %\begin{style}{index} @@ -14123,8 +14253,9 @@ false,nolabel,autolabel}[nolabel]{% \space##4\glspostdescription\space ##6}% % \end{macrocode} % Vertical gap between groups is the same as that used by indices: +%\changes{3.03}{2012/09/21}{added check for glsnogroupskip} % \begin{macrocode} - \renewcommand*{\glsgroupskip}{\indexspace}} + \renewcommand*{\glsgroupskip}{\ifglsnogroupskip\else\indexspace\fi}} % \end{macrocode} %\end{style} % @@ -14227,8 +14358,9 @@ false,nolabel,autolabel}[nolabel]{% % \end{macrocode} % Vertical gap between groups is the same as that used by % indices: +%\changes{3.03}{2012/09/21}{added check for glsnogroupskip} % \begin{macrocode} - \renewcommand*{\glsgroupskip}{\indexspace}} + \renewcommand*{\glsgroupskip}{\ifglsnogroupskip\else\indexspace\fi}} % \end{macrocode} %\end{style} % @@ -14337,8 +14469,9 @@ false,nolabel,autolabel}[nolabel]{% ##4\glspostdescription\space ##6\par}% % \end{macrocode} % Vertical gap between groups is the same as that used by indices: +%\changes{3.03}{2012/09/21}{added check for glsnogroupskip} % \begin{macrocode} - \renewcommand*{\glsgroupskip}{\indexspace}% + \renewcommand*{\glsgroupskip}{\ifglsnogroupskip\else\indexspace\fi}% } % \end{macrocode} %\end{style} @@ -14557,8 +14690,9 @@ false,nolabel,autolabel}[nolabel]{% }% % \end{macrocode} % Vertical gap between groups is the same as that used by indices: +%\changes{3.03}{2012/09/21}{added check for glsnogroupskip} % \begin{macrocode} - \renewcommand*{\glsgroupskip}{\indexspace}% + \renewcommand*{\glsgroupskip}{\ifglsnogroupskip\else\indexspace\fi}% } % \end{macrocode} %\end{style} @@ -21338,8 +21472,8 @@ description={the hash symbol}} # File : glossaries.perl # Author : Nicola L.C. Talbot # Date : 14th June 2007 -# Last Modified : 25th July 2008 -# Version : 1.04 +# Last Modified : 2012-09-21 +# Version : 1.05 # Description : LaTeX2HTML (limited!) implementation of glossaries # package. Note that not all the glossaries.sty # macros have been implemented. @@ -21362,11 +21496,22 @@ description={the hash symbol}} # This work consists of the files glossaries.dtx and glossaries.ins # and the derived files glossaries.sty, glossary-hypernav.sty, # glossary-list.sty, glossary-long.sty, glossary-super.sty, -# glossaries.perl. Also makeglossaries and makeglossaries.bat +# glossaries.perl, mfrstuc.perl. Also makeglossaries and makeglossaries.bat package main; +&do_require_package("mfirstuc"); + + %glossary_style = (); + &set_glossarystyle('altlist');# default style + + $CURRENT_STYLE='altlist'; + +&process_commands_nowrap_in_tex( <<_RAW_ARG_CMDS_); +newglossarystyle # {} # {} +_RAW_ARG_CMDS_ + # These are the only package options implemented. sub do_glossaries_style_altlist{ @@ -21378,8 +21523,20 @@ sub do_glossaries_toc{ sub do_glossaries_toc_true{ } +$INDEXONLYFIRST=0; + +sub do_glossaries_indexonlyfirst{ + $INDEXONLYFIRST=1; +} + +$gls_nonumberlist{'main'} = 0; + +sub do_glossaries_nonumberlist{ + $gls_nonumberlist{'main'} = 1; +} + $GLSCURRENTFORMAT="textrm" if (!defined($GLSCURRENTFORMAT)); -$GLOSSARY_END_DESCRIPTION = '. ' if (!defined($GLOSSARY_END_DESCRIPTION)); +$GLOSSARY_END_DESCRIPTION = '.' if (!defined($GLOSSARY_END_DESCRIPTION)); sub do_cmd_glossaryname{ "Glossary$_[0]" @@ -21388,6 +21545,7 @@ sub do_cmd_glossaryname{ $gls_mark{'main'} = "<tex2html_gls_main_mark>"; $gls_file_mark{'main'} = "<tex2html_gls_main_file_mark>"; $gls_title{'main'} = "\\glossaryname"; +$gls_toctitle{'main'} = "\\glossaryname"; $delimN{'main'} = ", "; $glsnumformat{'main'} = $GLSCURRENTFORMAT; @{$gls_entries{'main'}} = (); @@ -21407,7 +21565,7 @@ sub do_glossaries_acronym_true{ $acronymtype = 'acronym'; } -sub do_glossary_acronym_false{ +sub do_glossaries_acronym_false{ $acronymtype = 'main'; } @@ -21419,6 +21577,63 @@ sub do_cmd_acronymtype{ join('', $acronymtype, $_[0]); } +$global{'glossaryentry'} = 0; +$global{'glossarysubentry'} = 0; + +sub do_cmd_theglossaryentry{ + join('', $global{'glossaryentry'}, $_[0]); +} + +sub do_cmd_theglossarysubentry{ + join('', $global{'glossarysubentry'}, $_[0]); +} + +sub do_glossaries_entrycounter{ + &do_glossaries_entrycounter_true +} + +sub do_glossaries_entrycounter_true{ + eval(<<'_END_DEF'); + sub do_cmd_glsresetentrycounter{ + $global{'entrycounter'} = 0; + $_[0]; + } +_END_DEF +} + +sub do_glossaries_entrycounter_false{ + eval(<<'_END_DEF'); + sub do_cmd_glsresetentrycounter{ + $_[0]; + } +_END_DEF +} + +sub do_cmd_glsresetentrycounter{$_[0];} + +sub do_glossaries_subentrycounter{ + &do_glossaries_subentrycounter_true +} + +sub do_glossaries_subentrycounter_true{ + eval(<<'_END_DEF'); + sub do_cmd_glsresetsubentrycounter{ + $global{'subentrycounter'} = 0; + $_[0]; + } +_END_DEF +} + +sub do_glossaries_subentrycounter_false{ + eval(<<'_END_DEF'); + sub do_cmd_glsresetsubentrycounter{ + $_[0]; + } +_END_DEF +} + +sub do_cmd_glsresetsubentrycounter{ $_[0]; } + # modify set_depth_levels so that glossary is added sub replace_glossary_markers{ @@ -21434,7 +21649,7 @@ sub replace_glossary_markers{ } # there must be a better way of doing this -# other than copying the orginal code and adding to it. +# other than copying the original code and adding to it. sub replace_general_markers { if (defined &replace_infopage_hook) {&replace_infopage_hook if (/$info_page_mark/);} else { &replace_infopage if (/$info_page_mark/); } @@ -21483,28 +21698,256 @@ local(@styles) = split(/\s*,\s*/,$INDEX_STYLES); &add_real_gls } +sub gls_compare{ + local($x, $y) = @_; + + if ($x eq '' or $y eq '') + { + if ($x ne '') + { + # y is the shorter string + return 1; + } + elsif ($y ne '') + { + # x is the shorter string + return -1; + } + else + { + # both empty + return 0; + } + } + + local($x0) = ''; + local($y0) = ''; + + if ($x=~s/^(&#(?:\d+|x[\da-f]+);)//) + { + $x0 = $1; + } + elsif ($x=~s/^(.)//) + { + $x0 = $1; + } + + if ($y=~s/^(&#(?:\d+|x[\da-f]+);)//) + { + $y0 = $1; + } + elsif ($y=~s/^(.)//) + { + $y0 = $1; + } + + local($numx); + + if ($x0=~/&#(\d+|x[\da-f]+);/) + { + $numx = $1; + + $numx = hex("0$numx") if $numx=~/^x/; + } + else + { + $numx = ord($x0); + } + + local($numy); + + if ($y0=~/&#(\d+|x[\da-f]+);/) + { + $numy = $1; + + $numy = hex("0$numy") if $numy=~/^x/; + } + else + { + $numy = ord($y0); + } + + if ($numx == $numy) + { + return &gls_compare($x, $y); + } + elsif ($numx >= 48 and $numx <= 57) # x in range '0' ... '9' + { + if ($numy >= 48 and $numy <= 57) # y in range '0' ... '9' + { + return $numx <=> $numy; + } + elsif (($numy >= 97 and $numy <= 122) or ($numy >= 65 and $numy <= 90)) # y a letter + { + # digits are less than letters + return -1; + } + else + { + # digits are greater than symbols + return 1; + } + } + elsif (($numx >= 97 and $numx <= 122) or ($numx >= 65 and $numx <= 90)) # x a letter + { + if (($numy >= 97 and $numy <= 122) or ($numy >= 65 and $numy <= 90)) # y a letter + { + if (($numx <= 90 and $numy <= 90) or ($numx >= 97 and $numy >= 97)) + { + # same case (already checked if they are equal) + + return $numx <=> $numy; + } + + # are they upper/lower case versions of each other? + + if (($numx >= 97 and $numy == $numx-32)) + { + # x is upper case version of y + + if ($x or $y) + { + return &gls_compare($x, $y); + } + else + { + return -1; + } + } + + if (($numy >= 97 and $numx == $numy-32)) + { + # y is upper case version of x + + if ($x or $y) + { + return &gls_compare($x, $y); + } + else + { + return 1; + } + } + + # compare lower case values + return lc(chr($numx)) cmp lc(chr($numy)); + } + else + { + # a-z greater than symbols and digits + return 1; + } + } + elsif ($numy >= 48 and $numy <= 57) # y in range '0' ... '9' + { + # already checked for '0' < x < '9' and '0' < y < '9' + # already checked for 'a' < x < 'z' and '0' < y < '9' + + # digits greater than symbols + return 1; + } + elsif (($numy >= 97 and $numy <= 122) or ($numy >= 65 and $numy <= 90)) # y is a letter + { + # already checked for x is digit and y a is letter + # already checked for x is letter and y a is letter + + # symbols and digits are less than letters + + return -1; + } + + $numx <=> $numy +} + sub gloskeysort{ - local($x, $y) = ($a, $b); - $x=~s/^(.*)###(\d+)$/\l\1/; - local($x_id) = $2; - $y=~s/^(.*)###(\d+)$/\l\1/; + + $a=~/^(.*)###(\d+)$/; + + local($labelx) = $1; + local($x_id) =$2; + + $b=~/^(.*)###(\d+)$/; + + local($labely) = $1; local($y_id) = $2; - local($n) = ($x cmp $y); + local($sortx) = &gls_get_sort($labelx); + local($sorty) = &gls_get_sort($labely); - if ($n == 0) + local($n); + + # are they case-insensitive equivalent? + + if (lc($sortx) eq lc($sorty)) + { + $n = ($sortx cmp $sorty); + } + else + { + $n = &gls_compare($sortx, $sorty); + } + + unless ($n) { $n = ($x_id <=> $y_id); } - $n; + $n +} + +sub add_parent_if_required{ + local($label) = @_; + + local($parent) = &gls_get_parent($label); + + if ($parent) + { + local($type) = &gls_get_type($parent); + + # does this parent have a backlink? + + for my $key (keys %{$glossary{$type}}) + { + return if $key=~/^$parent###\d+$/; + } + + # none found, so add empty one + + my $id = ++$global{'max_id'}; + + $glossary{$type}{"$parent###$id"} = ''; + $glossary_entry{$type}{"$parent###$id"} = $parent; + + # check if parent also has a parent + + &add_parent_if_required($parent); + } } sub add_real_gls{ local($type) = @_; print "\nDoing glossary '$type' ..."; - local($key, $str, @keys, $glossary, $level, $count, - @previous, @current, $id, $linktext, $delimN); + local($key, $str, @keys, $thisglsentry, $level, $count, + $previous, $current, $id, $linktext, $delimN); + + $TITLE = $gls_toctitle{$type}; + + local($oldstyle) = $CURRENT_STYLE; + + if ($gls_style{$type}) + { + &set_glossarystyle($gls_style{$type}); + } + + # add any parent entries that haven't been referenced + + for my $key (keys %{$glossary{$type}}) + { + my $label = $key; + $label =~ s/###\d+$//o; # Remove the unique id's + + &add_parent_if_required($label); + } @keys = keys %{$glossary{$type}}; @@ -21514,47 +21957,624 @@ sub add_real_gls{ $delimN = $delimN{$type}; + $previous = ''; + + local($previousentry) = ''; + + my $glossaryentryfield = ''; + + my $previouscat = ''; + + local ($entry); + foreach $key (@keys) { $current = $key; - $str = $current; - $str =~ s/\#\#\#\d+$//o; # Remove the unique id's - #$linktext = $cross_ref_visible_mark; - $id = ++$global{'max_id'}; - $linktext = "\\$glossary_format{$type}{$key}${OP}$id${CP}$glossary_linktext{$type}{$key}${OP}$id${CP}"; - $linktext = &translate_commands($linktext); + $current =~ s/\#\#\#\d+$//o; # Remove the unique id's - local($entry) = $glossary_entry{$type}{$key}; + my $issame = ($current eq $previous ? 1 : 0); - $id = ++$global{'max_id'}; - local($name) = &translate_commands( - "\\glsnamefont $OP$id$CP$glsentry{$entry}{name}$OP$id$CP"); - - local($symbol) = ($glsentry{$entry}{'symbol'} ? - " $glsentry{$entry}{symbol}" : ''); - - $glossary .= - # If it's the same string don't start a new line - (&index_key_eq($current, $previous) ? - $delimN - . $glossary{$type}{$key} - . $linktext - . "</A>" - : "<DT>" - . "<A NAME=\"gls:$entry\">$name</A>" - . "<DD>" - . $glsentry{$entry}{'description'} - . $symbol . $GLOSSARY_END_DESCRIPTION - . $glossary{$type}{$key} - . $linktext. "</A>"); $previous = $current; + + $entry = $glossary_entry{$type}{$key}; + + unless ($issame) + { + if ($glossaryentryfield) + { + $id = ++$global{'max_id'}; + + my $level = &gls_get_level($previousentry); + + if ($level > 0) + { + my $id2 = ++$global{'max_id'}; + + $thisglsentry .= + "\\glossarysubentryfield $OP$id2$CP$level$OP$id2$CP$glossaryentryfield$OP$id$CP$linktext$OP$id$CP"; + } + else + { + $thisglsentry .= + "\\glossaryentryfield $glossaryentryfield$OP$id$CP$linktext$OP$id$CP"; + } + + $glossaryentryfield = ''; + } + + $linktext = ''; + + my $currentcat = substr(&gls_get_sort($current), 0, 1); + + if ($currentcat=~/[a-zA-Z]/) + { + $currentcat = uc($currentcat); + } + elsif ($currentcat=~/[0-9]/) + { + $currentcat = 'glsnumbers'; + } + else + { + $currentcat = 'glssymbols'; + } + + unless ($previouscat eq $currentcat) + { + $id = ++$global{'max_id'}; + $thisglsentry .= "\\glsgroupheading$OP$id$CP$currentcat$OP$id$CP"; + + $previouscat = $currentcat; + } + } + + $previousentry = $entry; + + # Back ref + + if ($gls_nonumberlist{$type}) + { + $linktext = ''; + } + elsif ($glossary{$type}{$key}) + { + $id = ++$global{'max_id'}; + + $linktext .= $delimN if ($linktext); + + $linktext .= "$glossary{$type}{$key}\\$glossary_format{$type}{$key}${OP}$id${CP}$glossary_linktext{$type}{$key}${OP}$id${CP}</A>"; + + } + + unless ($issame) + { + $id = ++$global{'max_id'}; + local($name) = &translate_commands( + "\\glsnamefont $OP$id$CP$glsentry{$entry}{name}$OP$id$CP"); + + local($symbol) = ($glsentry{$entry}{'symbol'} ? + " $glsentry{$entry}{symbol}" : ''); + + $id = ++$global{'max_id'}; + my $id2 = ++$global{'max_id'}; + my $id3 = ++$global{'max_id'}; + my $id4 = ++$global{'max_id'}; + + $glossaryentryfield = "$OP$id$CP$entry$OP$id$CP" # label + . "$OP$id2$CP$name$OP$id2$CP" # name + . "$OP$id3$CP$glsentry{$entry}{description}$OP$id3$CP" # description + . "$OP$id4$CP$symbol$OP$id4$CP" # symbol + } + + } + + if ($glossaryentryfield and $entry) + { + my $level = &gls_get_level($entry); + + if ($level > 0) + { + my $id2 = ++$global{'max_id'}; + + $thisglsentry .= + "\\glossarysubentryfield $OP$id2$CP$level$OP$id2$CP$glossaryentryfield$OP$id$CP$linktext$OP$id$CP"; + } + else + { + $id = ++$global{'max_id'}; + $thisglsentry .= + "\\glossaryentryfield $glossaryentryfield$OP$id$CP$linktext$OP$id$CP"; + } + } + + $str = &do_env_theglossary($thisglsentry) . &translate_commands("\\glossarypostamble"); + + if ($gls_style{$type}) + { + &set_glossarystyle($oldstyle); + } + + s/$gls_mark{$type}/$preglossary\n$str\n/s; +} + +sub do_cmd_glstarget{ + local($_) = @_; + + local($id, $label, $text); + + $label = &missing_braces unless + s/$next_pair_pr_rx/$id=$1;$label=$2;''/eo; + + $text = &missing_braces unless + s/$next_pair_pr_rx/$id=$1;$text=$2;''/eo; + + "<A NAME=\"gls:$label\">$text</A>$_"; +} + +sub do_cmd_newglossarystyle{ + local($_) = @_; + + local($id,$style,$defs); + + $style = &missing_braces unless + s/$next_pair_rx/$id=$1;$style=$2;''/eo; + + $defs = &missing_braces unless + s/$next_pair_rx/$id=$1;$defs=$2;''/eo; + + $glossary_style{$style} = $defs; + + $_; +} + +sub do_cmd_glossarystyle{ + local($_) = @_; + + local($id,$style); + + $style = &missing_braces unless + s/$next_pair_pr_rx/$id=$1;$style=$2;''/eo; + + &set_glossarystyle($style); + + $_; +} + +sub set_glossarystyle{ + local($style) = @_; + + $CURRENT_STYLE = $style; + + if ($glossary_style{$style}) + { + local($_) = $glossary_style{$style}; + + s/$O(\d+)$C/$OP$1$CP/g; + + &translate_commands($_); + } + else + { + my $cmd_sub = "set_glossarystyle_$style"; + + if (defined(&$cmd_sub)) + { + &$cmd_sub(); + } + else + { + &write_warnings("Unknown glossary style '$style', defaulting to 'altlist'"); + &set_glossarystyle_altlist(); + + $CURRENT_STYLE = 'altlist'; + } } - $glossary = '<DD>'.$glossary unless ($glossary =~ /^\s*<D(T|D)>/); - $glossary =~ s/(<A [^>]*>)(<D(T|D)>)/$2$1/g; +} + +sub do_cmd_glspar{ "<P>".$_[0]; } + +sub do_cmd_glossaryheader{ + local($_) = @_; + $_ +} + +sub do_cmd_glsentryitem{ + local($_) = @_; + + local($id, $label); - $str = &translate_commands("\\glossarypostamble"); - s/$gls_mark{$type}/$preglossary\n<DL COMPACT>\n$glossary<\/DL>$str\n/s; + $label = &missing_braces unless + s/$next_pair_pr_rx/$id=$1,$label=$2;''/eo; + + $_ +} + +sub do_cmd_glssubentryitem{ + local($_) = @_; + + local($id, $label); + + $label = &missing_braces unless + s/$next_pair_pr_rx/$id=$1,$label=$2;''/eo; + + $_ +} + +sub do_cmd_glsgroupheading{ + local($_) = @_; + + local($id, $heading); + + $heading = &missing_braces unless + s/$next_pair_pr_rx/$id=$1,$heading=$2;''/eo; + + $_; +} + +sub do_cmd_glossaryentryfield{ + local($_) = @_; + + local($id, $label, $name, $desc, $symbol, $backlink); + + $label = &missing_braces unless + s/$next_pair_pr_rx/$id=$1;$label=$2;''/eo; + + $name = &missing_braces unless + s/$next_pair_pr_rx/$id=$1;$name=$2;''/eo; + + $desc = &missing_braces unless + s/$next_pair_pr_rx/$id=$1;$desc=$2;''/eo; + + $symbol = &missing_braces unless + s/$next_pair_pr_rx/$id=$1;$symbol=$2;''/eo; + + $backlink = &missing_braces unless + s/$next_pair_pr_rx/$id=$1;$backlink=$2;''/eo; + + local($id2) = ++$global{'max_id'}; + + "\\glstarget $OP$id$CP$label$OP$id$CP$OP$id2$CP$name$OP$id2$CP\n$desc $backlink\n$_"; +} + +sub do_cmd_glossarysubentryfield{ + local($_) = @_; + + local($id, $level, $label, $name, $desc, $symbol, $backlink); + + $level = &missing_braces unless + s/$next_pair_pr_rx/$id=$1;$level=$2;''/eo; + + $label = &missing_braces unless + s/$next_pair_pr_rx/$id=$1;$label=$2;''/eo; + + $name = &missing_braces unless + s/$next_pair_pr_rx/$id=$1;$name=$2;''/eo; + + $desc = &missing_braces unless + s/$next_pair_pr_rx/$id=$1;$desc=$2;''/eo; + + $symbol = &missing_braces unless + s/$next_pair_pr_rx/$id=$1;$symbol=$2;''/eo; + + $backlink = &missing_braces unless + s/$next_pair_pr_rx/$id=$1;$backlink=$2;''/eo; + + local($id2) = ++$global{'max_id'}; + + "\\glstarget $OP$id$CP$label$OP$id$CP$OP$id2$CP$name$OP$id2$CP\n$desc $backlink\n$_"; +} + +sub do_env_theglossary{ + local($_) = @_; + + &translate_commands($_); +} + +sub set_glossarystyle_altlist{ + eval(<<'END_STYLE'); + sub do_cmd_glossaryheader{ + local($_) = @_; + $_ + } + + sub do_cmd_glsgroupheading{ + local($_) = @_; + + local($id, $heading); + + $heading = &missing_braces unless + s/$next_pair_pr_rx/$id=$1,$heading=$2;''/eo; + + $_ + } + + sub do_cmd_glossaryentryfield{ + local($_) = @_; + + local($id, $id2, $id3, $id4, $id5, $label, $name, $desc, $symbol, $backlink); + + $label = &missing_braces unless + s/$next_pair_pr_rx/$id=$1;$label=$2;''/eo; + + $name = &missing_braces unless + s/$next_pair_pr_rx/$id2=$1;$name=$2;''/eo; + + $desc = &missing_braces unless + s/$next_pair_pr_rx/$id3=$1;$desc=$2;''/eo; + + $symbol = &missing_braces unless + s/$next_pair_pr_rx/$id4=$1;$symbol=$2;''/eo; + + $backlink = &missing_braces unless + s/$next_pair_pr_rx/$id5=$1;$backlink=$2;''/eo; + + "<DT>\\glstarget $OP$id$CP$label$OP$id$CP$OP$id2$CP$name$OP$id2$CP\n<DD>" + . "$desc\\glspostdescription\\space $backlink$_"; + } + + sub do_cmd_glossarysubentryfield{ + local($_) = @_; + + local($id, $id2, $id3, $id4, $id5, $id6, $level, + $label, $name, $desc, $symbol, $backlink); + + $level = &missing_braces unless + s/$next_pair_pr_rx/$id=$1;$level=$2;''/eo; + + $label = &missing_braces unless + s/$next_pair_pr_rx/$id2=$1;$label=$2;''/eo; + + $name = &missing_braces unless + s/$next_pair_pr_rx/$id3=$1;$name=$2;''/eo; + + $desc = &missing_braces unless + s/$next_pair_pr_rx/$id4=$1;$desc=$2;''/eo; + + $symbol = &missing_braces unless + s/$next_pair_pr_rx/$id5=$1;$symbol=$2;''/eo; + + $backlink = &missing_braces unless + s/$next_pair_pr_rx/$id6=$1;$backlink=$2;''/eo; + + "<P>\\glssubentryitem $OP$id$CP$label$OP$id$CP" + ."\\glstarget $OP$id2$CP$label$OP$id2$CP$OP$id3$CP$name$OP$id3$CP" + ."$desc\\glspostdescription\\space $backlink\n$_"; + } + + sub do_env_theglossary{ + local($_) = @_; + + "<DL>".&translate_commands("\\glossaryheader $_")."</DL>"; + } +END_STYLE +} + +sub set_glossarystyle_inline{ + eval(<<'END_STYLE'); + sub do_cmd_glossaryheader{ + local($_) = @_; + $_ + } + + sub do_cmd_glsgroupheading{ + local($_) = @_; + + local($id, $heading); + + $heading = &missing_braces unless + s/$next_pair_pr_rx/$id=$1,$heading=$2;''/eo; + + $_; + } + + sub do_cmd_glossaryentryfield{ + local($_) = @_; + + local($id, $id2, $id3, $id4, $id5, $label, $name, $desc, $symbol, $backlink); + + $label = &missing_braces unless + s/$next_pair_pr_rx/$id=$1;$label=$2;''/eo; + + $name = &missing_braces unless + s/$next_pair_pr_rx/$id2=$1;$name=$2;''/eo; + + $desc = &missing_braces unless + s/$next_pair_pr_rx/$id3=$1;$desc=$2;''/eo; + + $symbol = &missing_braces unless + s/$next_pair_pr_rx/$id4=$1;$symbol=$2;''/eo; + + $backlink = &missing_braces unless + s/$next_pair_pr_rx/$id5=$1;$backlink=$2;''/eo; + + local($field) = "\\glsinlinedopostchild $glsinlinesep"; + + $field .= "\\glsentryitem $OP$id$CP$label$OP$id$CP" + . "\\glsinlinenameformat $OP$id2$CP$label$OP$id2$CP$OP$id3$CP$name$OP$id3$CP"; + + $id3 = ++$global{'max_id'}; + + if ($desc) + { + $field .= + "\\glsinlinedescformat $OP$id3$CP$desc$OP$id3$CP" + ."$OP$id4$CP$symbol$OP$id4$CP" + ."$OP$id5$CP$backlink$OP$id5$CP"; + } + else + { + $field .= + "\\glsinlineemptydescformat " + ."$OP$id4$CP$symbol$OP$id4$CP" + ."$OP$id5$CP$backlink$OP$id5$CP"; + } + +# TODO : check if has children + + local($haschildren) = 0; + + if ($haschildren) + { + $field .= "\\glsresetsubentrycounter " + . "\\glsinlineparentchildseparator " + . "\\glsinlinepostchild "; + } + + $glsinlinesep = &translate_commands("\\glsinlineseparator ") + unless $glsinlinesep; + + $field.$_; + } + + sub do_cmd_glossarysubentryfield{ + local($_) = @_; + + local($id, $id2, $id3, $id4,$id5,$id6,$level, + $label, $name, $desc, $symbol, $backlink); + + $level = &missing_braces unless + s/$next_pair_pr_rx/$id=$1;$level=$2;''/eo; + + $label = &missing_braces unless + s/$next_pair_pr_rx/$id2=$1;$label=$2;''/eo; + + $name = &missing_braces unless + s/$next_pair_pr_rx/$id3=$1;$name=$2;''/eo; + + $desc = &missing_braces unless + s/$next_pair_pr_rx/$id4=$1;$desc=$2;''/eo; + + $symbol = &missing_braces unless + s/$next_pair_pr_rx/$id5=$1;$symbol=$2;''/eo; + + $backlink = &missing_braces unless + s/$next_pair_pr_rx/$id6=$1;$backlink=$2;''/eo; + + "\\glsinlinesubnameformat $OP$id$CP$label$OP$id$CP$OP$id2$CP$name$OP$id2$CP" + ."\\glssubentryitem $OP$id3$CP$label$OP$id3$CP" + ."\\glsinlinesubdescformat $OP$id4$CP$desc$OP$id4$CP$OP$id5$CP$symbol$OP$id5$CP$OP$id6$CP$backlink$OP$id6$CP" + .$_; + } + + sub do_env_theglossary{ + local($_) = @_; + + $glsinlinesep = ''; + + &translate_commands("\\glossaryheader $_\\glspostinline "); + } +END_STYLE +} + +local($glsinlinesep,$glsinlinepostchild); + +sub do_cmd_glsinlineseparator{ + local($_) = @_; + + "; $_"; +} + +sub do_cmd_glsinlinedopostchild{ + local($_) = @_; + + $_; +} + +sub do_cmd_glspostdescription{ + local($_) = @_; + + $GLOSSARY_END_DESCRIPTION.$_; +} + +sub do_cmd_glspostinline{ + local($_) = @_; + + &translate_commands("\\glspostdescription\\space ").$_; +} + +sub do_cmd_glsinlinepostchild{ + local($_) = @_; + + $_; +} + +sub do_cmd_glsinlineparentchildseparator{ + local($_) = @_; + + ": $_"; +} + +sub do_cmd_glsinlinesubseparator{ + local($_) = @_; + + ", $_"; +} + +sub do_cmd_glsinlinenameformat{ + &do_cmd_glstarget(@_); +} + +sub do_cmd_glsinlinedescformat{ + local($_) = @_; + + local($id, $desc, $symbol, $backlinks); + + $desc = &missing_braces unless + s/$next_pair_pr_rx/$id=$1,$desc=$2;''/eo; + + $symbol = &missing_braces unless + s/$next_pair_pr_rx/$id=$1,$symbol=$2;''/eo; + + $backlinks = &missing_braces unless + s/$next_pair_pr_rx/$id=$1,$backlinks=$2;''/eo; + + "\\space $desc$_"; +} + +sub do_cmd_glsinlineemptydescformat{ + local($_) = @_; + + local($id, $symbol, $backlinks); + + $symbol = &missing_braces unless + s/$next_pair_pr_rx/$id=$1,$symbol=$2;''/eo; + + $backlinks = &missing_braces unless + s/$next_pair_pr_rx/$id=$1,$backlinks=$2;''/eo; + + $_; +} + +sub do_cmd_glsinlinesubnameformat{ + local($_) = @_; + + local($id, $id2, $label, $name); + + $label = &missing_braces unless + s/$next_pair_pr_rx/$id=$1,$label=$2;''/eo; + + $name = &missing_braces unless + s/$next_pair_pr_rx/$id2=$1,$name=$2;''/eo; + + "\\glstarget $OP$id$CP$label$OP$id$CP$OP$id2$CP$OP$id2$CP$_"; +} + +sub do_cmd_glsinlinesubdescformat{ + local($_) = @_; + + local($id, $desc, $symbol, $backlinks); + + $desc = &missing_braces unless + s/$next_pair_pr_rx/$id=$1,$desc=$2;''/eo; + + $symbol = &missing_braces unless + s/$next_pair_pr_rx/$id=$1,$symbol=$2;''/eo; + + $backlinks = &missing_braces unless + s/$next_pair_pr_rx/$id=$1,$backlinks=$2;''/eo; + + "$desc$_"; } sub set_depth_levels { @@ -21632,12 +22652,12 @@ sub get_firstkeyval{ } # need to get the value of the last key of a given name -# in the event of multiple occurences. +# in the event of multiple occurrences. sub get_keyval{ local($key,$_) = @_; local($value); - while (/\b$key\s*=/) + while (/\b$key\s*=/g) { ($value,$_) = &get_firstkeyval($key, $_); last unless defined($value); @@ -21646,6 +22666,18 @@ sub get_keyval{ ($value,$_); } +sub get_boolval{ + local($key,$_) = @_; + local($value); + + while (/\b$key\s*(?:=(true|false))?\b/g) + { + $value = ($1 ? $1 : 'true'); + } + + ($value eq 'true' ? 1 : 0, $_); +} + # This is modified from do_cmd_textohtmlindex sub do_cmd_textohtmlglossary{ @@ -21653,18 +22685,22 @@ sub do_cmd_textohtmlglossary{ local($keyval,$pat) = &get_next_optional_argument; - local($type,$title,$toctitle,$style); + local($type,$title,$toctitle,$style,$nonumberlist); + + $nonumberlist = 'default'; ($type,$keyval) = &get_keyval('type', $keyval); ($title,$keyval) = &get_keyval('title', $keyval); ($toctitle,$keyval) = &get_keyval('toctitle', $keyval); ($style,$keyval) = &get_keyval('style', $keyval); + ($nonumberlist,$keyval) = &get_boolval('nonumberlist', $keyval); - &make_textohtmlglossary($type,$toctitle,$title,$style).$_; + &make_textohtmlglossary($type,$toctitle,$title,$style,$nonumberlist).$_; } +# add_real_gls does the actual glossary sub make_textohtmlglossary{ - local($type,$toctitle,$title,$style) = @_; + local($type,$toctitle,$title,$style,$nonumberlist) = @_; unless (defined($type)) {$type = 'main';} @@ -21673,8 +22709,19 @@ sub make_textohtmlglossary{ &write_warnings("glossary type '$type' not implemented"); } - unless (defined($title) and $title) {$title = $gls_title{$type};} - unless (defined($toctitle) and $toctitle) {$toctitle = $title;} + if ($style) + { + $gls_style{$type} = $style; + } + + $toctitle = $gls_toctitle{$type} unless ($toctitle or $title); + + $title = $gls_title{$type} unless ($title); + $toctitle = $title unless ($toctitle); + + $gls_toctitle{$type} = $toctitle; + + $gls_nonumberlist{$type} = $nonumberlist unless ($nonumberlist eq 'default'); $toc_sec_title = $toctitle; $glsfile{$type} = $CURRENT_FILE; @@ -21702,6 +22749,7 @@ sub make_textohtmlglossary{ , &make_section_heading($title, $idx_head) , $gls_mark{$type} ); local($pre,$post) = &minimize_open_tags($heading); + join('',"<BR>\n" , $pre); } @@ -21766,13 +22814,8 @@ sub make_real_glossary_entry { $TITLE = $saved_title if (($saved_title)&&(!($TITLE)||($TITLE eq $default_title))); - local($sort) = $glsentry{$entry}{'sort'}; - # Save the reference - local($str) = "$sort###" . ++$global{'max_id'}; # Make unique - # concatenate multiple spaces into a single space - # otherwise keys won't sort properly - $str=~s/\s+/ /gs; + local($str) = "$label###" . ++$global{'max_id'}; # Make unique local($id) = ++$glsentry{$entry}{'maxid'}; local($glsanchor)="gls:$entry$id"; @@ -21789,13 +22832,46 @@ sub make_real_glossary_entry { $glossary_entry{$type}{$str} = $entry; $glossary_linktext{$type}{$str} = $TITLE; + local($mark) = $gls_file_mark{$type}; + + $mark = &get_gls_file_mark($type, $entry) if (defined(&get_gls_file_mark)); + + $text = &translate_commands($text); + if (defined($frame_foot_name)) { - "<A HREF=$gls_file_mark{$type}#gls:$entry NAME=\"$glsanchor\" TARGET=\"$frame_foot_name\">$text<\/A>"; + "<A HREF=\"$mark#gls:$entry\" NAME=\"$glsanchor\" TARGET=\"$frame_foot_name\">$text<\/A>"; } else { - "<A HREF=$gls_file_mark{$type}#gls:$entry NAME=\"$glsanchor\">$text<\/A>"; + "<A HREF=\"$mark#gls:$entry\" NAME=\"$glsanchor\">$text<\/A>"; + } +} + +sub make_real_glossary_entry_no_backlink { + local($entry,$text,$type) = @_; + local($this_file) = $CURRENT_FILE; + + local($target) = $frame_body_name; + + if (defined($frame_main_suffix)) + { + $this_file=~s/$frame_main_suffix/$frame_body_suffix/; + } + + local($mark) = $gls_file_mark{$type}; + + $mark = &get_gls_file_mark($type, $entry) if (defined(&get_gls_file_mark)); + + $text = &translate_commands($text); + + if (defined($frame_foot_name)) + { + "<A HREF=\"$mark#gls:$entry\" NAME=\"$glsanchor\" TARGET=\"$frame_foot_name\">$text<\/A>"; + } + else + { + "<A HREF=\"$mark#gls:$entry\" >$text<\/A>"; } } @@ -21827,11 +22903,13 @@ sub make_newglossarytype{ $gls_mark{$type} = "<tex2html_gls_${type}_mark>"; $gls_file_mark{$type} = "<tex2html_gls_${type}_file_mark>"; $gls_title{$type} = $title; + $gls_toctitle{$type} = $title; $delimN{$type} = ", "; $glsnumformat{$type} = $GLSCURRENTFORMAT; @{$gls_entries{$type}} = (); $gls_displayfirst{$type} = "glsdisplayfirst"; $gls_display{$type} = "glsdisplay"; + $gls_nonumberlist{$type} = $gls_nonumberlist{'main'}; } sub do_cmd_glsdisplay{ @@ -21969,15 +23047,21 @@ sub gls_entry_init{ ( type => $type, name => $name, 'sort' => $name, - description => $description, + description => $desc, text => $name, first => $name, plural => "${name}s", firstplural => "${name}s", symbol => '', flag => 0, - maxid=>0 + maxid => 0, + level => 0, + parent => '' ); + + $#{@{$glsentry{$label}{children}}} = -1; + + $glsentry{$label}; } sub gls_get_type{ @@ -22241,6 +23325,228 @@ sub gls_set_first{ } } +sub gls_get_parent{ + local($label) = @_; + + local($parent); + + if (&gls_entry_defined($label)) + { + $parent = $glsentry{$label}{'parent'}; + } + else + { + &write_warnings("gls_get_parent: glossary entry '$label' has not been defined"); + } + + $parent; +} + +sub gls_get_level{ + local($label) = @_; + + local($level) = 0; + + if (&gls_entry_defined($label)) + { + $level = $glsentry{$label}{'level'}; + } + else + { + &write_warnings("gls_get_level: glossary entry '$label' has not been defined"); + } + + $level; +} + +sub gls_set_parent{ + local ($label, $parent) = @_; + + if (&gls_entry_defined($label)) + { + if ($parent) + { + if (&gls_entry_defined($parent)) + { + $glsentry{$label}{'parent'} = $parent; + + push @{$glsentry{$parent}{'children'}}, $label; + + $glsentry{$label}{'level'} = $glsentry{$parent}{'level'}+1; + } + else + { + &write_warnings("gls_set_parent: parent '$parent' for glossary entry '$label' has not been defined"); + } + } + else + { + $glsentry{$label}{'parent'} = ''; + } + } + else + { + &write_warnings("gls_set_parent: glossary entry '$label' has not been defined"); + } +} + +sub gls_get_childcount{ + my($label) = @_; + + my($count) = 0; + + if (&gls_entry_defined($label)) + { + $count = scalar(@{$glsentry{$label}{'children'}}); + } + else + { + &write_warnings("gls_get_childcount: glossary entry '$label' has not been defined"); + } + + $count; +} + +sub gls_get_referenced_childcount{ + my($label) = @_; + + my($count) = 0; + + if (&gls_entry_defined($label)) + { + $count = scalar(grep(($glsentry{$_}{'maxid'} > 0), @{$glsentry{$label}{'children'}})); + } + else + { + &write_warnings("gls_get_childcount: glossary entry '$label' has not been defined"); + } + + $count; +} + +sub gls_set_userkeys{ + local($label, @user) = @_; + + if (&gls_entry_defined($label)) + { + for (my $idx = 0; $idx < 6; $idx++) + { + $glsentry{$label}{"user".($idx+1)} = $user[$idx]; + } + } + else + { + &write_warnings("gls_set_user: glossary entry '$label' has not been defined"); + } +} + +sub gls_set_user{ + local($label, $idx, $text) = @_; + + if (&gls_entry_defined($label)) + { + $glsentry{$label}{"user$idx"} = $text; + } + else + { + &write_warnings("gls_set_user: glossary entry '$label' has not been defined"); + } +} + +sub gls_set_useri{ + local($label, $text) = @_; + + if (&gls_entry_defined($label)) + { + $glsentry{$label}{'user1'} = $text; + } + else + { + &write_warnings("gls_set_useri: glossary entry '$label' has not been defined"); + } +} + +sub gls_set_userii{ + local($label, $text) = @_; + + if (&gls_entry_defined($label)) + { + $glsentry{$label}{'user2'} = $text; + } + else + { + &write_warnings("gls_set_userii: glossary entry '$label' has not been defined"); + } +} + +sub gls_set_useriii{ + local($label, $text) = @_; + + if (&gls_entry_defined($label)) + { + $glsentry{$label}{'user3'} = $text; + } + else + { + &write_warnings("gls_set_useriii: glossary entry '$label' has not been defined"); + } +} + +sub gls_set_useriv{ + local($label, $text) = @_; + + if (&gls_entry_defined($label)) + { + $glsentry{$label}{'user4'} = $text; + } + else + { + &write_warnings("gls_set_useriv: glossary entry '$label' has not been defined"); + } +} + +sub gls_set_userv{ + local($label, $text) = @_; + + if (&gls_entry_defined($label)) + { + $glsentry{$label}{'user5'} = $text; + } + else + { + &write_warnings("gls_set_userv: glossary entry '$label' has not been defined"); + } +} + +sub gls_set_uservi{ + local($label, $text) = @_; + + if (&gls_entry_defined($label)) + { + $glsentry{$label}{'user6'} = $text; + } + else + { + &write_warnings("gls_set_uservi: glossary entry '$label' has not been defined"); + } +} + +sub gls_get_user{ + local($label, $idx) = @_; + local($value) = ''; + + if (&gls_entry_defined($label)) + { + $value = $glsentry{$label}{"user".$idx}; + } + else + { + &write_warnings("gls_get_user[$idx]: glossary entry '$label' has not been defined"); + } + + $value; +} + sub gls_used{ local($label) = @_; local($flag) = 0; @@ -22260,13 +23566,13 @@ sub gls_used{ sub gls_entry_defined{ local($label) = @_; - defined(%{$glsentry{$label}}); + (%{$glsentry{$label}}) ? 1 : 0; } sub do_cmd_newglossaryentry{ local($_) = @_; local($label,$name,$description,$symbol,$sort,$text,$first, - $plural,$firstplural,$type,$keyval); + $plural,$firstplural,$type,$keyval,$parent,@user); $label = &missing_braces unless s/$next_pair_pr_rx/$label=$2;''/eo; @@ -22283,6 +23589,19 @@ sub do_cmd_newglossaryentry{ ($firstplural,$keyval) = &get_keyval('firstplural', $keyval); ($plural,$keyval) = &get_keyval('plural', $keyval); ($type,$keyval) = &get_keyval('type', $keyval); + ($parent,$keyval) = &get_keyval('parent', $keyval); + + if ($parent and not $name) + { + $name = &gls_get_name($parent); + } + + @user = (); + + for (my $idx = 0; $idx < 6; $idx++) + { + ($user[$idx],$keyval) = &get_keyval("user".($idx+1), $keyval); + } if (defined($type)) { @@ -22317,6 +23636,10 @@ sub do_cmd_newglossaryentry{ &gls_set_firstplural($label, $firstplural); + &gls_set_userkeys($label, @user); + + &gls_set_parent($label, $parent); + push @{$gls_entries{$type}}, $label; $_; @@ -22423,12 +23746,35 @@ sub do_cmd_glsadd{ $type = &gls_get_type($label); + local($dobacklink) = 1; + + if (&gls_used($label)) + { + if ($INDEXONLYFIRST) + { + $dobacklink = 0; + } + } + else + { + &unset_entry($label); + } + if (defined $type) { ($format,$optarg) = &get_keyval('format', $optarg); $format='' unless(defined($format)); - &gls_add_entry($type,$label,$format,""); + if ($dobacklink) + { + &gls_add_entry($type,$label,$format,""); + } + else + { + $glsentry{$label}{'maxid'} = ++$glsentry{$entry}{'maxid'}; + my $key = $label."###".$glsentry{$label}{'maxid'}; + $glossary{$type}{$key}=''; + } } else { @@ -22443,28 +23789,45 @@ sub do_cmd_glsaddall{ local($_) = @_; local($optarg,$pat) = &get_next_optional_argument; - local($format,$types); - - ($type,$optarg) = &get_keyval('types', $optarg); + local($format,$list); + ($list,$optarg) = &get_keyval('types', $optarg); ($format,$optarg) = &get_keyval('format', $optarg); + $format='' unless(defined($format)); local(@types) = keys(%gls_mark); - if (defined($types)) + if ($list) { - @types = split /,/, $types; + @types = split /\s*,\s*/, $list; } foreach $type (@types) { - # strip leasing and trailing spaces + # strip leading and trailing spaces $type=~s/^\s*([^\s]+)\s*$/\1/; foreach $label (@{$gls_entries{$type}}) { - &gls_add_entry($type,$label,$format,""); + local($dobacklink) = 1; + + if (&gls_used($label)) + { + if ($INDEXONLYFIRST) + { + $dobacklink = 0; + } + } + else + { + &unset_entry($label); + } + + if ($dobacklink) + { + &gls_add_entry($type,$label,$format,""); + } } } @@ -22588,6 +23951,64 @@ sub do_cmd_glslinkstar{ $text . $_; } +sub do_cmd_glsdisp{ + local($_) = @_; + local($optarg,$pat,$label,$text,$type,$format,$str); + + ($optarg,$pat) = &get_next_optional_argument; + + ($format,$optarg) = &get_keyval('format', $optarg); + + $label = &missing_braces unless + (s/$next_pair_pr_rx/$label=$2;''/eo); + + $text = &missing_braces unless + (s/$next_pair_pr_rx/$text=$2;''/eo); + + local($dobacklink) = 1; + + if (&gls_used($label)) + { + if ($INDEXONLYFIRST) + { + $dobacklink = 0; + } + } + else + { + &unset_entry($label); + } + + $type = &gls_get_type($label); + + if ($dobacklink) + { + &make_glslink($type, $label, $format, $text) .$space . $_; + } + else + { + &make_real_glossary_entry_no_backlink($label, $text, $type). $space . $_; + } +} + +sub do_cmd_glshyperlink{ + local($_) = @_; + + local($text,$pat) = &get_next_optional_argument; + + local($id, $label); + + $label = &missing_braces unless + s/$next_pair_pr_rx/$id=$1,$label=$2;''/eo; + + $text = &gls_get_text($label) unless $text; + + local($type) = &gls_get_type($label); + + "<A HREF=\"$gls_file_mark{$type}#gls:$label\">$text<\/A>" + .$_; +} + sub do_cmd_glsentrydesc{ local($_) = @_; @@ -22603,7 +24024,7 @@ sub do_cmd_Glsentrydesc{ $label = &missing_braces unless (s/$next_pair_pr_rx/$label=$2;''/eo); - ucfirst(&gls_get_description($label)).$_; + &do_real_makefirstuc(&gls_get_description($label)).$_; } sub do_cmd_glsentrytext{ @@ -22621,7 +24042,7 @@ sub do_cmd_Glsentrytext{ $label = &missing_braces unless (s/$next_pair_pr_rx/$label=$2;''/eo); - ucfirst(&gls_get_text($label)).$_; + &do_real_makefirstuc(&gls_get_text($label)).$_; } sub do_cmd_glsentryname{ @@ -22639,7 +24060,7 @@ sub do_cmd_Glsentryname{ $label = &missing_braces unless (s/$next_pair_pr_rx/$label=$2;''/eo); - ucfirst(&gls_get_name($label)).$_; + &do_real_makefirstuc(&gls_get_name($label)).$_; } sub do_cmd_glsentryfirst{ @@ -22657,7 +24078,7 @@ sub do_cmd_Glsentryfirst{ $label = &missing_braces unless (s/$next_pair_pr_rx/$label=$2;''/eo); - ucfirst(&gls_get_first($label)).$_; + &do_real_makefirstuc(&gls_get_first($label)).$_; } sub do_cmd_glsentryplural{ @@ -22675,7 +24096,7 @@ sub do_cmd_Glsentryplural{ $label = &missing_braces unless (s/$next_pair_pr_rx/$label=$2;''/eo); - ucfirst(&gls_get_plural($label)).$_; + &do_real_makefirstuc(&gls_get_plural($label)).$_; } sub do_cmd_glsentryfirstplural{ @@ -22702,7 +24123,7 @@ sub do_cmd_Glsentryfirstplural{ $label = &missing_braces unless (s/$next_pair_pr_rx/$label=$2;''/eo); - ucfirst(&gls_get_firstplural($label)).$_; + &do_real_makefirstuc(&gls_get_firstplural($label)).$_; } sub do_cmd_glsentrysymbol{ @@ -22720,7 +24141,61 @@ sub do_cmd_Glsentrysymbol{ $label = &missing_braces unless (s/$next_pair_pr_rx/$label=$2;''/eo); - ucfirst(&gls_get_symbol($label)).$_; + &do_real_makefirstuc(&gls_get_symbol($label)).$_; +} + +sub do_cmd_glsentryuseri{ + local($_) = @_; + + $label = &missing_braces unless + (s/$next_pair_pr_rx/$label=$2;''/eo); + + &gls_get_user($label, 1).$_; +} + +sub do_cmd_glsentryuserii{ + local($_) = @_; + + $label = &missing_braces unless + (s/$next_pair_pr_rx/$label=$2;''/eo); + + &gls_get_user($label, 2).$_; +} + +sub do_cmd_glsentryuseriii{ + local($_) = @_; + + $label = &missing_braces unless + (s/$next_pair_pr_rx/$label=$2;''/eo); + + &gls_get_user($label, 3).$_; +} + +sub do_cmd_glsentryuseriv{ + local($_) = @_; + + $label = &missing_braces unless + (s/$next_pair_pr_rx/$label=$2;''/eo); + + &gls_get_user($label, 4).$_; +} + +sub do_cmd_glsentryuserv{ + local($_) = @_; + + $label = &missing_braces unless + (s/$next_pair_pr_rx/$label=$2;''/eo); + + &gls_get_user($label, 5).$_; +} + +sub do_cmd_glsentryuservi{ + local($_) = @_; + + $label = &missing_braces unless + (s/$next_pair_pr_rx/$label=$2;''/eo); + + &gls_get_user($label, 6).$_; } sub do_cmd_gls{ @@ -22744,12 +24219,19 @@ sub do_cmd_gls{ local($type) = &gls_get_type($label); + local($dobacklink) = 1; + if (&gls_used($label)) { # entry has already been used $text = &gls_get_text($label); $display = &gls_get_display($type); + + if ($INDEXONLYFIRST) + { + $dobacklink = 0; + } } else { @@ -22777,7 +24259,14 @@ sub do_cmd_gls{ local($link_text) = &translate_commands("$display$args"); - &make_glslink($type, $label, $format, $link_text) .$space . $_; + if ($dobacklink) + { + &make_glslink($type, $label, $format, $link_text) .$space . $_; + } + else + { + &make_real_glossary_entry_no_backlink($label, $link_text, $type). $space . $_; + } } # added v1.04 @@ -22859,12 +24348,19 @@ sub do_cmd_glspl{ local($type) = $glsentry{$label}{'type'}; + local($dobacklink) = 1; + if (&gls_used($label)) { # entry has already been used $text = &gls_get_plural($label); $display = &gls_get_display($type);; + + if ($INDEXONLYFIRST) + { + $dobacklink = 0; + } } else { @@ -22892,7 +24388,14 @@ sub do_cmd_glspl{ local($link_text) = &translate_commands("$display$args"); - &make_glslink($type, $label, $format, $link_text) . $space . $_; + if ($dobacklink) + { + &make_glslink($type, $label, $format, $link_text) .$space . $_; + } + else + { + &make_real_glossary_entry_no_backlink($label, $link_text, $type). $space . $_; + } } # added v1.04 @@ -22974,12 +24477,19 @@ sub do_cmd_Gls{ local($type) = $glsentry{$label}{'type'}; + local($dobacklink) = 1; + if (&gls_used($label)) { # entry has already been used $text = &gls_get_text($label); $display = &gls_get_display($type);; + + if ($INDEXONLYFIRST) + { + $dobacklink = 0; + } } else { @@ -23005,9 +24515,16 @@ sub do_cmd_Gls{ $id = ++$global{'max_id'}; $args .= "$OP$id$CP$insert$OP$id$CP"; - local($link_text) = &translate_commands("$display$args"); + local($link_text) = &do_real_makefirstuc(&translate_commands("$display$args")); - &make_glslink($type, $label, $format, ucfirst($link_text)). $space . $_; + if ($dobacklink) + { + &make_glslink($type, $label, $format, $link_text) .$space . $_; + } + else + { + &make_real_glossary_entry_no_backlink($label, $link_text, $type). $space . $_; + } } # added v1.04 @@ -23065,7 +24582,7 @@ sub do_cmd_Glsstar{ local($link_text) = &translate_commands("$display$args"); - ucfirst($link_text). $space . $_; + &do_real_makefirstuc($link_text). $space . $_; } sub do_cmd_Glspl{ @@ -23089,12 +24606,19 @@ sub do_cmd_Glspl{ local($type) = $glsentry{$label}{'type'}; + local($dobacklink) = 1; + if (&gls_used($label)) { # entry has already been used $text = &gls_get_plural($label); $display = &gls_get_display($type);; + + if ($INDEXONLYFIRST) + { + $dobacklink = 0; + } } else { @@ -23120,9 +24644,16 @@ sub do_cmd_Glspl{ $id = ++$global{'max_id'}; $args .= "$OP$id$CP$insert$OP$id$CP"; - local($link_text) = &translate_commands("$display$args"); + local($link_text) = &do_real_makefirstuc(&translate_commands("$display$args")); - &make_glslink($type, $label, $format, ucfirst($link_text)).$space . $_; + if ($dobacklink) + { + &make_glslink($type, $label, $format, $link_text) .$space . $_; + } + else + { + &make_real_glossary_entry_no_backlink($label, $link_text, $type). $space . $_; + } } # added v1.04 @@ -23180,7 +24711,7 @@ sub do_cmd_Glsplstar{ local($link_text) = &translate_commands("$display$args"); - ucfirst($link_text).$space . $_; + &do_real_makefirstuc($link_text).$space . $_; } sub do_cmd_GLS{ @@ -23204,12 +24735,19 @@ sub do_cmd_GLS{ local($type) = $glsentry{$label}{'type'}; + local($dobacklink) = 1; + if (&gls_used($label)) { # entry has already been used $text = &gls_get_text($label); $display = &gls_get_display($type);; + + if ($INDEXONLYFIRST) + { + $dobacklink = 0; + } } else { @@ -23235,9 +24773,16 @@ sub do_cmd_GLS{ $id = ++$global{'max_id'}; $args .= "$OP$id$CP$insert$OP$id$CP"; - local($link_text) = &translate_commands("$display$args"); + local($link_text) = uc(&translate_commands("$display$args")); - &make_glslink($type, $label, $format, uc($link_text)).$space . $_; + if ($dobacklink) + { + &make_glslink($type, $label, $format, $link_text) .$space . $_; + } + else + { + &make_real_glossary_entry_no_backlink($label, $link_text, $type). $space . $_; + } } # added v1.04 @@ -23319,12 +24864,19 @@ sub do_cmd_GLSpl{ local($type) = $glsentry{$label}{'type'}; + local($dobacklink) = 1; + if (&gls_used($label)) { # entry has already been used $text = &gls_get_plural($label); $display = &gls_get_display($type);; + + if ($INDEXONLYFIRST) + { + $dobacklink = 0; + } } else { @@ -23350,9 +24902,16 @@ sub do_cmd_GLSpl{ $id = ++$global{'max_id'}; $args .= "$OP$id$CP$insert$OP$id$CP"; - local($link_text) = &translate_commands("$display$args"); + local($link_text) = uc(&translate_commands("$display$args")); - &make_glslink($type, $label, $format, uc($link_text)).$space . $_; + if ($dobacklink) + { + &make_glslink($type, $label, $format, $link_text) .$space . $_; + } + else + { + &make_real_glossary_entry_no_backlink($label, $link_text, $type). $space . $_; + } } # added v1.04 @@ -23464,7 +25023,7 @@ sub do_cmd_Glstext{ $text = &gls_get_text($label); - &make_glslink($type, $label, $format, ucfirst($text)) .$space . $_; + &make_glslink($type, $label, $format, &do_real_makefirstuc($text)) .$space . $_; } # added 22 Feb 2008 @@ -23545,7 +25104,7 @@ sub do_cmd_Glsname{ $text = &gls_get_name($label); - &make_glslink($type, $label, $format, ucfirst($text)) .$space . $_; + &make_glslink($type, $label, $format, &do_real_makefirstuc($text)) .$space . $_; } # added 22 Feb 2008 @@ -23626,7 +25185,7 @@ sub do_cmd_Glsfirst{ $text = &gls_get_first($label); - &make_glslink($type, $label, $format, ucfirst($text)) .$space . $_; + &make_glslink($type, $label, $format, &do_real_makefirstuc($text)) .$space . $_; } # added 22 Feb 2008 @@ -23707,7 +25266,7 @@ sub do_cmd_Glsfirstplural{ $text = &gls_get_firstplural($label); - &make_glslink($type, $label, $format, ucfirst($text)) .$space . $_; + &make_glslink($type, $label, $format, &do_real_makefirstuc($text)) .$space . $_; } # added 22 Feb 2008 @@ -23788,7 +25347,7 @@ sub do_cmd_Glsplural{ $text = &gls_get_plural($label); - &make_glslink($type, $label, $format, ucfirst($text)) .$space . $_; + &make_glslink($type, $label, $format, &do_real_makefirstuc($text)) .$space . $_; } # added 22 Feb 2008 @@ -23869,7 +25428,7 @@ sub do_cmd_Glsdesc{ $text = &gls_get_description($label); - &make_glslink($type, $label, $format, ucfirst($text)) .$space . $_; + &make_glslink($type, $label, $format, &do_real_makefirstuc($text)) .$space . $_; } # added 22 Feb 2008 @@ -23950,7 +25509,7 @@ sub do_cmd_Glssymbol{ $text = &gls_get_symbol($label); - &make_glslink($type, $label, $format, ucfirst($text)) .$space . $_; + &make_glslink($type, $label, $format, &do_real_makefirstuc($text)) .$space . $_; } # added 22 Feb 2008 @@ -23980,6 +25539,318 @@ sub do_cmd_GLSsymbol{ &make_glslink($type, $label, $format, uc($text)) .$space . $_; } +sub do_cmd_glsuseri{ + local($_) = @_; + local($optarg,$pat,$label,$text, $format, $insert); + + ($optarg,$pat) = &get_next_optional_argument; + + ($format,$optarg) = &get_keyval('format', $optarg); + + $label = &missing_braces unless + (s/$next_pair_pr_rx/$label=$2;''/eo); + + local ($space) = ''; + if (/^\s+[^\[]/ or /^\s*\[.*\]\s/) {$space = ' ';} + + $insert = ''; + ($insert,$pat) = &get_next_optional_argument; + + local($display) = ''; + + local($type) = &gls_get_type($label); + + $text = &gls_get_user($label, 1); + + &make_glslink($type, $label, $format, $text) .$space . $_; +} + +sub do_cmd_Glsuseri{ + local($_) = @_; + local($optarg,$pat,$label,$text, $format, $insert); + + ($optarg,$pat) = &get_next_optional_argument; + + ($format,$optarg) = &get_keyval('format', $optarg); + + $label = &missing_braces unless + (s/$next_pair_pr_rx/$label=$2;''/eo); + + local ($space) = ''; + if (/^\s+[^\[]/ or /^\s*\[.*\]\s/) {$space = ' ';} + + $insert = ''; + ($insert,$pat) = &get_next_optional_argument; + + local($display) = ''; + + local($type) = &gls_get_type($label); + + $text = &do_real_makefirstuc(&gls_get_user($label, 1)); + + &make_glslink($type, $label, $format, $text) .$space . $_; +} + +sub do_cmd_glsuserii{ + local($_) = @_; + local($optarg,$pat,$label,$text, $format, $insert); + + ($optarg,$pat) = &get_next_optional_argument; + + ($format,$optarg) = &get_keyval('format', $optarg); + + $label = &missing_braces unless + (s/$next_pair_pr_rx/$label=$2;''/eo); + + local ($space) = ''; + if (/^\s+[^\[]/ or /^\s*\[.*\]\s/) {$space = ' ';} + + $insert = ''; + ($insert,$pat) = &get_next_optional_argument; + + local($display) = ''; + + local($type) = &gls_get_type($label); + + $text = &gls_get_user($label, 2); + + &make_glslink($type, $label, $format, $text) .$space . $_; +} + +sub do_cmd_Glsuserii{ + local($_) = @_; + local($optarg,$pat,$label,$text, $format, $insert); + + ($optarg,$pat) = &get_next_optional_argument; + + ($format,$optarg) = &get_keyval('format', $optarg); + + $label = &missing_braces unless + (s/$next_pair_pr_rx/$label=$2;''/eo); + + local ($space) = ''; + if (/^\s+[^\[]/ or /^\s*\[.*\]\s/) {$space = ' ';} + + $insert = ''; + ($insert,$pat) = &get_next_optional_argument; + + local($display) = ''; + + local($type) = &gls_get_type($label); + + $text = &do_real_makefirstuc(&gls_get_user($label, 2)); + + &make_glslink($type, $label, $format, $text) .$space . $_; +} + +sub do_cmd_glsuseriii{ + local($_) = @_; + local($optarg,$pat,$label,$text, $format, $insert); + + ($optarg,$pat) = &get_next_optional_argument; + + ($format,$optarg) = &get_keyval('format', $optarg); + + $label = &missing_braces unless + (s/$next_pair_pr_rx/$label=$2;''/eo); + + local ($space) = ''; + if (/^\s+[^\[]/ or /^\s*\[.*\]\s/) {$space = ' ';} + + $insert = ''; + ($insert,$pat) = &get_next_optional_argument; + + local($display) = ''; + + local($type) = &gls_get_type($label); + + $text = &gls_get_user($label, 3); + + &make_glslink($type, $label, $format, $text) .$space . $_; +} + +sub do_cmd_Glsuseriii{ + local($_) = @_; + local($optarg,$pat,$label,$text, $format, $insert); + + ($optarg,$pat) = &get_next_optional_argument; + + ($format,$optarg) = &get_keyval('format', $optarg); + + $label = &missing_braces unless + (s/$next_pair_pr_rx/$label=$2;''/eo); + + local ($space) = ''; + if (/^\s+[^\[]/ or /^\s*\[.*\]\s/) {$space = ' ';} + + $insert = ''; + ($insert,$pat) = &get_next_optional_argument; + + local($display) = ''; + + local($type) = &gls_get_type($label); + + $text = &do_real_makefirstuc(&gls_get_user($label, 3)); + + &make_glslink($type, $label, $format, $text) .$space . $_; +} + +sub do_cmd_glsuseriv{ + local($_) = @_; + local($optarg,$pat,$label,$text, $format, $insert); + + ($optarg,$pat) = &get_next_optional_argument; + + ($format,$optarg) = &get_keyval('format', $optarg); + + $label = &missing_braces unless + (s/$next_pair_pr_rx/$label=$2;''/eo); + + local ($space) = ''; + if (/^\s+[^\[]/ or /^\s*\[.*\]\s/) {$space = ' ';} + + $insert = ''; + ($insert,$pat) = &get_next_optional_argument; + + local($display) = ''; + + local($type) = &gls_get_type($label); + + $text = &gls_get_user($label, 4); + + &make_glslink($type, $label, $format, $text) .$space . $_; +} + +sub do_cmd_Glsuseriv{ + local($_) = @_; + local($optarg,$pat,$label,$text, $format, $insert); + + ($optarg,$pat) = &get_next_optional_argument; + + ($format,$optarg) = &get_keyval('format', $optarg); + + $label = &missing_braces unless + (s/$next_pair_pr_rx/$label=$2;''/eo); + + local ($space) = ''; + if (/^\s+[^\[]/ or /^\s*\[.*\]\s/) {$space = ' ';} + + $insert = ''; + ($insert,$pat) = &get_next_optional_argument; + + local($display) = ''; + + local($type) = &gls_get_type($label); + + $text = &do_real_makefirstuc(&gls_get_user($label, 4)); + + &make_glslink($type, $label, $format, $text) .$space . $_; +} + +sub do_cmd_glsuserv{ + local($_) = @_; + local($optarg,$pat,$label,$text, $format, $insert); + + ($optarg,$pat) = &get_next_optional_argument; + + ($format,$optarg) = &get_keyval('format', $optarg); + + $label = &missing_braces unless + (s/$next_pair_pr_rx/$label=$2;''/eo); + + local ($space) = ''; + if (/^\s+[^\[]/ or /^\s*\[.*\]\s/) {$space = ' ';} + + $insert = ''; + ($insert,$pat) = &get_next_optional_argument; + + local($display) = ''; + + local($type) = &gls_get_type($label); + + $text = &gls_get_user($label, 5); + + &make_glslink($type, $label, $format, $text) .$space . $_; +} + +sub do_cmd_Glsuserv{ + local($_) = @_; + local($optarg,$pat,$label,$text, $format, $insert); + + ($optarg,$pat) = &get_next_optional_argument; + + ($format,$optarg) = &get_keyval('format', $optarg); + + $label = &missing_braces unless + (s/$next_pair_pr_rx/$label=$2;''/eo); + + local ($space) = ''; + if (/^\s+[^\[]/ or /^\s*\[.*\]\s/) {$space = ' ';} + + $insert = ''; + ($insert,$pat) = &get_next_optional_argument; + + local($display) = ''; + + local($type) = &gls_get_type($label); + + $text = &do_real_makefirstuc(&gls_get_user($label, 5)); + + &make_glslink($type, $label, $format, $text) .$space . $_; +} + +sub do_cmd_glsuservi{ + local($_) = @_; + local($optarg,$pat,$label,$text, $format, $insert); + + ($optarg,$pat) = &get_next_optional_argument; + + ($format,$optarg) = &get_keyval('format', $optarg); + + $label = &missing_braces unless + (s/$next_pair_pr_rx/$label=$2;''/eo); + + local ($space) = ''; + if (/^\s+[^\[]/ or /^\s*\[.*\]\s/) {$space = ' ';} + + $insert = ''; + ($insert,$pat) = &get_next_optional_argument; + + local($display) = ''; + + local($type) = &gls_get_type($label); + + $text = &gls_get_user($label, 6); + + &make_glslink($type, $label, $format, $text) .$space . $_; +} + +sub do_cmd_Glsuservi{ + local($_) = @_; + local($optarg,$pat,$label,$text, $format, $insert); + + ($optarg,$pat) = &get_next_optional_argument; + + ($format,$optarg) = &get_keyval('format', $optarg); + + $label = &missing_braces unless + (s/$next_pair_pr_rx/$label=$2;''/eo); + + local ($space) = ''; + if (/^\s+[^\[]/ or /^\s*\[.*\]\s/) {$space = ' ';} + + $insert = ''; + ($insert,$pat) = &get_next_optional_argument; + + local($display) = ''; + + local($type) = &gls_get_type($label); + + $text = &do_real_makefirstuc(&gls_get_user($label, 6)); + + &make_glslink($type, $label, $format, $text) .$space . $_; +} + sub do_cmd_acrshort{ &do_cmd_glstext(@_) } @@ -24055,7 +25926,7 @@ sub do_cmd_hyperbf{ &ignore_commands( <<_IGNORED_CMDS_ ); makeglossary makeglossaries -glossarystyle {} +glossaryentrynumbers # {} _IGNORED_CMDS_ 1; @@ -24066,5 +25937,148 @@ _IGNORED_CMDS_ %</glossaries.perl> % \end{macrocode} %\fi +%\iffalse +% \begin{macrocode} +%<*mfirstuc.perl> +% \end{macrocode} +%\fi +%\iffalse +% \begin{macrocode} +# File : mfirstuc.perl +# Author : Nicola L. C. Talbot +# Date : 2012-09-21 +# Version : 1.0 +# Description : LaTeX2HTML (limited!) implementation of mfirstuc package + +# This is a LaTeX2HTML style implementing the mfirstuc package, and +# is distributed as part of the glossaries package. +# Copyright 2007 Nicola L.C. Talbot +# This work may be distributed and/or modified under the +# conditions of the LaTeX Project Public License, either version 1.3 +# of this license of (at your option) any later version. +# The latest version of this license is in +# http://www.latex-project.org/lppl.txt +# and version 1.3 or later is part of all distributions of LaTeX +# version 2005/12/01 or later. +# +# This work has the LPPL maintenance status `maintained'. +# +# The Current Maintainer of this work is Nicola Talbot. + +use warnings; + +package main; + +sub do_cmd_makefirstuc{ + local($_) = @_; + + local($id,$text); + + $text = &missing_braces unless + s/$next_pair_pr_rx/$id=$1;$text=$2;''/eo; + + &translate_commands("\\glsmakefirstuc $text") . $_; +} + +sub do_cmd_xmakefirstuc{ + local($_) = @_; + + local($id,$text); + + $text = &missing_braces unless + s/$next_pair_pr_rx/$id=$1;$text=$2;''/eo; + + unless ($id) + { + $id = ++$global{'max_id'}; + } + + &translate_commands("\\expandafter \\makefirstuc $OP$id$CP$text$OP$id$CP") + . $_; +} + +sub do_cmd_glsmakefirstuc{ + local($_) = @_; + + local($id,$text); + + $text = &get_next_object unless + s/$next_pair_pr_rx/$id=$1;$text=$2;''/eo; + + &do_real_makefirstuc($text).$_; +} + +sub do_real_makefirstuc{ + local($text) = @_; + + if ($text=~/^((?:\s*<[^>]+>\s*)+)(.*)/) + { + $text = $1 . ucfirst($2); + } + else + { + $text = ucfirst($text); + } + + $text; +} + +sub do_cmd_capitalisewords{ + local($_) = @_; + + local($id,$text); + + $text = &missing_braces unless + s/$next_pair_pr_rx/$id=$1;$text=$2;''/eo; + + local($newtext) = ''; + + foreach my $word (split ' ', $text) + { + $id = ++$global{'max_id'}; + + $word = &translate_commands("\\makefirstuc $OP$id$CP$word$OP$id$CP"); + + if ($newtext) + { + $newtext .= ' ' . $word; + } + else + { + $newtext = $word; + } + } + + $newtext.$_; +} + +sub get_next_object{ + local($next, $revert, $thisline); + local($this_cmd) = $cmd; + $this_cmd =~ s/^\\// unless ($cmd eq "\\"); + if (/^[\s%]*([^\n]*)\n/ ) { + $thisline = &revert_to_raw_tex($1) + } else { + $thisline = &revert_to_raw_tex($_); + } + s/^\s*//; + if ($_ =~ s/$next_token_rx//) { $next = $& }; + $next =~ s/$comment_mark(\d+\n?)?//g; + if ($next =~ /^\\(\W|\d|[a-zA-z]*\b)/) { + $revert = $next = "\\".$1; + } elsif ($next =~ /\W/) { + $revert = &revert_to_raw_tex($next); + } else { $revert = $next }; + $next; +} + +1; +% \end{macrocode} +%\fi +%\iffalse +% \begin{macrocode} +%</mfirstuc.perl> +% \end{macrocode} +%\fi %\Finale \endinput diff --git a/Master/texmf-dist/source/latex/glossaries/glossaries.ins b/Master/texmf-dist/source/latex/glossaries/glossaries.ins index 91f62e20856..a9c1d0ce4e6 100644 --- a/Master/texmf-dist/source/latex/glossaries/glossaries.ins +++ b/Master/texmf-dist/source/latex/glossaries/glossaries.ins @@ -1,4 +1,4 @@ -% glossaries.ins generated using makedtx version 0.94b 2012/5/21 14:06 +% glossaries.ins generated using makedtx version 0.94b 2012/9/21 14:41 \input docstrip \preamble @@ -18,7 +18,7 @@ The Current Maintainer of this work is Nicola Talbot. - This work consists of the files glossaries.dtx and glossaries.ins and the derived files glossaries.sty, mfirstuc.sty, glossary-hypernav.sty, glossary-inline.sty, glossary-list.sty, glossary-long.sty, glossary-longragged.sty, glossary-mcols.sty, glossary-super.sty, glossary-superragged.sty, glossary-tree.sty, glossaries-compatible-207.sty, glossaries-accsupp.sty, glossaries-babel.sty, glossaries-polyglossia.sty, glossaries-dictionary-Brazilian.dict, glossaries-dictionary-Danish.dict, glossaries-dictionary-Dutch.dict, glossaries-dictionary-English.dict, glossaries-dictionary-French.dict, glossaries-dictionary-German.dict, glossaries-dictionary-Irish.dict, glossaries-dictionary-Italian.dict, glossaries-dictionary-Magyar.dict, glossaries-dictionary-Polish.dict, glossaries-dictionary-Serbian.dict, glossaries-dictionary-Spanish.dict, minimalgls.tex, sample-crossref.tex, sample-custom-acronym.tex, sample-dual.tex, sample-inline.tex, sample-langdict.tex, sample-mfirstuc.tex, sample-numberlist.tex, sample.tex, sample4col.tex, sampleaccsupp.tex, sampleAcr.tex, sampleAcrDesc.tex, sampleacronyms.tex, sampleDB.tex, sampleDesc.tex, sampleEq.tex, sampleEqPg.tex, sampleNtn.tex, sampleSec.tex, sampletree.tex, sampleutf8.tex, samplexdy-compatible207.tex, samplexdy.tex, samplexdy2.tex, samplexdy-mc.xdy, samplexdy-mc207.xdy, database1.tex, database2.tex, glossaries.perl. + This work consists of the files glossaries.dtx and glossaries.ins and the derived files glossaries.sty, mfirstuc.sty, glossary-hypernav.sty, glossary-inline.sty, glossary-list.sty, glossary-long.sty, glossary-longragged.sty, glossary-mcols.sty, glossary-super.sty, glossary-superragged.sty, glossary-tree.sty, glossaries-compatible-207.sty, glossaries-accsupp.sty, glossaries-babel.sty, glossaries-polyglossia.sty, glossaries-dictionary-Brazilian.dict, glossaries-dictionary-Danish.dict, glossaries-dictionary-Dutch.dict, glossaries-dictionary-English.dict, glossaries-dictionary-French.dict, glossaries-dictionary-German.dict, glossaries-dictionary-Irish.dict, glossaries-dictionary-Italian.dict, glossaries-dictionary-Magyar.dict, glossaries-dictionary-Polish.dict, glossaries-dictionary-Serbian.dict, glossaries-dictionary-Spanish.dict, minimalgls.tex, sample-crossref.tex, sample-custom-acronym.tex, sample-dual.tex, sample-inline.tex, sample-langdict.tex, sample-mfirstuc.tex, sample-numberlist.tex, sample.tex, sample4col.tex, sampleaccsupp.tex, sampleAcr.tex, sampleAcrDesc.tex, sampleacronyms.tex, sampleDB.tex, sampleDesc.tex, sampleEq.tex, sampleEqPg.tex, sampleNtn.tex, sampleSec.tex, sampletree.tex, sampleutf8.tex, samplexdy-compatible207.tex, samplexdy.tex, samplexdy2.tex, samplexdy-mc.xdy, samplexdy-mc207.xdy, database1.tex, database2.tex, glossaries.perl, mfirstuc.perl. \endpreamble @@ -108,6 +108,7 @@ \file{database1.tex}{\nopreamble\nopostamble\from{glossaries.dtx}{database1.tex}} \file{database2.tex}{\nopreamble\nopostamble\from{glossaries.dtx}{database2.tex}} \file{glossaries.perl}{\nopreamble\nopostamble\from{glossaries.dtx}{glossaries.perl}} +\file{mfirstuc.perl}{\nopreamble\nopostamble\from{glossaries.dtx}{mfirstuc.perl}} } \endbatchfile diff --git a/Master/texmf-dist/source/latex/glossaries/glossaries.perl b/Master/texmf-dist/source/latex/glossaries/glossaries.perl index 9aa8f17e5bb..d615d83ab08 100644 --- a/Master/texmf-dist/source/latex/glossaries/glossaries.perl +++ b/Master/texmf-dist/source/latex/glossaries/glossaries.perl @@ -1,8 +1,8 @@ # File : glossaries.perl # Author : Nicola L.C. Talbot # Date : 14th June 2007 -# Last Modified : 25th July 2008 -# Version : 1.04 +# Last Modified : 2012-09-21 +# Version : 1.05 # Description : LaTeX2HTML (limited!) implementation of glossaries # package. Note that not all the glossaries.sty # macros have been implemented. @@ -25,10 +25,21 @@ # This work consists of the files glossaries.dtx and glossaries.ins # and the derived files glossaries.sty, glossary-hypernav.sty, # glossary-list.sty, glossary-long.sty, glossary-super.sty, -# glossaries.perl. Also makeglossaries and makeglossaries.bat +# glossaries.perl, mfrstuc.perl. Also makeglossaries and makeglossaries.bat package main; +&do_require_package("mfirstuc"); + + %glossary_style = (); + &set_glossarystyle('altlist');# default style + + $CURRENT_STYLE='altlist'; + +&process_commands_nowrap_in_tex( <<_RAW_ARG_CMDS_); +newglossarystyle # {} # {} +_RAW_ARG_CMDS_ + # These are the only package options implemented. sub do_glossaries_style_altlist{ @@ -40,8 +51,20 @@ sub do_glossaries_toc{ sub do_glossaries_toc_true{ } +$INDEXONLYFIRST=0; + +sub do_glossaries_indexonlyfirst{ + $INDEXONLYFIRST=1; +} + +$gls_nonumberlist{'main'} = 0; + +sub do_glossaries_nonumberlist{ + $gls_nonumberlist{'main'} = 1; +} + $GLSCURRENTFORMAT="textrm" if (!defined($GLSCURRENTFORMAT)); -$GLOSSARY_END_DESCRIPTION = '. ' if (!defined($GLOSSARY_END_DESCRIPTION)); +$GLOSSARY_END_DESCRIPTION = '.' if (!defined($GLOSSARY_END_DESCRIPTION)); sub do_cmd_glossaryname{ "Glossary$_[0]" @@ -50,6 +73,7 @@ sub do_cmd_glossaryname{ $gls_mark{'main'} = "<tex2html_gls_main_mark>"; $gls_file_mark{'main'} = "<tex2html_gls_main_file_mark>"; $gls_title{'main'} = "\\glossaryname"; +$gls_toctitle{'main'} = "\\glossaryname"; $delimN{'main'} = ", "; $glsnumformat{'main'} = $GLSCURRENTFORMAT; @{$gls_entries{'main'}} = (); @@ -69,7 +93,7 @@ sub do_glossaries_acronym_true{ $acronymtype = 'acronym'; } -sub do_glossary_acronym_false{ +sub do_glossaries_acronym_false{ $acronymtype = 'main'; } @@ -81,6 +105,63 @@ sub do_cmd_acronymtype{ join('', $acronymtype, $_[0]); } +$global{'glossaryentry'} = 0; +$global{'glossarysubentry'} = 0; + +sub do_cmd_theglossaryentry{ + join('', $global{'glossaryentry'}, $_[0]); +} + +sub do_cmd_theglossarysubentry{ + join('', $global{'glossarysubentry'}, $_[0]); +} + +sub do_glossaries_entrycounter{ + &do_glossaries_entrycounter_true +} + +sub do_glossaries_entrycounter_true{ + eval(<<'_END_DEF'); + sub do_cmd_glsresetentrycounter{ + $global{'entrycounter'} = 0; + $_[0]; + } +_END_DEF +} + +sub do_glossaries_entrycounter_false{ + eval(<<'_END_DEF'); + sub do_cmd_glsresetentrycounter{ + $_[0]; + } +_END_DEF +} + +sub do_cmd_glsresetentrycounter{$_[0];} + +sub do_glossaries_subentrycounter{ + &do_glossaries_subentrycounter_true +} + +sub do_glossaries_subentrycounter_true{ + eval(<<'_END_DEF'); + sub do_cmd_glsresetsubentrycounter{ + $global{'subentrycounter'} = 0; + $_[0]; + } +_END_DEF +} + +sub do_glossaries_subentrycounter_false{ + eval(<<'_END_DEF'); + sub do_cmd_glsresetsubentrycounter{ + $_[0]; + } +_END_DEF +} + +sub do_cmd_glsresetsubentrycounter{ $_[0]; } + # modify set_depth_levels so that glossary is added sub replace_glossary_markers{ @@ -96,7 +177,7 @@ sub replace_glossary_markers{ } # there must be a better way of doing this -# other than copying the orginal code and adding to it. +# other than copying the original code and adding to it. sub replace_general_markers { if (defined &replace_infopage_hook) {&replace_infopage_hook if (/$info_page_mark/);} else { &replace_infopage if (/$info_page_mark/); } @@ -145,28 +226,256 @@ local(@styles) = split(/\s*,\s*/,$INDEX_STYLES); &add_real_gls } +sub gls_compare{ + local($x, $y) = @_; + + if ($x eq '' or $y eq '') + { + if ($x ne '') + { + # y is the shorter string + return 1; + } + elsif ($y ne '') + { + # x is the shorter string + return -1; + } + else + { + # both empty + return 0; + } + } + + local($x0) = ''; + local($y0) = ''; + + if ($x=~s/^(&#(?:\d+|x[\da-f]+);)//) + { + $x0 = $1; + } + elsif ($x=~s/^(.)//) + { + $x0 = $1; + } + + if ($y=~s/^(&#(?:\d+|x[\da-f]+);)//) + { + $y0 = $1; + } + elsif ($y=~s/^(.)//) + { + $y0 = $1; + } + + local($numx); + + if ($x0=~/&#(\d+|x[\da-f]+);/) + { + $numx = $1; + + $numx = hex("0$numx") if $numx=~/^x/; + } + else + { + $numx = ord($x0); + } + + local($numy); + + if ($y0=~/&#(\d+|x[\da-f]+);/) + { + $numy = $1; + + $numy = hex("0$numy") if $numy=~/^x/; + } + else + { + $numy = ord($y0); + } + + if ($numx == $numy) + { + return &gls_compare($x, $y); + } + elsif ($numx >= 48 and $numx <= 57) # x in range '0' ... '9' + { + if ($numy >= 48 and $numy <= 57) # y in range '0' ... '9' + { + return $numx <=> $numy; + } + elsif (($numy >= 97 and $numy <= 122) or ($numy >= 65 and $numy <= 90)) # y a letter + { + # digits are less than letters + return -1; + } + else + { + # digits are greater than symbols + return 1; + } + } + elsif (($numx >= 97 and $numx <= 122) or ($numx >= 65 and $numx <= 90)) # x a letter + { + if (($numy >= 97 and $numy <= 122) or ($numy >= 65 and $numy <= 90)) # y a letter + { + if (($numx <= 90 and $numy <= 90) or ($numx >= 97 and $numy >= 97)) + { + # same case (already checked if they are equal) + + return $numx <=> $numy; + } + + # are they upper/lower case versions of each other? + + if (($numx >= 97 and $numy == $numx-32)) + { + # x is upper case version of y + + if ($x or $y) + { + return &gls_compare($x, $y); + } + else + { + return -1; + } + } + + if (($numy >= 97 and $numx == $numy-32)) + { + # y is upper case version of x + + if ($x or $y) + { + return &gls_compare($x, $y); + } + else + { + return 1; + } + } + + # compare lower case values + return lc(chr($numx)) cmp lc(chr($numy)); + } + else + { + # a-z greater than symbols and digits + return 1; + } + } + elsif ($numy >= 48 and $numy <= 57) # y in range '0' ... '9' + { + # already checked for '0' < x < '9' and '0' < y < '9' + # already checked for 'a' < x < 'z' and '0' < y < '9' + + # digits greater than symbols + return 1; + } + elsif (($numy >= 97 and $numy <= 122) or ($numy >= 65 and $numy <= 90)) # y is a letter + { + # already checked for x is digit and y a is letter + # already checked for x is letter and y a is letter + + # symbols and digits are less than letters + + return -1; + } + + $numx <=> $numy +} + sub gloskeysort{ - local($x, $y) = ($a, $b); - $x=~s/^(.*)###(\d+)$/\l\1/; - local($x_id) = $2; - $y=~s/^(.*)###(\d+)$/\l\1/; + + $a=~/^(.*)###(\d+)$/; + + local($labelx) = $1; + local($x_id) =$2; + + $b=~/^(.*)###(\d+)$/; + + local($labely) = $1; local($y_id) = $2; - local($n) = ($x cmp $y); + local($sortx) = &gls_get_sort($labelx); + local($sorty) = &gls_get_sort($labely); + + local($n); + + # are they case-insensitive equivalent? + + if (lc($sortx) eq lc($sorty)) + { + $n = ($sortx cmp $sorty); + } + else + { + $n = &gls_compare($sortx, $sorty); + } - if ($n == 0) + unless ($n) { $n = ($x_id <=> $y_id); } - $n; + $n +} + +sub add_parent_if_required{ + local($label) = @_; + + local($parent) = &gls_get_parent($label); + + if ($parent) + { + local($type) = &gls_get_type($parent); + + # does this parent have a backlink? + + for my $key (keys %{$glossary{$type}}) + { + return if $key=~/^$parent###\d+$/; + } + + # none found, so add empty one + + my $id = ++$global{'max_id'}; + + $glossary{$type}{"$parent###$id"} = ''; + $glossary_entry{$type}{"$parent###$id"} = $parent; + + # check if parent also has a parent + + &add_parent_if_required($parent); + } } sub add_real_gls{ local($type) = @_; print "\nDoing glossary '$type' ..."; - local($key, $str, @keys, $glossary, $level, $count, - @previous, @current, $id, $linktext, $delimN); + local($key, $str, @keys, $thisglsentry, $level, $count, + $previous, $current, $id, $linktext, $delimN); + + $TITLE = $gls_toctitle{$type}; + + local($oldstyle) = $CURRENT_STYLE; + + if ($gls_style{$type}) + { + &set_glossarystyle($gls_style{$type}); + } + + # add any parent entries that haven't been referenced + + for my $key (keys %{$glossary{$type}}) + { + my $label = $key; + $label =~ s/###\d+$//o; # Remove the unique id's + + &add_parent_if_required($label); + } @keys = keys %{$glossary{$type}}; @@ -176,47 +485,624 @@ sub add_real_gls{ $delimN = $delimN{$type}; + $previous = ''; + + local($previousentry) = ''; + + my $glossaryentryfield = ''; + + my $previouscat = ''; + + local ($entry); + foreach $key (@keys) { $current = $key; - $str = $current; - $str =~ s/\#\#\#\d+$//o; # Remove the unique id's - #$linktext = $cross_ref_visible_mark; - $id = ++$global{'max_id'}; - $linktext = "\\$glossary_format{$type}{$key}${OP}$id${CP}$glossary_linktext{$type}{$key}${OP}$id${CP}"; - $linktext = &translate_commands($linktext); + $current =~ s/\#\#\#\d+$//o; # Remove the unique id's - local($entry) = $glossary_entry{$type}{$key}; + my $issame = ($current eq $previous ? 1 : 0); - $id = ++$global{'max_id'}; - local($name) = &translate_commands( - "\\glsnamefont $OP$id$CP$glsentry{$entry}{name}$OP$id$CP"); - - local($symbol) = ($glsentry{$entry}{'symbol'} ? - " $glsentry{$entry}{symbol}" : ''); - - $glossary .= - # If it's the same string don't start a new line - (&index_key_eq($current, $previous) ? - $delimN - . $glossary{$type}{$key} - . $linktext - . "</A>" - : "<DT>" - . "<A NAME=\"gls:$entry\">$name</A>" - . "<DD>" - . $glsentry{$entry}{'description'} - . $symbol . $GLOSSARY_END_DESCRIPTION - . $glossary{$type}{$key} - . $linktext. "</A>"); $previous = $current; + + $entry = $glossary_entry{$type}{$key}; + + unless ($issame) + { + if ($glossaryentryfield) + { + $id = ++$global{'max_id'}; + + my $level = &gls_get_level($previousentry); + + if ($level > 0) + { + my $id2 = ++$global{'max_id'}; + + $thisglsentry .= + "\\glossarysubentryfield $OP$id2$CP$level$OP$id2$CP$glossaryentryfield$OP$id$CP$linktext$OP$id$CP"; + } + else + { + $thisglsentry .= + "\\glossaryentryfield $glossaryentryfield$OP$id$CP$linktext$OP$id$CP"; + } + + $glossaryentryfield = ''; + } + + $linktext = ''; + + my $currentcat = substr(&gls_get_sort($current), 0, 1); + + if ($currentcat=~/[a-zA-Z]/) + { + $currentcat = uc($currentcat); + } + elsif ($currentcat=~/[0-9]/) + { + $currentcat = 'glsnumbers'; + } + else + { + $currentcat = 'glssymbols'; + } + + unless ($previouscat eq $currentcat) + { + $id = ++$global{'max_id'}; + $thisglsentry .= "\\glsgroupheading$OP$id$CP$currentcat$OP$id$CP"; + + $previouscat = $currentcat; + } + } + + $previousentry = $entry; + + # Back ref + + if ($gls_nonumberlist{$type}) + { + $linktext = ''; + } + elsif ($glossary{$type}{$key}) + { + $id = ++$global{'max_id'}; + + $linktext .= $delimN if ($linktext); + + $linktext .= "$glossary{$type}{$key}\\$glossary_format{$type}{$key}${OP}$id${CP}$glossary_linktext{$type}{$key}${OP}$id${CP}</A>"; + + } + + unless ($issame) + { + $id = ++$global{'max_id'}; + local($name) = &translate_commands( + "\\glsnamefont $OP$id$CP$glsentry{$entry}{name}$OP$id$CP"); + + local($symbol) = ($glsentry{$entry}{'symbol'} ? + " $glsentry{$entry}{symbol}" : ''); + + $id = ++$global{'max_id'}; + my $id2 = ++$global{'max_id'}; + my $id3 = ++$global{'max_id'}; + my $id4 = ++$global{'max_id'}; + + $glossaryentryfield = "$OP$id$CP$entry$OP$id$CP" # label + . "$OP$id2$CP$name$OP$id2$CP" # name + . "$OP$id3$CP$glsentry{$entry}{description}$OP$id3$CP" # description + . "$OP$id4$CP$symbol$OP$id4$CP" # symbol + } + + } + + if ($glossaryentryfield and $entry) + { + my $level = &gls_get_level($entry); + + if ($level > 0) + { + my $id2 = ++$global{'max_id'}; + + $thisglsentry .= + "\\glossarysubentryfield $OP$id2$CP$level$OP$id2$CP$glossaryentryfield$OP$id$CP$linktext$OP$id$CP"; + } + else + { + $id = ++$global{'max_id'}; + $thisglsentry .= + "\\glossaryentryfield $glossaryentryfield$OP$id$CP$linktext$OP$id$CP"; + } + } + + $str = &do_env_theglossary($thisglsentry) . &translate_commands("\\glossarypostamble"); + + if ($gls_style{$type}) + { + &set_glossarystyle($oldstyle); + } + + s/$gls_mark{$type}/$preglossary\n$str\n/s; +} + +sub do_cmd_glstarget{ + local($_) = @_; + + local($id, $label, $text); + + $label = &missing_braces unless + s/$next_pair_pr_rx/$id=$1;$label=$2;''/eo; + + $text = &missing_braces unless + s/$next_pair_pr_rx/$id=$1;$text=$2;''/eo; + + "<A NAME=\"gls:$label\">$text</A>$_"; +} + +sub do_cmd_newglossarystyle{ + local($_) = @_; + + local($id,$style,$defs); + + $style = &missing_braces unless + s/$next_pair_rx/$id=$1;$style=$2;''/eo; + + $defs = &missing_braces unless + s/$next_pair_rx/$id=$1;$defs=$2;''/eo; + + $glossary_style{$style} = $defs; + + $_; +} + +sub do_cmd_glossarystyle{ + local($_) = @_; + + local($id,$style); + + $style = &missing_braces unless + s/$next_pair_pr_rx/$id=$1;$style=$2;''/eo; + + &set_glossarystyle($style); + + $_; +} + +sub set_glossarystyle{ + local($style) = @_; + + $CURRENT_STYLE = $style; + + if ($glossary_style{$style}) + { + local($_) = $glossary_style{$style}; + + s/$O(\d+)$C/$OP$1$CP/g; + + &translate_commands($_); + } + else + { + my $cmd_sub = "set_glossarystyle_$style"; + + if (defined(&$cmd_sub)) + { + &$cmd_sub(); + } + else + { + &write_warnings("Unknown glossary style '$style', defaulting to 'altlist'"); + &set_glossarystyle_altlist(); + + $CURRENT_STYLE = 'altlist'; + } } - $glossary = '<DD>'.$glossary unless ($glossary =~ /^\s*<D(T|D)>/); - $glossary =~ s/(<A [^>]*>)(<D(T|D)>)/$2$1/g; +} + +sub do_cmd_glspar{ "<P>".$_[0]; } + +sub do_cmd_glossaryheader{ + local($_) = @_; + $_ +} + +sub do_cmd_glsentryitem{ + local($_) = @_; + + local($id, $label); + + $label = &missing_braces unless + s/$next_pair_pr_rx/$id=$1,$label=$2;''/eo; + + $_ +} + +sub do_cmd_glssubentryitem{ + local($_) = @_; + + local($id, $label); + + $label = &missing_braces unless + s/$next_pair_pr_rx/$id=$1,$label=$2;''/eo; + + $_ +} + +sub do_cmd_glsgroupheading{ + local($_) = @_; + + local($id, $heading); + + $heading = &missing_braces unless + s/$next_pair_pr_rx/$id=$1,$heading=$2;''/eo; + + $_; +} + +sub do_cmd_glossaryentryfield{ + local($_) = @_; + + local($id, $label, $name, $desc, $symbol, $backlink); + + $label = &missing_braces unless + s/$next_pair_pr_rx/$id=$1;$label=$2;''/eo; + + $name = &missing_braces unless + s/$next_pair_pr_rx/$id=$1;$name=$2;''/eo; + + $desc = &missing_braces unless + s/$next_pair_pr_rx/$id=$1;$desc=$2;''/eo; + + $symbol = &missing_braces unless + s/$next_pair_pr_rx/$id=$1;$symbol=$2;''/eo; + + $backlink = &missing_braces unless + s/$next_pair_pr_rx/$id=$1;$backlink=$2;''/eo; + + local($id2) = ++$global{'max_id'}; + + "\\glstarget $OP$id$CP$label$OP$id$CP$OP$id2$CP$name$OP$id2$CP\n$desc $backlink\n$_"; +} + +sub do_cmd_glossarysubentryfield{ + local($_) = @_; + + local($id, $level, $label, $name, $desc, $symbol, $backlink); + + $level = &missing_braces unless + s/$next_pair_pr_rx/$id=$1;$level=$2;''/eo; + + $label = &missing_braces unless + s/$next_pair_pr_rx/$id=$1;$label=$2;''/eo; + + $name = &missing_braces unless + s/$next_pair_pr_rx/$id=$1;$name=$2;''/eo; - $str = &translate_commands("\\glossarypostamble"); - s/$gls_mark{$type}/$preglossary\n<DL COMPACT>\n$glossary<\/DL>$str\n/s; + $desc = &missing_braces unless + s/$next_pair_pr_rx/$id=$1;$desc=$2;''/eo; + + $symbol = &missing_braces unless + s/$next_pair_pr_rx/$id=$1;$symbol=$2;''/eo; + + $backlink = &missing_braces unless + s/$next_pair_pr_rx/$id=$1;$backlink=$2;''/eo; + + local($id2) = ++$global{'max_id'}; + + "\\glstarget $OP$id$CP$label$OP$id$CP$OP$id2$CP$name$OP$id2$CP\n$desc $backlink\n$_"; +} + +sub do_env_theglossary{ + local($_) = @_; + + &translate_commands($_); +} + +sub set_glossarystyle_altlist{ + eval(<<'END_STYLE'); + sub do_cmd_glossaryheader{ + local($_) = @_; + $_ + } + + sub do_cmd_glsgroupheading{ + local($_) = @_; + + local($id, $heading); + + $heading = &missing_braces unless + s/$next_pair_pr_rx/$id=$1,$heading=$2;''/eo; + + $_ + } + + sub do_cmd_glossaryentryfield{ + local($_) = @_; + + local($id, $id2, $id3, $id4, $id5, $label, $name, $desc, $symbol, $backlink); + + $label = &missing_braces unless + s/$next_pair_pr_rx/$id=$1;$label=$2;''/eo; + + $name = &missing_braces unless + s/$next_pair_pr_rx/$id2=$1;$name=$2;''/eo; + + $desc = &missing_braces unless + s/$next_pair_pr_rx/$id3=$1;$desc=$2;''/eo; + + $symbol = &missing_braces unless + s/$next_pair_pr_rx/$id4=$1;$symbol=$2;''/eo; + + $backlink = &missing_braces unless + s/$next_pair_pr_rx/$id5=$1;$backlink=$2;''/eo; + + "<DT>\\glstarget $OP$id$CP$label$OP$id$CP$OP$id2$CP$name$OP$id2$CP\n<DD>" + . "$desc\\glspostdescription\\space $backlink$_"; + } + + sub do_cmd_glossarysubentryfield{ + local($_) = @_; + + local($id, $id2, $id3, $id4, $id5, $id6, $level, + $label, $name, $desc, $symbol, $backlink); + + $level = &missing_braces unless + s/$next_pair_pr_rx/$id=$1;$level=$2;''/eo; + + $label = &missing_braces unless + s/$next_pair_pr_rx/$id2=$1;$label=$2;''/eo; + + $name = &missing_braces unless + s/$next_pair_pr_rx/$id3=$1;$name=$2;''/eo; + + $desc = &missing_braces unless + s/$next_pair_pr_rx/$id4=$1;$desc=$2;''/eo; + + $symbol = &missing_braces unless + s/$next_pair_pr_rx/$id5=$1;$symbol=$2;''/eo; + + $backlink = &missing_braces unless + s/$next_pair_pr_rx/$id6=$1;$backlink=$2;''/eo; + + "<P>\\glssubentryitem $OP$id$CP$label$OP$id$CP" + ."\\glstarget $OP$id2$CP$label$OP$id2$CP$OP$id3$CP$name$OP$id3$CP" + ."$desc\\glspostdescription\\space $backlink\n$_"; + } + + sub do_env_theglossary{ + local($_) = @_; + + "<DL>".&translate_commands("\\glossaryheader $_")."</DL>"; + } +END_STYLE +} + +sub set_glossarystyle_inline{ + eval(<<'END_STYLE'); + sub do_cmd_glossaryheader{ + local($_) = @_; + $_ + } + + sub do_cmd_glsgroupheading{ + local($_) = @_; + + local($id, $heading); + + $heading = &missing_braces unless + s/$next_pair_pr_rx/$id=$1,$heading=$2;''/eo; + + $_; + } + + sub do_cmd_glossaryentryfield{ + local($_) = @_; + + local($id, $id2, $id3, $id4, $id5, $label, $name, $desc, $symbol, $backlink); + + $label = &missing_braces unless + s/$next_pair_pr_rx/$id=$1;$label=$2;''/eo; + + $name = &missing_braces unless + s/$next_pair_pr_rx/$id2=$1;$name=$2;''/eo; + + $desc = &missing_braces unless + s/$next_pair_pr_rx/$id3=$1;$desc=$2;''/eo; + + $symbol = &missing_braces unless + s/$next_pair_pr_rx/$id4=$1;$symbol=$2;''/eo; + + $backlink = &missing_braces unless + s/$next_pair_pr_rx/$id5=$1;$backlink=$2;''/eo; + + local($field) = "\\glsinlinedopostchild $glsinlinesep"; + + $field .= "\\glsentryitem $OP$id$CP$label$OP$id$CP" + . "\\glsinlinenameformat $OP$id2$CP$label$OP$id2$CP$OP$id3$CP$name$OP$id3$CP"; + + $id3 = ++$global{'max_id'}; + + if ($desc) + { + $field .= + "\\glsinlinedescformat $OP$id3$CP$desc$OP$id3$CP" + ."$OP$id4$CP$symbol$OP$id4$CP" + ."$OP$id5$CP$backlink$OP$id5$CP"; + } + else + { + $field .= + "\\glsinlineemptydescformat " + ."$OP$id4$CP$symbol$OP$id4$CP" + ."$OP$id5$CP$backlink$OP$id5$CP"; + } + +# TODO : check if has children + + local($haschildren) = 0; + + if ($haschildren) + { + $field .= "\\glsresetsubentrycounter " + . "\\glsinlineparentchildseparator " + . "\\glsinlinepostchild "; + } + + $glsinlinesep = &translate_commands("\\glsinlineseparator ") + unless $glsinlinesep; + + $field.$_; + } + + sub do_cmd_glossarysubentryfield{ + local($_) = @_; + + local($id, $id2, $id3, $id4,$id5,$id6,$level, + $label, $name, $desc, $symbol, $backlink); + + $level = &missing_braces unless + s/$next_pair_pr_rx/$id=$1;$level=$2;''/eo; + + $label = &missing_braces unless + s/$next_pair_pr_rx/$id2=$1;$label=$2;''/eo; + + $name = &missing_braces unless + s/$next_pair_pr_rx/$id3=$1;$name=$2;''/eo; + + $desc = &missing_braces unless + s/$next_pair_pr_rx/$id4=$1;$desc=$2;''/eo; + + $symbol = &missing_braces unless + s/$next_pair_pr_rx/$id5=$1;$symbol=$2;''/eo; + + $backlink = &missing_braces unless + s/$next_pair_pr_rx/$id6=$1;$backlink=$2;''/eo; + + "\\glsinlinesubnameformat $OP$id$CP$label$OP$id$CP$OP$id2$CP$name$OP$id2$CP" + ."\\glssubentryitem $OP$id3$CP$label$OP$id3$CP" + ."\\glsinlinesubdescformat $OP$id4$CP$desc$OP$id4$CP$OP$id5$CP$symbol$OP$id5$CP$OP$id6$CP$backlink$OP$id6$CP" + .$_; + } + + sub do_env_theglossary{ + local($_) = @_; + + $glsinlinesep = ''; + + &translate_commands("\\glossaryheader $_\\glspostinline "); + } +END_STYLE +} + +local($glsinlinesep,$glsinlinepostchild); + +sub do_cmd_glsinlineseparator{ + local($_) = @_; + + "; $_"; +} + +sub do_cmd_glsinlinedopostchild{ + local($_) = @_; + + $_; +} + +sub do_cmd_glspostdescription{ + local($_) = @_; + + $GLOSSARY_END_DESCRIPTION.$_; +} + +sub do_cmd_glspostinline{ + local($_) = @_; + + &translate_commands("\\glspostdescription\\space ").$_; +} + +sub do_cmd_glsinlinepostchild{ + local($_) = @_; + + $_; +} + +sub do_cmd_glsinlineparentchildseparator{ + local($_) = @_; + + ": $_"; +} + +sub do_cmd_glsinlinesubseparator{ + local($_) = @_; + + ", $_"; +} + +sub do_cmd_glsinlinenameformat{ + &do_cmd_glstarget(@_); +} + +sub do_cmd_glsinlinedescformat{ + local($_) = @_; + + local($id, $desc, $symbol, $backlinks); + + $desc = &missing_braces unless + s/$next_pair_pr_rx/$id=$1,$desc=$2;''/eo; + + $symbol = &missing_braces unless + s/$next_pair_pr_rx/$id=$1,$symbol=$2;''/eo; + + $backlinks = &missing_braces unless + s/$next_pair_pr_rx/$id=$1,$backlinks=$2;''/eo; + + "\\space $desc$_"; +} + +sub do_cmd_glsinlineemptydescformat{ + local($_) = @_; + + local($id, $symbol, $backlinks); + + $symbol = &missing_braces unless + s/$next_pair_pr_rx/$id=$1,$symbol=$2;''/eo; + + $backlinks = &missing_braces unless + s/$next_pair_pr_rx/$id=$1,$backlinks=$2;''/eo; + + $_; +} + +sub do_cmd_glsinlinesubnameformat{ + local($_) = @_; + + local($id, $id2, $label, $name); + + $label = &missing_braces unless + s/$next_pair_pr_rx/$id=$1,$label=$2;''/eo; + + $name = &missing_braces unless + s/$next_pair_pr_rx/$id2=$1,$name=$2;''/eo; + + "\\glstarget $OP$id$CP$label$OP$id$CP$OP$id2$CP$OP$id2$CP$_"; +} + +sub do_cmd_glsinlinesubdescformat{ + local($_) = @_; + + local($id, $desc, $symbol, $backlinks); + + $desc = &missing_braces unless + s/$next_pair_pr_rx/$id=$1,$desc=$2;''/eo; + + $symbol = &missing_braces unless + s/$next_pair_pr_rx/$id=$1,$symbol=$2;''/eo; + + $backlinks = &missing_braces unless + s/$next_pair_pr_rx/$id=$1,$backlinks=$2;''/eo; + + "$desc$_"; } sub set_depth_levels { @@ -294,12 +1180,12 @@ sub get_firstkeyval{ } # need to get the value of the last key of a given name -# in the event of multiple occurences. +# in the event of multiple occurrences. sub get_keyval{ local($key,$_) = @_; local($value); - while (/\b$key\s*=/) + while (/\b$key\s*=/g) { ($value,$_) = &get_firstkeyval($key, $_); last unless defined($value); @@ -308,6 +1194,18 @@ sub get_keyval{ ($value,$_); } +sub get_boolval{ + local($key,$_) = @_; + local($value); + + while (/\b$key\s*(?:=(true|false))?\b/g) + { + $value = ($1 ? $1 : 'true'); + } + + ($value eq 'true' ? 1 : 0, $_); +} + # This is modified from do_cmd_textohtmlindex sub do_cmd_textohtmlglossary{ @@ -315,18 +1213,22 @@ sub do_cmd_textohtmlglossary{ local($keyval,$pat) = &get_next_optional_argument; - local($type,$title,$toctitle,$style); + local($type,$title,$toctitle,$style,$nonumberlist); + + $nonumberlist = 'default'; ($type,$keyval) = &get_keyval('type', $keyval); ($title,$keyval) = &get_keyval('title', $keyval); ($toctitle,$keyval) = &get_keyval('toctitle', $keyval); ($style,$keyval) = &get_keyval('style', $keyval); + ($nonumberlist,$keyval) = &get_boolval('nonumberlist', $keyval); - &make_textohtmlglossary($type,$toctitle,$title,$style).$_; + &make_textohtmlglossary($type,$toctitle,$title,$style,$nonumberlist).$_; } +# add_real_gls does the actual glossary sub make_textohtmlglossary{ - local($type,$toctitle,$title,$style) = @_; + local($type,$toctitle,$title,$style,$nonumberlist) = @_; unless (defined($type)) {$type = 'main';} @@ -335,8 +1237,19 @@ sub make_textohtmlglossary{ &write_warnings("glossary type '$type' not implemented"); } - unless (defined($title) and $title) {$title = $gls_title{$type};} - unless (defined($toctitle) and $toctitle) {$toctitle = $title;} + if ($style) + { + $gls_style{$type} = $style; + } + + $toctitle = $gls_toctitle{$type} unless ($toctitle or $title); + + $title = $gls_title{$type} unless ($title); + $toctitle = $title unless ($toctitle); + + $gls_toctitle{$type} = $toctitle; + + $gls_nonumberlist{$type} = $nonumberlist unless ($nonumberlist eq 'default'); $toc_sec_title = $toctitle; $glsfile{$type} = $CURRENT_FILE; @@ -364,6 +1277,7 @@ sub make_textohtmlglossary{ , &make_section_heading($title, $idx_head) , $gls_mark{$type} ); local($pre,$post) = &minimize_open_tags($heading); + join('',"<BR>\n" , $pre); } @@ -428,13 +1342,8 @@ sub make_real_glossary_entry { $TITLE = $saved_title if (($saved_title)&&(!($TITLE)||($TITLE eq $default_title))); - local($sort) = $glsentry{$entry}{'sort'}; - # Save the reference - local($str) = "$sort###" . ++$global{'max_id'}; # Make unique - # concatenate multiple spaces into a single space - # otherwise keys won't sort properly - $str=~s/\s+/ /gs; + local($str) = "$label###" . ++$global{'max_id'}; # Make unique local($id) = ++$glsentry{$entry}{'maxid'}; local($glsanchor)="gls:$entry$id"; @@ -451,13 +1360,46 @@ sub make_real_glossary_entry { $glossary_entry{$type}{$str} = $entry; $glossary_linktext{$type}{$str} = $TITLE; + local($mark) = $gls_file_mark{$type}; + + $mark = &get_gls_file_mark($type, $entry) if (defined(&get_gls_file_mark)); + + $text = &translate_commands($text); + + if (defined($frame_foot_name)) + { + "<A HREF=\"$mark#gls:$entry\" NAME=\"$glsanchor\" TARGET=\"$frame_foot_name\">$text<\/A>"; + } + else + { + "<A HREF=\"$mark#gls:$entry\" NAME=\"$glsanchor\">$text<\/A>"; + } +} + +sub make_real_glossary_entry_no_backlink { + local($entry,$text,$type) = @_; + local($this_file) = $CURRENT_FILE; + + local($target) = $frame_body_name; + + if (defined($frame_main_suffix)) + { + $this_file=~s/$frame_main_suffix/$frame_body_suffix/; + } + + local($mark) = $gls_file_mark{$type}; + + $mark = &get_gls_file_mark($type, $entry) if (defined(&get_gls_file_mark)); + + $text = &translate_commands($text); + if (defined($frame_foot_name)) { - "<A HREF=$gls_file_mark{$type}#gls:$entry NAME=\"$glsanchor\" TARGET=\"$frame_foot_name\">$text<\/A>"; + "<A HREF=\"$mark#gls:$entry\" NAME=\"$glsanchor\" TARGET=\"$frame_foot_name\">$text<\/A>"; } else { - "<A HREF=$gls_file_mark{$type}#gls:$entry NAME=\"$glsanchor\">$text<\/A>"; + "<A HREF=\"$mark#gls:$entry\" >$text<\/A>"; } } @@ -489,11 +1431,13 @@ sub make_newglossarytype{ $gls_mark{$type} = "<tex2html_gls_${type}_mark>"; $gls_file_mark{$type} = "<tex2html_gls_${type}_file_mark>"; $gls_title{$type} = $title; + $gls_toctitle{$type} = $title; $delimN{$type} = ", "; $glsnumformat{$type} = $GLSCURRENTFORMAT; @{$gls_entries{$type}} = (); $gls_displayfirst{$type} = "glsdisplayfirst"; $gls_display{$type} = "glsdisplay"; + $gls_nonumberlist{$type} = $gls_nonumberlist{'main'}; } sub do_cmd_glsdisplay{ @@ -631,15 +1575,21 @@ sub gls_entry_init{ ( type => $type, name => $name, 'sort' => $name, - description => $description, + description => $desc, text => $name, first => $name, plural => "${name}s", firstplural => "${name}s", symbol => '', flag => 0, - maxid=>0 + maxid => 0, + level => 0, + parent => '' ); + + $#{@{$glsentry{$label}{children}}} = -1; + + $glsentry{$label}; } sub gls_get_type{ @@ -903,6 +1853,228 @@ sub gls_set_first{ } } +sub gls_get_parent{ + local($label) = @_; + + local($parent); + + if (&gls_entry_defined($label)) + { + $parent = $glsentry{$label}{'parent'}; + } + else + { + &write_warnings("gls_get_parent: glossary entry '$label' has not been defined"); + } + + $parent; +} + +sub gls_get_level{ + local($label) = @_; + + local($level) = 0; + + if (&gls_entry_defined($label)) + { + $level = $glsentry{$label}{'level'}; + } + else + { + &write_warnings("gls_get_level: glossary entry '$label' has not been defined"); + } + + $level; +} + +sub gls_set_parent{ + local ($label, $parent) = @_; + + if (&gls_entry_defined($label)) + { + if ($parent) + { + if (&gls_entry_defined($parent)) + { + $glsentry{$label}{'parent'} = $parent; + + push @{$glsentry{$parent}{'children'}}, $label; + + $glsentry{$label}{'level'} = $glsentry{$parent}{'level'}+1; + } + else + { + &write_warnings("gls_set_parent: parent '$parent' for glossary entry '$label' has not been defined"); + } + } + else + { + $glsentry{$label}{'parent'} = ''; + } + } + else + { + &write_warnings("gls_set_parent: glossary entry '$label' has not been defined"); + } +} + +sub gls_get_childcount{ + my($label) = @_; + + my($count) = 0; + + if (&gls_entry_defined($label)) + { + $count = scalar(@{$glsentry{$label}{'children'}}); + } + else + { + &write_warnings("gls_get_childcount: glossary entry '$label' has not been defined"); + } + + $count; +} + +sub gls_get_referenced_childcount{ + my($label) = @_; + + my($count) = 0; + + if (&gls_entry_defined($label)) + { + $count = scalar(grep(($glsentry{$_}{'maxid'} > 0), @{$glsentry{$label}{'children'}})); + } + else + { + &write_warnings("gls_get_childcount: glossary entry '$label' has not been defined"); + } + + $count; +} + +sub gls_set_userkeys{ + local($label, @user) = @_; + + if (&gls_entry_defined($label)) + { + for (my $idx = 0; $idx < 6; $idx++) + { + $glsentry{$label}{"user".($idx+1)} = $user[$idx]; + } + } + else + { + &write_warnings("gls_set_user: glossary entry '$label' has not been defined"); + } +} + +sub gls_set_user{ + local($label, $idx, $text) = @_; + + if (&gls_entry_defined($label)) + { + $glsentry{$label}{"user$idx"} = $text; + } + else + { + &write_warnings("gls_set_user: glossary entry '$label' has not been defined"); + } +} + +sub gls_set_useri{ + local($label, $text) = @_; + + if (&gls_entry_defined($label)) + { + $glsentry{$label}{'user1'} = $text; + } + else + { + &write_warnings("gls_set_useri: glossary entry '$label' has not been defined"); + } +} + +sub gls_set_userii{ + local($label, $text) = @_; + + if (&gls_entry_defined($label)) + { + $glsentry{$label}{'user2'} = $text; + } + else + { + &write_warnings("gls_set_userii: glossary entry '$label' has not been defined"); + } +} + +sub gls_set_useriii{ + local($label, $text) = @_; + + if (&gls_entry_defined($label)) + { + $glsentry{$label}{'user3'} = $text; + } + else + { + &write_warnings("gls_set_useriii: glossary entry '$label' has not been defined"); + } +} + +sub gls_set_useriv{ + local($label, $text) = @_; + + if (&gls_entry_defined($label)) + { + $glsentry{$label}{'user4'} = $text; + } + else + { + &write_warnings("gls_set_useriv: glossary entry '$label' has not been defined"); + } +} + +sub gls_set_userv{ + local($label, $text) = @_; + + if (&gls_entry_defined($label)) + { + $glsentry{$label}{'user5'} = $text; + } + else + { + &write_warnings("gls_set_userv: glossary entry '$label' has not been defined"); + } +} + +sub gls_set_uservi{ + local($label, $text) = @_; + + if (&gls_entry_defined($label)) + { + $glsentry{$label}{'user6'} = $text; + } + else + { + &write_warnings("gls_set_uservi: glossary entry '$label' has not been defined"); + } +} + +sub gls_get_user{ + local($label, $idx) = @_; + local($value) = ''; + + if (&gls_entry_defined($label)) + { + $value = $glsentry{$label}{"user".$idx}; + } + else + { + &write_warnings("gls_get_user[$idx]: glossary entry '$label' has not been defined"); + } + + $value; +} + sub gls_used{ local($label) = @_; local($flag) = 0; @@ -922,13 +2094,13 @@ sub gls_used{ sub gls_entry_defined{ local($label) = @_; - defined(%{$glsentry{$label}}); + (%{$glsentry{$label}}) ? 1 : 0; } sub do_cmd_newglossaryentry{ local($_) = @_; local($label,$name,$description,$symbol,$sort,$text,$first, - $plural,$firstplural,$type,$keyval); + $plural,$firstplural,$type,$keyval,$parent,@user); $label = &missing_braces unless s/$next_pair_pr_rx/$label=$2;''/eo; @@ -945,6 +2117,19 @@ sub do_cmd_newglossaryentry{ ($firstplural,$keyval) = &get_keyval('firstplural', $keyval); ($plural,$keyval) = &get_keyval('plural', $keyval); ($type,$keyval) = &get_keyval('type', $keyval); + ($parent,$keyval) = &get_keyval('parent', $keyval); + + if ($parent and not $name) + { + $name = &gls_get_name($parent); + } + + @user = (); + + for (my $idx = 0; $idx < 6; $idx++) + { + ($user[$idx],$keyval) = &get_keyval("user".($idx+1), $keyval); + } if (defined($type)) { @@ -979,6 +2164,10 @@ sub do_cmd_newglossaryentry{ &gls_set_firstplural($label, $firstplural); + &gls_set_userkeys($label, @user); + + &gls_set_parent($label, $parent); + push @{$gls_entries{$type}}, $label; $_; @@ -1085,12 +2274,35 @@ sub do_cmd_glsadd{ $type = &gls_get_type($label); + local($dobacklink) = 1; + + if (&gls_used($label)) + { + if ($INDEXONLYFIRST) + { + $dobacklink = 0; + } + } + else + { + &unset_entry($label); + } + if (defined $type) { ($format,$optarg) = &get_keyval('format', $optarg); $format='' unless(defined($format)); - &gls_add_entry($type,$label,$format,""); + if ($dobacklink) + { + &gls_add_entry($type,$label,$format,""); + } + else + { + $glsentry{$label}{'maxid'} = ++$glsentry{$entry}{'maxid'}; + my $key = $label."###".$glsentry{$label}{'maxid'}; + $glossary{$type}{$key}=''; + } } else { @@ -1105,28 +2317,45 @@ sub do_cmd_glsaddall{ local($_) = @_; local($optarg,$pat) = &get_next_optional_argument; - local($format,$types); - - ($type,$optarg) = &get_keyval('types', $optarg); + local($format,$list); + ($list,$optarg) = &get_keyval('types', $optarg); ($format,$optarg) = &get_keyval('format', $optarg); + $format='' unless(defined($format)); local(@types) = keys(%gls_mark); - if (defined($types)) + if ($list) { - @types = split /,/, $types; + @types = split /\s*,\s*/, $list; } foreach $type (@types) { - # strip leasing and trailing spaces + # strip leading and trailing spaces $type=~s/^\s*([^\s]+)\s*$/\1/; foreach $label (@{$gls_entries{$type}}) { - &gls_add_entry($type,$label,$format,""); + local($dobacklink) = 1; + + if (&gls_used($label)) + { + if ($INDEXONLYFIRST) + { + $dobacklink = 0; + } + } + else + { + &unset_entry($label); + } + + if ($dobacklink) + { + &gls_add_entry($type,$label,$format,""); + } } } @@ -1250,6 +2479,64 @@ sub do_cmd_glslinkstar{ $text . $_; } +sub do_cmd_glsdisp{ + local($_) = @_; + local($optarg,$pat,$label,$text,$type,$format,$str); + + ($optarg,$pat) = &get_next_optional_argument; + + ($format,$optarg) = &get_keyval('format', $optarg); + + $label = &missing_braces unless + (s/$next_pair_pr_rx/$label=$2;''/eo); + + $text = &missing_braces unless + (s/$next_pair_pr_rx/$text=$2;''/eo); + + local($dobacklink) = 1; + + if (&gls_used($label)) + { + if ($INDEXONLYFIRST) + { + $dobacklink = 0; + } + } + else + { + &unset_entry($label); + } + + $type = &gls_get_type($label); + + if ($dobacklink) + { + &make_glslink($type, $label, $format, $text) .$space . $_; + } + else + { + &make_real_glossary_entry_no_backlink($label, $text, $type). $space . $_; + } +} + +sub do_cmd_glshyperlink{ + local($_) = @_; + + local($text,$pat) = &get_next_optional_argument; + + local($id, $label); + + $label = &missing_braces unless + s/$next_pair_pr_rx/$id=$1,$label=$2;''/eo; + + $text = &gls_get_text($label) unless $text; + + local($type) = &gls_get_type($label); + + "<A HREF=\"$gls_file_mark{$type}#gls:$label\">$text<\/A>" + .$_; +} + sub do_cmd_glsentrydesc{ local($_) = @_; @@ -1265,7 +2552,7 @@ sub do_cmd_Glsentrydesc{ $label = &missing_braces unless (s/$next_pair_pr_rx/$label=$2;''/eo); - ucfirst(&gls_get_description($label)).$_; + &do_real_makefirstuc(&gls_get_description($label)).$_; } sub do_cmd_glsentrytext{ @@ -1283,7 +2570,7 @@ sub do_cmd_Glsentrytext{ $label = &missing_braces unless (s/$next_pair_pr_rx/$label=$2;''/eo); - ucfirst(&gls_get_text($label)).$_; + &do_real_makefirstuc(&gls_get_text($label)).$_; } sub do_cmd_glsentryname{ @@ -1301,7 +2588,7 @@ sub do_cmd_Glsentryname{ $label = &missing_braces unless (s/$next_pair_pr_rx/$label=$2;''/eo); - ucfirst(&gls_get_name($label)).$_; + &do_real_makefirstuc(&gls_get_name($label)).$_; } sub do_cmd_glsentryfirst{ @@ -1319,7 +2606,7 @@ sub do_cmd_Glsentryfirst{ $label = &missing_braces unless (s/$next_pair_pr_rx/$label=$2;''/eo); - ucfirst(&gls_get_first($label)).$_; + &do_real_makefirstuc(&gls_get_first($label)).$_; } sub do_cmd_glsentryplural{ @@ -1337,7 +2624,7 @@ sub do_cmd_Glsentryplural{ $label = &missing_braces unless (s/$next_pair_pr_rx/$label=$2;''/eo); - ucfirst(&gls_get_plural($label)).$_; + &do_real_makefirstuc(&gls_get_plural($label)).$_; } sub do_cmd_glsentryfirstplural{ @@ -1364,7 +2651,7 @@ sub do_cmd_Glsentryfirstplural{ $label = &missing_braces unless (s/$next_pair_pr_rx/$label=$2;''/eo); - ucfirst(&gls_get_firstplural($label)).$_; + &do_real_makefirstuc(&gls_get_firstplural($label)).$_; } sub do_cmd_glsentrysymbol{ @@ -1382,7 +2669,61 @@ sub do_cmd_Glsentrysymbol{ $label = &missing_braces unless (s/$next_pair_pr_rx/$label=$2;''/eo); - ucfirst(&gls_get_symbol($label)).$_; + &do_real_makefirstuc(&gls_get_symbol($label)).$_; +} + +sub do_cmd_glsentryuseri{ + local($_) = @_; + + $label = &missing_braces unless + (s/$next_pair_pr_rx/$label=$2;''/eo); + + &gls_get_user($label, 1).$_; +} + +sub do_cmd_glsentryuserii{ + local($_) = @_; + + $label = &missing_braces unless + (s/$next_pair_pr_rx/$label=$2;''/eo); + + &gls_get_user($label, 2).$_; +} + +sub do_cmd_glsentryuseriii{ + local($_) = @_; + + $label = &missing_braces unless + (s/$next_pair_pr_rx/$label=$2;''/eo); + + &gls_get_user($label, 3).$_; +} + +sub do_cmd_glsentryuseriv{ + local($_) = @_; + + $label = &missing_braces unless + (s/$next_pair_pr_rx/$label=$2;''/eo); + + &gls_get_user($label, 4).$_; +} + +sub do_cmd_glsentryuserv{ + local($_) = @_; + + $label = &missing_braces unless + (s/$next_pair_pr_rx/$label=$2;''/eo); + + &gls_get_user($label, 5).$_; +} + +sub do_cmd_glsentryuservi{ + local($_) = @_; + + $label = &missing_braces unless + (s/$next_pair_pr_rx/$label=$2;''/eo); + + &gls_get_user($label, 6).$_; } sub do_cmd_gls{ @@ -1406,12 +2747,19 @@ sub do_cmd_gls{ local($type) = &gls_get_type($label); + local($dobacklink) = 1; + if (&gls_used($label)) { # entry has already been used $text = &gls_get_text($label); $display = &gls_get_display($type); + + if ($INDEXONLYFIRST) + { + $dobacklink = 0; + } } else { @@ -1439,7 +2787,14 @@ sub do_cmd_gls{ local($link_text) = &translate_commands("$display$args"); - &make_glslink($type, $label, $format, $link_text) .$space . $_; + if ($dobacklink) + { + &make_glslink($type, $label, $format, $link_text) .$space . $_; + } + else + { + &make_real_glossary_entry_no_backlink($label, $link_text, $type). $space . $_; + } } # added v1.04 @@ -1521,12 +2876,19 @@ sub do_cmd_glspl{ local($type) = $glsentry{$label}{'type'}; + local($dobacklink) = 1; + if (&gls_used($label)) { # entry has already been used $text = &gls_get_plural($label); $display = &gls_get_display($type);; + + if ($INDEXONLYFIRST) + { + $dobacklink = 0; + } } else { @@ -1554,7 +2916,14 @@ sub do_cmd_glspl{ local($link_text) = &translate_commands("$display$args"); - &make_glslink($type, $label, $format, $link_text) . $space . $_; + if ($dobacklink) + { + &make_glslink($type, $label, $format, $link_text) .$space . $_; + } + else + { + &make_real_glossary_entry_no_backlink($label, $link_text, $type). $space . $_; + } } # added v1.04 @@ -1636,12 +3005,19 @@ sub do_cmd_Gls{ local($type) = $glsentry{$label}{'type'}; + local($dobacklink) = 1; + if (&gls_used($label)) { # entry has already been used $text = &gls_get_text($label); $display = &gls_get_display($type);; + + if ($INDEXONLYFIRST) + { + $dobacklink = 0; + } } else { @@ -1667,9 +3043,16 @@ sub do_cmd_Gls{ $id = ++$global{'max_id'}; $args .= "$OP$id$CP$insert$OP$id$CP"; - local($link_text) = &translate_commands("$display$args"); + local($link_text) = &do_real_makefirstuc(&translate_commands("$display$args")); - &make_glslink($type, $label, $format, ucfirst($link_text)). $space . $_; + if ($dobacklink) + { + &make_glslink($type, $label, $format, $link_text) .$space . $_; + } + else + { + &make_real_glossary_entry_no_backlink($label, $link_text, $type). $space . $_; + } } # added v1.04 @@ -1727,7 +3110,7 @@ sub do_cmd_Glsstar{ local($link_text) = &translate_commands("$display$args"); - ucfirst($link_text). $space . $_; + &do_real_makefirstuc($link_text). $space . $_; } sub do_cmd_Glspl{ @@ -1751,12 +3134,19 @@ sub do_cmd_Glspl{ local($type) = $glsentry{$label}{'type'}; + local($dobacklink) = 1; + if (&gls_used($label)) { # entry has already been used $text = &gls_get_plural($label); $display = &gls_get_display($type);; + + if ($INDEXONLYFIRST) + { + $dobacklink = 0; + } } else { @@ -1782,9 +3172,16 @@ sub do_cmd_Glspl{ $id = ++$global{'max_id'}; $args .= "$OP$id$CP$insert$OP$id$CP"; - local($link_text) = &translate_commands("$display$args"); + local($link_text) = &do_real_makefirstuc(&translate_commands("$display$args")); - &make_glslink($type, $label, $format, ucfirst($link_text)).$space . $_; + if ($dobacklink) + { + &make_glslink($type, $label, $format, $link_text) .$space . $_; + } + else + { + &make_real_glossary_entry_no_backlink($label, $link_text, $type). $space . $_; + } } # added v1.04 @@ -1842,7 +3239,7 @@ sub do_cmd_Glsplstar{ local($link_text) = &translate_commands("$display$args"); - ucfirst($link_text).$space . $_; + &do_real_makefirstuc($link_text).$space . $_; } sub do_cmd_GLS{ @@ -1866,12 +3263,19 @@ sub do_cmd_GLS{ local($type) = $glsentry{$label}{'type'}; + local($dobacklink) = 1; + if (&gls_used($label)) { # entry has already been used $text = &gls_get_text($label); $display = &gls_get_display($type);; + + if ($INDEXONLYFIRST) + { + $dobacklink = 0; + } } else { @@ -1897,9 +3301,16 @@ sub do_cmd_GLS{ $id = ++$global{'max_id'}; $args .= "$OP$id$CP$insert$OP$id$CP"; - local($link_text) = &translate_commands("$display$args"); + local($link_text) = uc(&translate_commands("$display$args")); - &make_glslink($type, $label, $format, uc($link_text)).$space . $_; + if ($dobacklink) + { + &make_glslink($type, $label, $format, $link_text) .$space . $_; + } + else + { + &make_real_glossary_entry_no_backlink($label, $link_text, $type). $space . $_; + } } # added v1.04 @@ -1981,12 +3392,19 @@ sub do_cmd_GLSpl{ local($type) = $glsentry{$label}{'type'}; + local($dobacklink) = 1; + if (&gls_used($label)) { # entry has already been used $text = &gls_get_plural($label); $display = &gls_get_display($type);; + + if ($INDEXONLYFIRST) + { + $dobacklink = 0; + } } else { @@ -2012,9 +3430,16 @@ sub do_cmd_GLSpl{ $id = ++$global{'max_id'}; $args .= "$OP$id$CP$insert$OP$id$CP"; - local($link_text) = &translate_commands("$display$args"); + local($link_text) = uc(&translate_commands("$display$args")); - &make_glslink($type, $label, $format, uc($link_text)).$space . $_; + if ($dobacklink) + { + &make_glslink($type, $label, $format, $link_text) .$space . $_; + } + else + { + &make_real_glossary_entry_no_backlink($label, $link_text, $type). $space . $_; + } } # added v1.04 @@ -2126,7 +3551,7 @@ sub do_cmd_Glstext{ $text = &gls_get_text($label); - &make_glslink($type, $label, $format, ucfirst($text)) .$space . $_; + &make_glslink($type, $label, $format, &do_real_makefirstuc($text)) .$space . $_; } # added 22 Feb 2008 @@ -2207,7 +3632,7 @@ sub do_cmd_Glsname{ $text = &gls_get_name($label); - &make_glslink($type, $label, $format, ucfirst($text)) .$space . $_; + &make_glslink($type, $label, $format, &do_real_makefirstuc($text)) .$space . $_; } # added 22 Feb 2008 @@ -2288,7 +3713,7 @@ sub do_cmd_Glsfirst{ $text = &gls_get_first($label); - &make_glslink($type, $label, $format, ucfirst($text)) .$space . $_; + &make_glslink($type, $label, $format, &do_real_makefirstuc($text)) .$space . $_; } # added 22 Feb 2008 @@ -2369,7 +3794,7 @@ sub do_cmd_Glsfirstplural{ $text = &gls_get_firstplural($label); - &make_glslink($type, $label, $format, ucfirst($text)) .$space . $_; + &make_glslink($type, $label, $format, &do_real_makefirstuc($text)) .$space . $_; } # added 22 Feb 2008 @@ -2450,7 +3875,7 @@ sub do_cmd_Glsplural{ $text = &gls_get_plural($label); - &make_glslink($type, $label, $format, ucfirst($text)) .$space . $_; + &make_glslink($type, $label, $format, &do_real_makefirstuc($text)) .$space . $_; } # added 22 Feb 2008 @@ -2531,7 +3956,7 @@ sub do_cmd_Glsdesc{ $text = &gls_get_description($label); - &make_glslink($type, $label, $format, ucfirst($text)) .$space . $_; + &make_glslink($type, $label, $format, &do_real_makefirstuc($text)) .$space . $_; } # added 22 Feb 2008 @@ -2612,7 +4037,7 @@ sub do_cmd_Glssymbol{ $text = &gls_get_symbol($label); - &make_glslink($type, $label, $format, ucfirst($text)) .$space . $_; + &make_glslink($type, $label, $format, &do_real_makefirstuc($text)) .$space . $_; } # added 22 Feb 2008 @@ -2642,6 +4067,318 @@ sub do_cmd_GLSsymbol{ &make_glslink($type, $label, $format, uc($text)) .$space . $_; } +sub do_cmd_glsuseri{ + local($_) = @_; + local($optarg,$pat,$label,$text, $format, $insert); + + ($optarg,$pat) = &get_next_optional_argument; + + ($format,$optarg) = &get_keyval('format', $optarg); + + $label = &missing_braces unless + (s/$next_pair_pr_rx/$label=$2;''/eo); + + local ($space) = ''; + if (/^\s+[^\[]/ or /^\s*\[.*\]\s/) {$space = ' ';} + + $insert = ''; + ($insert,$pat) = &get_next_optional_argument; + + local($display) = ''; + + local($type) = &gls_get_type($label); + + $text = &gls_get_user($label, 1); + + &make_glslink($type, $label, $format, $text) .$space . $_; +} + +sub do_cmd_Glsuseri{ + local($_) = @_; + local($optarg,$pat,$label,$text, $format, $insert); + + ($optarg,$pat) = &get_next_optional_argument; + + ($format,$optarg) = &get_keyval('format', $optarg); + + $label = &missing_braces unless + (s/$next_pair_pr_rx/$label=$2;''/eo); + + local ($space) = ''; + if (/^\s+[^\[]/ or /^\s*\[.*\]\s/) {$space = ' ';} + + $insert = ''; + ($insert,$pat) = &get_next_optional_argument; + + local($display) = ''; + + local($type) = &gls_get_type($label); + + $text = &do_real_makefirstuc(&gls_get_user($label, 1)); + + &make_glslink($type, $label, $format, $text) .$space . $_; +} + +sub do_cmd_glsuserii{ + local($_) = @_; + local($optarg,$pat,$label,$text, $format, $insert); + + ($optarg,$pat) = &get_next_optional_argument; + + ($format,$optarg) = &get_keyval('format', $optarg); + + $label = &missing_braces unless + (s/$next_pair_pr_rx/$label=$2;''/eo); + + local ($space) = ''; + if (/^\s+[^\[]/ or /^\s*\[.*\]\s/) {$space = ' ';} + + $insert = ''; + ($insert,$pat) = &get_next_optional_argument; + + local($display) = ''; + + local($type) = &gls_get_type($label); + + $text = &gls_get_user($label, 2); + + &make_glslink($type, $label, $format, $text) .$space . $_; +} + +sub do_cmd_Glsuserii{ + local($_) = @_; + local($optarg,$pat,$label,$text, $format, $insert); + + ($optarg,$pat) = &get_next_optional_argument; + + ($format,$optarg) = &get_keyval('format', $optarg); + + $label = &missing_braces unless + (s/$next_pair_pr_rx/$label=$2;''/eo); + + local ($space) = ''; + if (/^\s+[^\[]/ or /^\s*\[.*\]\s/) {$space = ' ';} + + $insert = ''; + ($insert,$pat) = &get_next_optional_argument; + + local($display) = ''; + + local($type) = &gls_get_type($label); + + $text = &do_real_makefirstuc(&gls_get_user($label, 2)); + + &make_glslink($type, $label, $format, $text) .$space . $_; +} + +sub do_cmd_glsuseriii{ + local($_) = @_; + local($optarg,$pat,$label,$text, $format, $insert); + + ($optarg,$pat) = &get_next_optional_argument; + + ($format,$optarg) = &get_keyval('format', $optarg); + + $label = &missing_braces unless + (s/$next_pair_pr_rx/$label=$2;''/eo); + + local ($space) = ''; + if (/^\s+[^\[]/ or /^\s*\[.*\]\s/) {$space = ' ';} + + $insert = ''; + ($insert,$pat) = &get_next_optional_argument; + + local($display) = ''; + + local($type) = &gls_get_type($label); + + $text = &gls_get_user($label, 3); + + &make_glslink($type, $label, $format, $text) .$space . $_; +} + +sub do_cmd_Glsuseriii{ + local($_) = @_; + local($optarg,$pat,$label,$text, $format, $insert); + + ($optarg,$pat) = &get_next_optional_argument; + + ($format,$optarg) = &get_keyval('format', $optarg); + + $label = &missing_braces unless + (s/$next_pair_pr_rx/$label=$2;''/eo); + + local ($space) = ''; + if (/^\s+[^\[]/ or /^\s*\[.*\]\s/) {$space = ' ';} + + $insert = ''; + ($insert,$pat) = &get_next_optional_argument; + + local($display) = ''; + + local($type) = &gls_get_type($label); + + $text = &do_real_makefirstuc(&gls_get_user($label, 3)); + + &make_glslink($type, $label, $format, $text) .$space . $_; +} + +sub do_cmd_glsuseriv{ + local($_) = @_; + local($optarg,$pat,$label,$text, $format, $insert); + + ($optarg,$pat) = &get_next_optional_argument; + + ($format,$optarg) = &get_keyval('format', $optarg); + + $label = &missing_braces unless + (s/$next_pair_pr_rx/$label=$2;''/eo); + + local ($space) = ''; + if (/^\s+[^\[]/ or /^\s*\[.*\]\s/) {$space = ' ';} + + $insert = ''; + ($insert,$pat) = &get_next_optional_argument; + + local($display) = ''; + + local($type) = &gls_get_type($label); + + $text = &gls_get_user($label, 4); + + &make_glslink($type, $label, $format, $text) .$space . $_; +} + +sub do_cmd_Glsuseriv{ + local($_) = @_; + local($optarg,$pat,$label,$text, $format, $insert); + + ($optarg,$pat) = &get_next_optional_argument; + + ($format,$optarg) = &get_keyval('format', $optarg); + + $label = &missing_braces unless + (s/$next_pair_pr_rx/$label=$2;''/eo); + + local ($space) = ''; + if (/^\s+[^\[]/ or /^\s*\[.*\]\s/) {$space = ' ';} + + $insert = ''; + ($insert,$pat) = &get_next_optional_argument; + + local($display) = ''; + + local($type) = &gls_get_type($label); + + $text = &do_real_makefirstuc(&gls_get_user($label, 4)); + + &make_glslink($type, $label, $format, $text) .$space . $_; +} + +sub do_cmd_glsuserv{ + local($_) = @_; + local($optarg,$pat,$label,$text, $format, $insert); + + ($optarg,$pat) = &get_next_optional_argument; + + ($format,$optarg) = &get_keyval('format', $optarg); + + $label = &missing_braces unless + (s/$next_pair_pr_rx/$label=$2;''/eo); + + local ($space) = ''; + if (/^\s+[^\[]/ or /^\s*\[.*\]\s/) {$space = ' ';} + + $insert = ''; + ($insert,$pat) = &get_next_optional_argument; + + local($display) = ''; + + local($type) = &gls_get_type($label); + + $text = &gls_get_user($label, 5); + + &make_glslink($type, $label, $format, $text) .$space . $_; +} + +sub do_cmd_Glsuserv{ + local($_) = @_; + local($optarg,$pat,$label,$text, $format, $insert); + + ($optarg,$pat) = &get_next_optional_argument; + + ($format,$optarg) = &get_keyval('format', $optarg); + + $label = &missing_braces unless + (s/$next_pair_pr_rx/$label=$2;''/eo); + + local ($space) = ''; + if (/^\s+[^\[]/ or /^\s*\[.*\]\s/) {$space = ' ';} + + $insert = ''; + ($insert,$pat) = &get_next_optional_argument; + + local($display) = ''; + + local($type) = &gls_get_type($label); + + $text = &do_real_makefirstuc(&gls_get_user($label, 5)); + + &make_glslink($type, $label, $format, $text) .$space . $_; +} + +sub do_cmd_glsuservi{ + local($_) = @_; + local($optarg,$pat,$label,$text, $format, $insert); + + ($optarg,$pat) = &get_next_optional_argument; + + ($format,$optarg) = &get_keyval('format', $optarg); + + $label = &missing_braces unless + (s/$next_pair_pr_rx/$label=$2;''/eo); + + local ($space) = ''; + if (/^\s+[^\[]/ or /^\s*\[.*\]\s/) {$space = ' ';} + + $insert = ''; + ($insert,$pat) = &get_next_optional_argument; + + local($display) = ''; + + local($type) = &gls_get_type($label); + + $text = &gls_get_user($label, 6); + + &make_glslink($type, $label, $format, $text) .$space . $_; +} + +sub do_cmd_Glsuservi{ + local($_) = @_; + local($optarg,$pat,$label,$text, $format, $insert); + + ($optarg,$pat) = &get_next_optional_argument; + + ($format,$optarg) = &get_keyval('format', $optarg); + + $label = &missing_braces unless + (s/$next_pair_pr_rx/$label=$2;''/eo); + + local ($space) = ''; + if (/^\s+[^\[]/ or /^\s*\[.*\]\s/) {$space = ' ';} + + $insert = ''; + ($insert,$pat) = &get_next_optional_argument; + + local($display) = ''; + + local($type) = &gls_get_type($label); + + $text = &do_real_makefirstuc(&gls_get_user($label, 6)); + + &make_glslink($type, $label, $format, $text) .$space . $_; +} + sub do_cmd_acrshort{ &do_cmd_glstext(@_) } @@ -2717,7 +4454,7 @@ sub do_cmd_hyperbf{ &ignore_commands( <<_IGNORED_CMDS_ ); makeglossary makeglossaries -glossarystyle {} +glossaryentrynumbers # {} _IGNORED_CMDS_ 1; diff --git a/Master/texmf-dist/source/latex/glossaries/mfirstuc.perl b/Master/texmf-dist/source/latex/glossaries/mfirstuc.perl new file mode 100644 index 00000000000..7ab863d06f4 --- /dev/null +++ b/Master/texmf-dist/source/latex/glossaries/mfirstuc.perl @@ -0,0 +1,129 @@ +# File : mfirstuc.perl +# Author : Nicola L. C. Talbot +# Date : 2012-09-21 +# Version : 1.0 +# Description : LaTeX2HTML (limited!) implementation of mfirstuc package + +# This is a LaTeX2HTML style implementing the mfirstuc package, and +# is distributed as part of the glossaries package. +# Copyright 2007 Nicola L.C. Talbot +# This work may be distributed and/or modified under the +# conditions of the LaTeX Project Public License, either version 1.3 +# of this license of (at your option) any later version. +# The latest version of this license is in +# http://www.latex-project.org/lppl.txt +# and version 1.3 or later is part of all distributions of LaTeX +# version 2005/12/01 or later. +# +# This work has the LPPL maintenance status `maintained'. +# +# The Current Maintainer of this work is Nicola Talbot. + +use warnings; + +package main; + +sub do_cmd_makefirstuc{ + local($_) = @_; + + local($id,$text); + + $text = &missing_braces unless + s/$next_pair_pr_rx/$id=$1;$text=$2;''/eo; + + &translate_commands("\\glsmakefirstuc $text") . $_; +} + +sub do_cmd_xmakefirstuc{ + local($_) = @_; + + local($id,$text); + + $text = &missing_braces unless + s/$next_pair_pr_rx/$id=$1;$text=$2;''/eo; + + unless ($id) + { + $id = ++$global{'max_id'}; + } + + &translate_commands("\\expandafter \\makefirstuc $OP$id$CP$text$OP$id$CP") + . $_; +} + +sub do_cmd_glsmakefirstuc{ + local($_) = @_; + + local($id,$text); + + $text = &get_next_object unless + s/$next_pair_pr_rx/$id=$1;$text=$2;''/eo; + + &do_real_makefirstuc($text).$_; +} + +sub do_real_makefirstuc{ + local($text) = @_; + + if ($text=~/^((?:\s*<[^>]+>\s*)+)(.*)/) + { + $text = $1 . ucfirst($2); + } + else + { + $text = ucfirst($text); + } + + $text; +} + +sub do_cmd_capitalisewords{ + local($_) = @_; + + local($id,$text); + + $text = &missing_braces unless + s/$next_pair_pr_rx/$id=$1;$text=$2;''/eo; + + local($newtext) = ''; + + foreach my $word (split ' ', $text) + { + $id = ++$global{'max_id'}; + + $word = &translate_commands("\\makefirstuc $OP$id$CP$word$OP$id$CP"); + + if ($newtext) + { + $newtext .= ' ' . $word; + } + else + { + $newtext = $word; + } + } + + $newtext.$_; +} + +sub get_next_object{ + local($next, $revert, $thisline); + local($this_cmd) = $cmd; + $this_cmd =~ s/^\\// unless ($cmd eq "\\"); + if (/^[\s%]*([^\n]*)\n/ ) { + $thisline = &revert_to_raw_tex($1) + } else { + $thisline = &revert_to_raw_tex($_); + } + s/^\s*//; + if ($_ =~ s/$next_token_rx//) { $next = $& }; + $next =~ s/$comment_mark(\d+\n?)?//g; + if ($next =~ /^\\(\W|\d|[a-zA-z]*\b)/) { + $revert = $next = "\\".$1; + } elsif ($next =~ /\W/) { + $revert = &revert_to_raw_tex($next); + } else { $revert = $next }; + $next; +} + +1; |