From 3aed69f900ce6a1011d17c3886e1d65c66822612 Mon Sep 17 00:00:00 2001 From: Karl Berry Date: Thu, 16 Aug 2007 00:36:59 +0000 Subject: glossaries 1.04 (15aug07) git-svn-id: svn://tug.org/texlive/trunk@4740 c570f23f-e606-0410-a88d-b1316a301751 --- Master/texmf-dist/doc/latex/glossaries/CHANGES | 6 + Master/texmf-dist/doc/latex/glossaries/README | 84 +- Master/texmf-dist/doc/latex/glossaries/doc/CHANGES | 11 - Master/texmf-dist/doc/latex/glossaries/doc/README | 42 - .../doc/latex/glossaries/doc/glossaries.pdf | Bin 453752 -> 472066 bytes .../texmf-dist/doc/latex/glossaries/doc/sample.tex | 5 + .../doc/latex/glossaries/doc/sampleAcr.tex | 2 + .../latex/glossaries/latex2html/glossaries.perl | 1689 ------------------- .../glossaries/latex2html/styles/glossaries.perl | 1693 ++++++++++++++++++++ 9 files changed, 1748 insertions(+), 1784 deletions(-) delete mode 100644 Master/texmf-dist/doc/latex/glossaries/doc/CHANGES delete mode 100644 Master/texmf-dist/doc/latex/glossaries/doc/README delete mode 100644 Master/texmf-dist/doc/latex/glossaries/latex2html/glossaries.perl create mode 100644 Master/texmf-dist/doc/latex/glossaries/latex2html/styles/glossaries.perl (limited to 'Master/texmf-dist/doc/latex/glossaries') diff --git a/Master/texmf-dist/doc/latex/glossaries/CHANGES b/Master/texmf-dist/doc/latex/glossaries/CHANGES index 427b1ce1b03..485ca845623 100644 --- a/Master/texmf-dist/doc/latex/glossaries/CHANGES +++ b/Master/texmf-dist/doc/latex/glossaries/CHANGES @@ -1,5 +1,11 @@ glossaries change log: +v1.04 (3 Aug 2007): + * Added \glstextformat + +v1.03 (4 July 2007): + * Added \glspostdescription + v1.02 (25 May 2007): * Added overview section in the documentation diff --git a/Master/texmf-dist/doc/latex/glossaries/README b/Master/texmf-dist/doc/latex/glossaries/README index c80f663bf1a..843f528baca 100644 --- a/Master/texmf-dist/doc/latex/glossaries/README +++ b/Master/texmf-dist/doc/latex/glossaries/README @@ -1,42 +1,42 @@ -LaTeX Package : glossaries v 1.02 - -Last Modified : 25 May 2007 - -Author : Nicola Talbot - -This package is provided to assist generating glossaries. -The package supports acronyms and multiple glossaries. -New entries are defined to have a name and description (and -optionally an associated symbol.) Plural forms can also be -specified. New glossary styles can be defined, and preambles -and postambles can be specified. There is provision for loading -a database of terms, only terms used in the text will be added -to the relevant glossary. - -*This package replaces the glossary package which is now obsolete.* - -The package is supplied using the TeX Directory Structure (TDS). -Files in texmf directory should go in the corresponding -$LOCALTEXMF directories. The scripts directory contains the Perl -script makeglossaries and the batch file makeglossaries.bat -which should go somewhere on your operating system's PATH. (Both -files are required for Windows, only the Perl script is -required for other operating systems.) - -*Remember to refresh TeX's database* - -This package comes with a LaTeX2HTML style file glossaries.perl. -This is located in latex2html/styles and should be placed in -the relevant LaTeX2HTML styles directory, but note that -glossaries.perl only supplies a sub-set of the commands provided -by glossary.sty, so some commands may not be implemented, or -may be implemented in a different way. - -The package and documentation source code is also supplied as a -dtx and ins file located in texmf/source. - -This material is subject to the LaTeX Project Public License. -See http://www.ctan.org/tex-archive/help/Catalogue/licenses.lppl.html for the details of that license. - -http://theoval.cmp.uea.ac.uk/~nlct/ - +LaTeX Package : glossaries v 1.04 + +Last Modified : 3 August 2007 + +Author : Nicola Talbot + +This package is provided to assist generating glossaries. +The package supports acronyms and multiple glossaries. +New entries are defined to have a name and description (and +optionally an associated symbol.) Plural forms can also be +specified. New glossary styles can be defined, and preambles +and postambles can be specified. There is provision for loading +a database of terms, only terms used in the text will be added +to the relevant glossary. + +*This package replaces the glossary package which is now obsolete.* + +The package is supplied using the TeX Directory Structure (TDS). +Files in texmf directory should go in the corresponding +$LOCALTEXMF directories. The scripts directory contains the Perl +script makeglossaries and the batch file makeglossaries.bat +which should go somewhere on your operating system's PATH. (Both +files are required for Windows, only the Perl script is +required for other operating systems.) + +*Remember to refresh TeX's database* + +This package comes with a LaTeX2HTML style file glossaries.perl. +This is located in latex2html/styles and should be placed in +the relevant LaTeX2HTML styles directory, but note that +glossaries.perl only supplies a sub-set of the commands provided +by glossary.sty, so some commands may not be implemented, or +may be implemented in a different way. + +The package and documentation source code is also supplied as a +dtx and ins file located in texmf/source. + +This material is subject to the LaTeX Project Public License. +See http://www.ctan.org/tex-archive/help/Catalogue/licenses.lppl.html for the details of that license. + +http://theoval.cmp.uea.ac.uk/~nlct/ + diff --git a/Master/texmf-dist/doc/latex/glossaries/doc/CHANGES b/Master/texmf-dist/doc/latex/glossaries/doc/CHANGES deleted file mode 100644 index 427b1ce1b03..00000000000 --- a/Master/texmf-dist/doc/latex/glossaries/doc/CHANGES +++ /dev/null @@ -1,11 +0,0 @@ -glossaries change log: - -v1.02 (25 May 2007): - * Added overview section in the documentation - -v1.01 (17 May 2007): - * Added number range facility (equivalent to makeindex's |( and |) - formatting commands.) - * Added a space after \delimN and \delimR in the ist file. - -v1.0 (16 May 2007): Initial release diff --git a/Master/texmf-dist/doc/latex/glossaries/doc/README b/Master/texmf-dist/doc/latex/glossaries/doc/README deleted file mode 100644 index c80f663bf1a..00000000000 --- a/Master/texmf-dist/doc/latex/glossaries/doc/README +++ /dev/null @@ -1,42 +0,0 @@ -LaTeX Package : glossaries v 1.02 - -Last Modified : 25 May 2007 - -Author : Nicola Talbot - -This package is provided to assist generating glossaries. -The package supports acronyms and multiple glossaries. -New entries are defined to have a name and description (and -optionally an associated symbol.) Plural forms can also be -specified. New glossary styles can be defined, and preambles -and postambles can be specified. There is provision for loading -a database of terms, only terms used in the text will be added -to the relevant glossary. - -*This package replaces the glossary package which is now obsolete.* - -The package is supplied using the TeX Directory Structure (TDS). -Files in texmf directory should go in the corresponding -$LOCALTEXMF directories. The scripts directory contains the Perl -script makeglossaries and the batch file makeglossaries.bat -which should go somewhere on your operating system's PATH. (Both -files are required for Windows, only the Perl script is -required for other operating systems.) - -*Remember to refresh TeX's database* - -This package comes with a LaTeX2HTML style file glossaries.perl. -This is located in latex2html/styles and should be placed in -the relevant LaTeX2HTML styles directory, but note that -glossaries.perl only supplies a sub-set of the commands provided -by glossary.sty, so some commands may not be implemented, or -may be implemented in a different way. - -The package and documentation source code is also supplied as a -dtx and ins file located in texmf/source. - -This material is subject to the LaTeX Project Public License. -See http://www.ctan.org/tex-archive/help/Catalogue/licenses.lppl.html for the details of that license. - -http://theoval.cmp.uea.ac.uk/~nlct/ - diff --git a/Master/texmf-dist/doc/latex/glossaries/doc/glossaries.pdf b/Master/texmf-dist/doc/latex/glossaries/doc/glossaries.pdf index b5d381ed5d7..0404aa4144f 100644 Binary files a/Master/texmf-dist/doc/latex/glossaries/doc/glossaries.pdf and b/Master/texmf-dist/doc/latex/glossaries/doc/glossaries.pdf differ diff --git a/Master/texmf-dist/doc/latex/glossaries/doc/sample.tex b/Master/texmf-dist/doc/latex/glossaries/doc/sample.tex index 516cb248421..3110d9b8d17 100644 --- a/Master/texmf-dist/doc/latex/glossaries/doc/sample.tex +++ b/Master/texmf-dist/doc/latex/glossaries/doc/sample.tex @@ -25,6 +25,11 @@ description={rectangular array of quantities}, % plural is not simply obtained by appending an s, so specify plural=matrices} +\newcommand{\pardescription}{distinct section of piece of +writing\par beginning on new usually indented line} +\newglossaryentry{par}{name=paragraph, +description=\pardescription} + \begin{document} \title{Sample Document Using glossary Package} diff --git a/Master/texmf-dist/doc/latex/glossaries/doc/sampleAcr.tex b/Master/texmf-dist/doc/latex/glossaries/doc/sampleAcr.tex index 02531ff49a0..2b26e982be0 100644 --- a/Master/texmf-dist/doc/latex/glossaries/doc/sampleAcr.tex +++ b/Master/texmf-dist/doc/latex/glossaries/doc/sampleAcr.tex @@ -5,6 +5,8 @@ \makeglossaries +\renewcommand*{\glstextformat}[1]{\textsf{#1}} + \newacronym{svm}% label {svm}% abbreviation {support vector machine}% long form diff --git a/Master/texmf-dist/doc/latex/glossaries/latex2html/glossaries.perl b/Master/texmf-dist/doc/latex/glossaries/latex2html/glossaries.perl deleted file mode 100644 index 67f04090aa1..00000000000 --- a/Master/texmf-dist/doc/latex/glossaries/latex2html/glossaries.perl +++ /dev/null @@ -1,1689 +0,0 @@ -# File : glossaries.perl -# Author : Nicola Talbot -# Date : 16 May 2007 -# Version : 1.0 -# Description : LaTeX2HTML (limited!) implementation of glossaries -# package. Note that not all the glossaries.sty -# macros have been implemented. - -package main; - -# These are the only package options implemented. - -sub do_glossaries_style_altlist{ -} - -sub do_glossaries_toc{ -} - -sub do_glossaries_toc_true{ -} - -$GLSCURRENTFORMAT="textrm"; - -sub do_cmd_glossaryname{ - "Glossary$_[0]" -} - -$gls_mark{'main'} = ""; -$gls_file_mark{'main'} = ""; -$gls_title{'main'} = "\\glossaryname"; -$delimN{'main'} = ", "; -$glsnumformat{'main'} = $GLSCURRENTFORMAT; -@{$gls_entries{'main'}} = (); -$gls_displayfirst{'main'} = "glsdisplayfirst"; -$gls_display{'main'} = "glsdisplay"; - -%glsentry = (); - -$acronymtype = 'main'; - -sub do_glossaries_acronym{ - &do_glossaries_acronym_true -} - -sub do_glossaries_acronym_true{ - &make_newglossarytype("acronym", "\\acronymname"); - $acronymtype = 'acronym'; -} - -sub do_glossary_acronym_false{ - $acronymtype = 'main'; -} - -sub do_cmd_acronymname{ - join('', 'Acronyms', $_[0]); -} - -sub do_cmd_acronymtype{ - join('', $acronymtype, $_[0]); -} - -# modify set_depth_levels so that glossary is added - -sub replace_glossary_markers{ - foreach $type (keys %gls_mark) - { - if (defined &add_gls_hook) - {&add_gls_hook if (/$gls_mark{$type}/);} - else - {&add_gls($type) if (/$gls_mark{$type}/);} - - s/$gls_file_mark{$type}/$glsfile{$type}/g; - } -} - -# there must be a better way of doing this -# other than copying the orginal 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/); } - if (defined &add_idx_hook) {&add_idx_hook if (/$idx_mark/);} - else {&add_idx if (/$idx_mark/);} - &replace_glossary_markers; - - if ($segment_figure_captions) { -s/$lof_mark/$segment_figure_captions/o - } else { s/$lof_mark/$figure_captions/o } - if ($segment_table_captions) { -s/$lot_mark/$segment_table_captions/o - } else { s/$lot_mark/$table_captions/o } - &replace_morelinks(); - if (defined &replace_citations_hook) {&replace_citations_hook if /$bbl_mark/;} - else {&replace_bbl_marks if /$bbl_mark/;} - if (defined &add_toc_hook) {&add_toc_hook if (/$toc_mark/);} - else {&add_toc if (/$toc_mark/);} - if (defined &add_childs_hook) {&add_childs_hook if (/$childlinks_on_mark/);} - else {&add_childlinks if (/$childlinks_on_mark/);} - &remove_child_marks; - - if (defined &replace_cross_references_hook) {&replace_cross_references_hook;} - else {&replace_cross_ref_marks if /$cross_ref_mark||$cross_ref_visible_mark/;} - if (defined &replace_external_references_hook) {&replace_external_references_hook;} - else {&replace_external_ref_marks if /$external_ref_mark/;} - if (defined &replace_cite_references_hook) {&replace_cite_references_hook;} - else { &replace_cite_marks if /$cite_mark/; } - if (defined &replace_user_references) { - &replace_user_references if /$user_ref_mark/; } - -} - -sub add_gls{ - local($sidx_style, $eidx_style) =('',''); - if ($INDEX_STYLES) { -if ($INDEX_STYLES =~/,/) { -local(@styles) = split(/\s*,\s*/,$INDEX_STYLES); - $sidx_style = join('','<', join('><',@styles) ,'>'); - $eidx_style = join('',''); -} else { - $sidx_style = join('','<', $INDEX_STYLES,'>'); - $eidx_style = join('',''); -} - } - &add_real_gls -} - -sub gloskeysort{ - local($x, $y) = ($a, $b); - $x=~s/^(.*)###(\d+)$/\l\1/; - local($x_id) = $2; - $y=~s/^(.*)###(\d+)$/\l\1/; - local($y_id) = $2; - - local($n) = ($x cmp $y); - - if ($n == 0) - { - $n = ($x_id <=> $y_id); - } - - $n; -} - -sub add_real_gls{ - local($type) = @_; - print "\nDoing glossary '$type' ..."; - local($key, $str, @keys, $glossary, $level, $count, - @previous, @current, $id, $linktext, $delimN); - - @keys = keys %{$glossary{$type}}; - - @keys = sort gloskeysort @keys; - - $level = 0; - - $delimN = $delimN{$type}; - - 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); - - local($entry) = $glossary_entry{$type}{$key}; - - $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 - . "\n" - : "
" - . $name - . "
" - . $glsentry{$entry}{'description'} - . $symbol . '. ' - . $glossary{$type}{$key} - . $linktext. "\n"); - $previous = $current; - } - $glossary = '
'.$glossary unless ($glossary =~ /^\s*/); - - $glossary =~ s/(]*>)()/$2$1/g; - - $str = &translate_commands("\\glossarypostamble"); - s/$gls_mark{$type}/$preglossary\n
\n$glossary<\/DL>$str\n/s; -} - -sub set_depth_levels { - # Sets $outermost_level - local($level); - # scan the document body, not the preamble, for use of sectioning commands - my ($contents) = $_; - if ($contents =~ /\\begin\s*((?:$O|$OP)\d+(?:$C|$CP))document\1|\\startdocument/s) { -$contents = $'; - } - foreach $level ("part", "chapter", "section", "subsection", - "subsubsection", "paragraph") { -last if (($outermost_level) = $contents =~ /\\($level)$delimiter_rx/); -last if (($outermost_level) = $contents =~ /\\endsegment\s*\[\s*($level)\s*\]/s); -if ($contents =~ /\\segment\s*($O\d+$C)[^<]+\1\s*($O\d+$C)\s*($level)\s*\2/s) -{ $outermost_level = $3; last }; - } - $level = ($outermost_level ? $section_commands{$outermost_level} : - do {$outermost_level = 'section'; 3;}); - - if ($REL_DEPTH && $MAX_SPLIT_DEPTH) { -$MAX_SPLIT_DEPTH = $level + $MAX_SPLIT_DEPTH; - } elsif (!($MAX_SPLIT_DEPTH)) { $MAX_SPLIT_DEPTH = 1 }; - - %unnumbered_section_commands = ( - 'tableofcontents', $level -, 'listoffigures', $level -, 'listoftables', $level -, 'bibliography', $level -, 'textohtmlindex', $level -, 'textohtmlglossary', $level -, 'textohtmlglossaries', $level - , %unnumbered_section_commands - ); - - %section_commands = ( - %unnumbered_section_commands - , %section_commands - ); -} - -sub add_bbl_and_idx_dummy_commands { - local($id) = $global{'max_id'}; - - s/([\\]begin\s*$O\d+$C\s*thebibliography)/$bbl_cnt++; $1/eg; - ## if ($bbl_cnt == 1) { -s/([\\]begin\s*$O\d+$C\s*thebibliography)/$id++; "\\bibliography$O$id$C$O$id$C $1"/geo; - #} - $global{'max_id'} = $id; - s/([\\]begin\s*$O\d+$C\s*theindex)/\\textohtmlindex $1/o; - s/[\\]printindex/\\textohtmlindex /o; - &add_gls_dummy_commands; - &lib_add_bbl_and_idx_dummy_commands() if defined(&lib_add_bbl_and_idx_dummy_commands); -} - -sub add_gls_dummy_commands{ - s/[\\]printglossary/\\textohtmlglossary/sg; - s/[\\]printglossaries/\\textohtmlglossaries/sg; -} - -sub get_firstkeyval{ - local($key,$_) = @_; - local($value); - - s/\b$key\s*=$OP(\d+)$CP(.*)$OP\1$CP\s*(,|$)/$value=$2;','/es; - undef($value) if $`=~/\b$key\s*=/; - - unless (defined($value)) - { - s/(^|,)\s*$key\s*=\s*([^,]*)\s*(,|$)/,/s; - $value=$2; - } - - ($value,$_); -} - -# need to get the value of the last key of a given name -# in the event of multiple occurences. -sub get_keyval{ - local($key,$_) = @_; - local($value); - - while (/\b$key\s*=/) - { - ($value,$_) = &get_firstkeyval($key, $_); - } - - ($value,$_); -} - -# This is modified from do_cmd_textohtmlindex - -sub do_cmd_textohtmlglossary{ - local($_) = @_; - - local($keyval,$pat) = &get_next_optional_argument; - - local($type,$title,$toctitle,$style); - - ($type,$keyval) = &get_keyval('type', $keyval); - ($title,$keyval) = &get_keyval('title', $keyval); - ($toctitle,$keyval) = &get_keyval('toctitle', $keyval); - ($style,$keyval) = &get_keyval('style', $keyval); - - &make_textohtmlglossary($type,$toctitle,$title,$style).$_; -} - -sub make_textohtmlglossary{ - local($type,$toctitle,$title,$style) = @_; - - unless (defined($type)) {$type = 'main';} - - unless (defined $gls_mark{$type}) - { - &write_warnings("glossary type '$type' not implemented"); - } - - unless (defined($title) and $title) {$title = $gls_title{$type};} - unless (defined($toctitle) and $toctitle) {$toctitle = $title;} - - $toc_sec_title = $toctitle; - $glsfile{$type} = $CURRENT_FILE; - - $TITLE=&translate_commands($toctitle); - - if (%glossary_labels) { &make_glossary_labels(); } - - if (($SHORT_INDEX) && (%glossary_segment)) - { - &make_preglossary(); - } - else - { - $preglossary = &translate_commands("\\glossarypreamble"); - } - - local $idx_head = $section_headings{'textohtmlindex'}; - local($heading) = join('' - , &make_section_heading($title, $idx_head) - , $gls_mark{$type} ); - local($pre,$post) = &minimize_open_tags($heading); - join('',"
\n" , $pre); -} - -sub do_cmd_textohtmlglossaries{ - local($_) = @_; - - foreach $type (keys %gls_mark) - { - $id = ++$global{'max_id'}; - $_ = &make_textohtmlglossary($type,$gls_title{'main'}).$_; - } - - $_; -} - -sub make_glossary_labels { - local($key, @keys); - @keys = keys %glossary_labels; - foreach $key (@keys) { - if (($ref_files{$key}) && !($ref_files{$key} eq "$glsfile{'main'}")) { - local($tmp) = $ref_files{$key}; - &write_warnings("\nmultiple label $key , target in $glsfile{'main'} masks $tmp "); - } - $ref_files{$key} .= $glsfile{'main'}; - } -} - -sub make_preglossary{ &make_real_preglossary } -sub make_real_preglossary{ - local($key, @keys, $head, $body); - $head = "
\n

Legend:

\n
"; - @keys = keys %glossary_segment; - foreach $key (@keys) { - local($tmp) = "segment$key"; - $tmp = $ref_files{$tmp}; - $body .= "\n
$key
".&make_named_href('',$tmp,$glossary_segment{$key}); - } - $preglossary = join('', $head, $body, "\n
") if ($body); -} - -sub do_cmd_glossary { &do_real_glossary(@_) } -sub do_real_glossary { - local($_) = @_; - local($type) = "main"; - local($anchor,$entry); - - local($type,$pat) = &get_next_optional_argument; - - $entry = &missing_braces unless - (s/$next_pair_pr_rx//o&&($entry=$2)); - - $anchor = &make_glossary_entry($entry,$anchor_invisible_mark,$type); - - join('', $anchor, $_); -} - -sub make_glossary_entry { &make_real_glossary_entry(@_) } -sub make_real_glossary_entry { - local($entry,$text,$type) = @_; - local($this_file) = $CURRENT_FILE; - $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($br_id) = ++$global{'max_id'}; - $glossary{$type}{$str} .= &make_half_href($this_file."#$br_id"); - $glossary_format{$type}{$str} = $GLSCURRENTFORMAT; - $glossary_entry{$type}{$str} = $entry; - $glossary_linktext{$type}{$str} = $TITLE; - "
$text<\/A>"; -} - -sub do_cmd_newglossary{ - local($_) = @_; - local($type,$out,$in,$opt,$pat,$title); - - ($opt,$pat) = &get_next_optional_argument; - - $type = &missing_braces unless - (s/$next_pair_pr_rx//o&&($type=$2)); - $in = &missing_braces unless - (s/$next_pair_pr_rx//o&&($in=$2)); - $out = &missing_braces unless - (s/$next_pair_pr_rx//o&&($out=$2)); - $title = &missing_braces unless - (s/$next_pair_pr_rx//o&&($title=$2)); - - ($opt,$pat) = &get_next_optional_argument; - - &make_newglossarytype($type, $title); - - $_; -} - -sub make_newglossarytype{ - local($type, $title) = @_; - - $gls_mark{$type} = ""; - $gls_file_mark{$type} = ""; - $gls_title{$type} = $title; - $delimN{$type} = ", "; - $glsnumformat{$type} = $GLSCURRENTFORMAT; - @{$gls_entries{$type}} = (); - $gls_displayfirst{$type} = "glsdisplayfirst"; - $gls_display{$type} = "glsdisplay"; -} - -sub do_cmd_glsdisplay{ - local($_) = @_; - local($text,$description,$symbol,$insert); - - $text = &missing_braces unless - (s/$next_pair_pr_rx/$text=$2;''/eo); - - $description = &missing_braces unless - (s/$next_pair_pr_rx/$description=$2;''/eo); - - $symbol = &missing_braces unless - (s/$next_pair_pr_rx/$symbol=$2;''/eo); - - $insert = &missing_braces unless - (s/$next_pair_pr_rx/$insert=$2;''/eo); - - "$text$insert" . $_; -} - -sub do_cmd_glsdisplayfirst{ - local($_) = @_; - local($text,$description,$symbol,$insert); - - $text = &missing_braces unless - (s/$next_pair_pr_rx/$text=$2;''/eo); - - $description = &missing_braces unless - (s/$next_pair_pr_rx/$description=$2;''/eo); - - $symbol = &missing_braces unless - (s/$next_pair_pr_rx/$symbol=$2;''/eo); - - $insert = &missing_braces unless - (s/$next_pair_pr_rx/$insert=$2;''/eo); - - "$text$insert" . $_; -} - -sub gls_get_displayfirst{ - local($type) = @_; - local($display)= $gls_displayfirst{$type}; - - if (not defined($display)) - { - &write_warnings("Glossary '$type' is not defined"); - $display=''; - } - elsif ($display eq '') - { - &write_warnings("glsdisplayfirst not set for glossary '$type'"); - } - else - { - $display = "\\$display "; - } - - $display; -} - -sub gls_get_display{ - local($type) = @_; - local($display)= $gls_display{$type}; - - if (not defined($display)) - { - &write_warnings("Glossary '$type' is not defined"); - $display = ''; - } - elsif ($display eq '') - { - &write_warnings("glsdisplay not set for glossary '$type'"); - } - else - { - $display = "\\$display "; - } - - $display; -} - -sub do_cmd_glsnamefont{ - local($_) = @_; - local($text); - - $text = &missing_braces unless - (s/$next_pair_pr_rx/$text=$2;''/eo); - - "$text$_"; -} - -sub do_cmd_newacronym{ - local($_) = @_; - local($label,$abbrev,$long,$opt); - - ($opt,$pat) = &get_next_optional_argument; - - $label = &missing_braces unless - (s/$next_pair_pr_rx/$label=$2;''/eo); - $abbrv = &missing_braces unless - (s/$next_pair_pr_rx/$abbrv=$2;''/eo); - $long = &missing_braces unless - (s/$next_pair_pr_rx/$long=$2;''/eo); - - local($cmd) = "\\newglossaryentry"; - local($id); - $id = ++$global{'max_id'}; - $cmd .= "$OP$id$CP$label$OP$id$CP"; - $id = ++$global{'max_id'}; - local($entry) = "type=$OP$id$CP\\acronymtype$OP$id$CP,"; - $id = ++$global{'max_id'}; - $entry .= "name=$OP$id$CP$abbrv$OP$id$CP,"; - $id = ++$global{'max_id'}; - $entry .= "description=$OP$id$CP$long$OP$id$CP,"; - $id = ++$global{'max_id'}; - $entry .= "text=$OP$id$CP$abbrv$OP$id$CP,"; - $id = ++$global{'max_id'}; - $entry .= "first=$OP$id$CP$long ($abbrv)$OP$id$CP,"; - $id = ++$global{'max_id'}; - $entry .= "plural=$OP$id$CP${abbrv}s$OP$id$CP,"; - $id = ++$global{'max_id'}; - $entry .= "firstplural=$OP$id$CP${long}s (${abbrv}s)$OP$id$CP"; - - $id = ++$global{'max_id'}; - $cmd .= "$OP$id$CP$entry,$opt$OP$id$CP"; - - &translate_commands($cmd).$_; -} - -sub gls_entry_init{ - local($label, $type, $name, $desc) = @_; - - %{$glsentry{$label}} = - ( type => $type, - name => $name, - 'sort' => $name, - description => $description, - text => $name, - first => $name, - plural => "${name}s", - firstplural => "${name}s", - symbol => '', - flag => 0 - ); -} - -sub gls_get_type{ - local($label) = @_; - local($type) = ''; - - if (&gls_entry_defined($label)) - { - $type = $glsentry{$label}{'type'}; - } - else - { - &write_warnings("gls_get_type: glossary entry '$label' has not been defined"); - } - - $type; -} - -sub gls_set_type{ - local($label, $type) = @_; - - if (&gls_entry_defined($label)) - { - $glsentry{$label}{'type'} = $type; - } - else - { - &write_warnings("gls_set_type: glossary entry '$label' has not been defined"); - } -} - -sub gls_get_name{ - local($label) = @_; - local($name) = ''; - - if (&gls_entry_defined($label)) - { - $name = $glsentry{$label}{'name'}; - } - else - { - &write_warnings("gls_get_name: glossary entry '$label' has not been defined"); - } - - $name; -} - -sub gls_set_name{ - local($label, $name) = @_; - - if (&gls_entry_defined($label)) - { - $glsentry{$label}{'name'} = $name; - } - else - { - &write_warnings("gls_set_name: glossary entry '$label' has not been defined"); - } -} - -sub gls_get_description{ - local($label) = @_; - local($description) = ''; - - if (&gls_entry_defined($label)) - { - $description = $glsentry{$label}{'description'}; - } - else - { - &write_warnings("gls_get_description: glossary entry '$label' has not been defined"); - } - - $description; -} - -sub gls_set_description{ - local($label, $description) = @_; - - if (&gls_entry_defined($label)) - { - $glsentry{$label}{'description'} = $description; - } - else - { - &write_warnings("gls_set_description: glossary entry '$label' has not been defined"); - } -} - -sub gls_get_symbol{ - local($label) = @_; - local($symbol) = ''; - - if (&gls_entry_defined($label)) - { - $symbol = $glsentry{$label}{'symbol'}; - } - else - { - &write_warnings("gls_get_symbol: glossary entry '$label' has not been defined"); - } - - $symbol; -} - -sub gls_set_symbol{ - local($label, $symbol) = @_; - - if (&gls_entry_defined($label)) - { - $glsentry{$label}{'symbol'} = $symbol; - } - else - { - &write_warnings("gls_set_symbol: glossary entry '$label' has not been defined"); - } -} - -sub gls_get_sort{ - local($label) = @_; - local($sort) = ''; - - if (&gls_entry_defined($label)) - { - $sort = $glsentry{$label}{'sort'}; - } - else - { - &write_warnings("gls_get_sort: glossary entry '$label' has not been defined"); - } - - $sort; -} - -sub gls_set_sort{ - local($label, $sort) = @_; - - if (&gls_entry_defined($label)) - { - $glsentry{$label}{'sort'} = $sort; - } - else - { - &write_warnings("gls_set_sort: glossary entry '$label' has not been defined"); - } -} - -sub gls_get_text{ - local($label) = @_; - local($text) = ''; - - if (&gls_entry_defined($label)) - { - $text = $glsentry{$label}{'text'}; - } - else - { - &write_warnings("gls_get_text: glossary entry '$label' has not been defined"); - } - - $text; -} - -sub gls_set_text{ - local($label, $text) = @_; - - if (&gls_entry_defined($label)) - { - $glsentry{$label}{'text'} = $text; - } - else - { - &write_warnings("gls_set_text: glossary entry '$label' has not been defined"); - } -} - -sub gls_get_plural{ - local($label) = @_; - local($plural) = ''; - - if (&gls_entry_defined($label)) - { - $plural = $glsentry{$label}{'plural'}; - } - else - { - &write_warnings("gls_get_plural: glossary entry '$label' has not been defined"); - } - - $plural; -} - -sub gls_set_plural{ - local($label, $plural) = @_; - - if (&gls_entry_defined($label)) - { - $glsentry{$label}{'plural'} = $plural; - } - else - { - &write_warnings("gls_set_plural: glossary entry '$label' has not been defined"); - } -} - -sub gls_get_firstplural{ - local($label) = @_; - local($firstplural) = ''; - - if (&gls_entry_defined($label)) - { - $firstplural = $glsentry{$label}{'firstplural'}; - } - else - { - &write_warnings("gls_get_firstplural: glossary entry '$label' has not been defined"); - } - - $firstplural; -} - -sub gls_set_firstplural{ - local($label, $firstplural) = @_; - - if (&gls_entry_defined($label)) - { - $glsentry{$label}{'firstplural'} = $firstplural; - } - else - { - &write_warnings("gls_set_firstplural: glossary entry '$label' has not been defined"); - } -} - -sub gls_get_first{ - local($label) = @_; - local($first) = ''; - - if (&gls_entry_defined($label)) - { - $first = $glsentry{$label}{'first'}; - } - else - { - &write_warnings("gls_get_first: glossary entry '$label' has not been defined"); - } - - $first; -} - -sub gls_set_first{ - local($label, $first) = @_; - - if (&gls_entry_defined($label)) - { - $glsentry{$label}{'first'} = $first; - } - else - { - &write_warnings("gls_set_first: glossary entry '$label' has not been defined"); - } -} - -sub gls_used{ - local($label) = @_; - local($flag) = 0; - - if (&gls_entry_defined($label)) - { - $flag = $glsentry{$label}{'flag'}; - } - else - { - &write_warnings("gls_used: glossary entry '$label' has not been defined"); - } - - $flag; -} - -sub gls_entry_defined{ - local($label) = @_; - - defined(%{$glsentry{$label}}); -} - -sub do_cmd_newglossaryentry{ - local($_) = @_; - local($label,$name,$description,$symbol,$sort,$text,$first, - $plural,$firstplural,$type,$keyval); - - $label = &missing_braces unless - s/$next_pair_pr_rx/$label=$2;''/eo; - - $keyval = &missing_braces unless - s/$next_pair_pr_rx/$keyval=$2;''/eo; - - ($name,$keyval) = &get_keyval('name', $keyval); - ($description,$keyval) = &get_keyval('description', $keyval); - ($symbol,$keyval) = &get_keyval('symbol', $keyval); - ($sort,$keyval) = &get_keyval('sort', $keyval); - ($text,$keyval) = &get_keyval('text', $keyval); - ($first,$keyval) = &get_keyval('first', $keyval); - ($firstplural,$keyval) = &get_keyval('firstplural', $keyval); - ($plural,$keyval) = &get_keyval('plural', $keyval); - ($type,$keyval) = &get_keyval('type', $keyval); - - if (defined($type)) - { - $type = &translate_commands($type); - } - else - { - $type = 'main'; - } - - &gls_entry_init($label, $type, $name, $description); - - &gls_set_symbol($label, defined($symbol)?$symbol:''); - - $sort = "$name $description" unless (defined($sort) and $sort); - - &gls_set_sort($label, $sort); - - $text = $name unless (defined($text) and $text); - - &gls_set_text($label, $text); - - $first = $text unless (defined($first) and $first); - - &gls_set_first($label, $first); - - $plural = "${text}s" unless (defined($plural) and $plural); - - &gls_set_plural($label, $plural); - - $firstplural = "${first}s" unless (defined($firstplural) and $firstplural); - - &gls_set_firstplural($label, $firstplural); - - push @{$gls_entries{$type}}, $label; - - $_; -} - -sub reset_entry{ - local($label) = @_; - - $glsentry{$label}{'flag'} = 0; -} - -sub unset_entry{ - local($label) = @_; - - $glsentry{$label}{'flag'} = 1; -} - -sub do_cmd_glsreset{ - local($_) = @_; - local($label); - - $label = &missing_braces unless - s/$next_pair_pr_rx/$label=$2;''/eo; - - &reset_entry($label); - - $_; -} - -sub do_cmd_glsunset{ - local($_) = @_; - local($label); - - $label = &missing_braces unless - s/$next_pair_pr_rx/$label=$2;''/eo; - - &unset_entry($label); - - $_; -} - -sub do_cmd_ifglsused{ - local($_) = @_; - local($label,$true,$false); - - $label = &missing_braces unless - s/$next_pair_pr_rx/$label=$2;''/eo; - - $true = &missing_braces unless - s/$next_pair_pr_rx/$true=$2;''/eo; - - $false = &missing_braces unless - s/$next_pair_pr_rx/$false=$2;''/eo; - - (&gls_used($label) ? $true : $false) . $_; -} - -sub do_cmd_ifglsentryexists{ - local($_) = @_; - local($label,$true,$false); - - $label = &missing_braces unless - s/$next_pair_pr_rx/$label=$2;''/eo; - - $true = &missing_braces unless - s/$next_pair_pr_rx/$true=$2;''/eo; - - $false = &missing_braces unless - s/$next_pair_pr_rx/$false=$2;''/eo; - - (&gls_entry_defined($label) ? $true : $false) . $_; -} - -sub gls_add_entry{ - local($type, $label, $format, $text) = @_; - - local($oldfmt) = $GLSCURRENTFORMAT; - - if (defined($format) and $format) - { - $GLSCURRENTFORMAT=$format; - } - - $id = ++$global{'max_id'}; - - local($str) = &make_real_glossary_entry($label,$text,$type); - $GLSCURRENTFORMAT = $oldfmt; - - $str; -} - -sub do_cmd_glsadd{ - local($_) = @_; - local($optarg,$pat,$label,$str,$id,$type,$format); - ($optarg,$pat) = &get_next_optional_argument; - - $label = &missing_braces unless - (s/$next_pair_pr_rx/$label=$2;''/eo); - - $type = &gls_get_type($label); - - if (defined $type) - { - ($format,$optarg) = &get_keyval('format', $optarg); - $format='' unless(defined($format)); - - &gls_add_entry($type,$label,$format,""); - } - else - { - &write_warnings("gls_add: glossary entry '$label' undefined"); - $str = ''; - } - - $str . $_; -} - -sub do_cmd_glsaddall{ - local($_) = @_; - local($optarg,$pat) = &get_next_optional_argument; - - local($format,$types); - - ($type,$optarg) = &get_keyval('types', $optarg); - - ($format,$optarg) = &get_keyval('format', $optarg); - $format='' unless(defined($format)); - - local(@types) = keys(%gls_mark); - - if (defined($types)) - { - @types = split /,/, $types; - } - - foreach $type (@types) - { - # strip leasing and trailing spaces - $type=~s/^\s*([^\s]+)\s*$/\1/; - - foreach $label (@{$gls_entries{$type}}) - { - &gls_add_entry($type,$label,$format,""); - } - } - - $_; -} - -sub do_cmd_glsresetall{ - local($_) = @_; - local($types,$pat) = &get_next_optional_argument; - - local(@types) = keys(%gls_mark); - - if (defined($types) and $types) - { - @types = split /,/, $types; - } - - foreach $type (@types) - { - # strip leasing and trailing spaces - $type=~s/^\s*([^\s]+)\s*$/\1/; - - foreach $label (@{$gls_entries{$type}}) - { - &reset_entry($label); - } - } - - $_; -} - -sub do_cmd_glsunsetall{ - local($_) = @_; - local($types,$pat) = &get_next_optional_argument; - - local(@types) = keys(%gls_mark); - - if (defined($types) and $types) - { - @types = split /,/, $types; - } - - foreach $type (@types) - { - # strip leasing and trailing spaces - $type=~s/^\s*([^\s]+)\s*$/\1/; - - foreach $label (@{$gls_entries{$type}}) - { - &reset_entry($label); - } - } - - $_; -} - -sub make_glslink{ - local($type,$label,$format,$text) = @_; - local($str) = ''; - - if (defined $type) - { - $str = &gls_add_entry($type,$label,$format,$text); - } - else - { - &write_warnings("glossary '$type' undefined"); - } - - $str; -} - -sub do_cmd_glslink{ - 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 ($space) = ''; - if (/^\s+[^\[]/ or /^\s*\[.*\]\s/) {$space = ' ';} - ($optarg,$pat) = &get_next_optional_argument; - - $type = &gls_get_type($label); - - &make_glslink($type, $label, $format, $text).$space . $_; -} - -sub do_cmd_glsentrydesc{ - local($_) = @_; - - $label = &missing_braces unless - (s/$next_pair_pr_rx/$label=$2;''/eo); - - &gls_get_description($label).$_; -} - -sub do_cmd_Glsentrydesc{ - local($_) = @_; - - $label = &missing_braces unless - (s/$next_pair_pr_rx/$label=$2;''/eo); - - ucfirst(&gls_get_description($label)).$_; -} - -sub do_cmd_glsentrytext{ - local($_) = @_; - - $label = &missing_braces unless - (s/$next_pair_pr_rx/$label=$2;''/eo); - - &gls_get_text($label).$_; -} - -sub do_cmd_Glsentrytext{ - local($_) = @_; - - $label = &missing_braces unless - (s/$next_pair_pr_rx/$label=$2;''/eo); - - ucfirst(&gls_get_text($label)).$_; -} - -sub do_cmd_glsentryname{ - local($_) = @_; - - $label = &missing_braces unless - (s/$next_pair_pr_rx/$label=$2;''/eo); - - &gls_get_name($label).$_; -} - -sub do_cmd_Glsentryname{ - local($_) = @_; - - $label = &missing_braces unless - (s/$next_pair_pr_rx/$label=$2;''/eo); - - ucfirst(&gls_get_name($label)).$_; -} - -sub do_cmd_glsentryfirst{ - local($_) = @_; - - $label = &missing_braces unless - (s/$next_pair_pr_rx/$label=$2;''/eo); - - &gls_get_first($label).$_; -} - -sub do_cmd_Glsentryfirst{ - local($_) = @_; - - $label = &missing_braces unless - (s/$next_pair_pr_rx/$label=$2;''/eo); - - ucfirst(&gls_get_first($label)).$_; -} - -sub do_cmd_glsentryplural{ - local($_) = @_; - - $label = &missing_braces unless - (s/$next_pair_pr_rx/$label=$2;''/eo); - - &gls_get_plural($label).$_; -} - -sub do_cmd_Glsentryplural{ - local($_) = @_; - - $label = &missing_braces unless - (s/$next_pair_pr_rx/$label=$2;''/eo); - - ucfirst(&gls_get_plural($label)).$_; -} - -sub do_cmd_glsentryfirstplural{ - local($_) = @_; - - $label = &missing_braces unless - (s/$next_pair_pr_rx/$label=$2;''/eo); - - local($text)=$glsentry{$label}{'firstplural'}; - - unless (defined($text)) - { - &write_warnings("glossary entry '$label' has not been defined"); - $text = ''; - } - - "$text$_"; - &gls_get_firstplural($label).$_; -} - -sub do_cmd_Glsentryfirstplural{ - local($_) = @_; - - $label = &missing_braces unless - (s/$next_pair_pr_rx/$label=$2;''/eo); - - ucfirst(&gls_get_firstplural($label)).$_; -} - -sub do_cmd_glsentrysymbol{ - local($_) = @_; - - $label = &missing_braces unless - (s/$next_pair_pr_rx/$label=$2;''/eo); - - &gls_get_symbol($label).$_; -} - -sub do_cmd_Glsentrysymbol{ - local($_) = @_; - - $label = &missing_braces unless - (s/$next_pair_pr_rx/$label=$2;''/eo); - - ucfirst(&gls_get_symbol($label)).$_; -} - -sub do_cmd_gls{ - 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); - - if (&gls_used($label)) - { - # entry has already been used - - $text = &gls_get_text($label); - $display = &gls_get_display($type);; - } - else - { - # entry hasn't been used - - $text = &gls_get_first($label); - $display = &gls_get_displayfirst($type); - - &unset_entry($label); - } - - local($args) = ''; - - local($id) = ++$global{'max_id'}; - $args .= "$OP$id$CP$text$OP$id$CP"; - - $id = ++$global{'max_id'}; - $args .= "$OP$id$CP$glsentry{$label}{description}$OP$id$CP"; - - $id = ++$global{'max_id'}; - $args .= "$OP$id$CP$glsentry{$label}{symbol}$OP$id$CP"; - - $id = ++$global{'max_id'}; - $args .= "$OP$id$CP$insert$OP$id$CP"; - - local($link_text) = &translate_commands("$display$args"); - - &make_glslink($type, $label, $format, $link_text) .$space . $_; -} - -sub do_cmd_glspl{ - 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) = $glsentry{$label}{'type'}; - - if (&gls_used($label)) - { - # entry has already been used - - $text = &gls_get_plural($label); - $display = &gls_get_display($type);; - } - else - { - # entry hasn't been used - - $text = &gls_get_firstplural($label); - $display = &gls_get_displayfirst($type); - - &unset_entry($label); - } - - local($args) = ''; - - local($id) = ++$global{'max_id'}; - $args .= "$OP$id$CP$text$OP$id$CP"; - - $id = ++$global{'max_id'}; - $args .= "$OP$id$CP$glsentry{$label}{description}$OP$id$CP"; - - $id = ++$global{'max_id'}; - $args .= "$OP$id$CP$glsentry{$label}{symbol}$OP$id$CP"; - - $id = ++$global{'max_id'}; - $args .= "$OP$id$CP$insert$OP$id$CP"; - - local($link_text) = &translate_commands("$display$args"); - - &make_glslink($type, $label, $format, $link_text) . $space . $_; -} - -sub do_cmd_Gls{ - 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) = $glsentry{$label}{'type'}; - - if (&gls_used($label)) - { - # entry has already been used - - $text = &gls_get_text($label); - $display = &gls_get_display($type);; - } - else - { - # entry hasn't been used - - $text = &gls_get_first($label); - $display = &gls_get_displayfirst($type); - - &unset_entry($label); - } - - local($args) = ''; - - local($id) = ++$global{'max_id'}; - $args .= "$OP$id$CP$text$OP$id$CP"; - - $id = ++$global{'max_id'}; - $args .= "$OP$id$CP$glsentry{$label}{description}$OP$id$CP"; - - $id = ++$global{'max_id'}; - $args .= "$OP$id$CP$glsentry{$label}{symbol}$OP$id$CP"; - - $id = ++$global{'max_id'}; - $args .= "$OP$id$CP$insert$OP$id$CP"; - - local($link_text) = &translate_commands("$display$args"); - - &make_glslink($type, $label, $format, ucfirst($link_text)). $space . $_; -} - -sub do_cmd_Glspl{ - 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) = $glsentry{$label}{'type'}; - - if (&gls_used($label)) - { - # entry has already been used - - $text = &gls_get_plural($label); - $display = &gls_get_display($type);; - } - else - { - # entry hasn't been used - - $text = &gls_get_firstplural($label); - $display = &gls_get_displayfirst($type); - - &unset_entry($label); - } - - local($args) = ''; - - local($id) = ++$global{'max_id'}; - $args .= "$OP$id$CP$text$OP$id$CP"; - - $id = ++$global{'max_id'}; - $args .= "$OP$id$CP$glsentry{$label}{description}$OP$id$CP"; - - $id = ++$global{'max_id'}; - $args .= "$OP$id$CP$glsentry{$label}{symbol}$OP$id$CP"; - - $id = ++$global{'max_id'}; - $args .= "$OP$id$CP$insert$OP$id$CP"; - - local($link_text) = &translate_commands("$display$args"); - - &make_glslink($type, $label, $format, ucfirst($link_text)).$space . $_; -} - -sub do_cmd_GLS{ - 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) = $glsentry{$label}{'type'}; - - if (&gls_used($label)) - { - # entry has already been used - - $text = &gls_get_text($label); - $display = &gls_get_display($type);; - } - else - { - # entry hasn't been used - - $text = &gls_get_first($label); - $display = &gls_get_displayfirst($type); - - &unset_entry($label); - } - - local($args) = ''; - - local($id) = ++$global{'max_id'}; - $args .= "$OP$id$CP$text$OP$id$CP"; - - $id = ++$global{'max_id'}; - $args .= "$OP$id$CP$glsentry{$label}{description}$OP$id$CP"; - - $id = ++$global{'max_id'}; - $args .= "$OP$id$CP$glsentry{$label}{symbol}$OP$id$CP"; - - $id = ++$global{'max_id'}; - $args .= "$OP$id$CP$insert$OP$id$CP"; - - local($link_text) = &translate_commands("$display$args"); - - &make_glslink($type, $label, $format, uc($link_text)).$space . $_; -} - -sub do_cmd_GLSpl{ - 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) = $glsentry{$label}{'type'}; - - if (&gls_used($label)) - { - # entry has already been used - - $text = &gls_get_plural($label); - $display = &gls_get_display($type);; - } - else - { - # entry hasn't been used - - $text = &gls_get_firstplural($label); - $display = &gls_get_displayfirst($type); - - &unset_entry($label); - } - - local($args) = ''; - - local($id) = ++$global{'max_id'}; - $args .= "$OP$id$CP$text$OP$id$CP"; - - $id = ++$global{'max_id'}; - $args .= "$OP$id$CP$glsentry{$label}{description}$OP$id$CP"; - - $id = ++$global{'max_id'}; - $args .= "$OP$id$CP$glsentry{$label}{symbol}$OP$id$CP"; - - $id = ++$global{'max_id'}; - $args .= "$OP$id$CP$insert$OP$id$CP"; - - local($link_text) = &translate_commands("$display$args"); - - &make_glslink($type, $label, $format, uc($link_text)).$space . $_; -} - -sub do_cmd_glossarypreamble{ - local($_) = @_; - $_[0]; -} - -sub do_cmd_glossarypostamble{ - local($_) = @_; - $_[0]; -} - -sub do_cmd_glsnumformat{ - local($_) = @_; - - $_; -} - -sub do_cmd_hyperit{ - join('', "\\textit ", $_[0]); -} - -sub do_cmd_hyperrm{ - join('', "\\textrm ", $_[0]); -} - -sub do_cmd_hypertt{ - join('', "\\texttt ", $_[0]); -} - -sub do_cmd_hypersf{ - join('', "\\textsf ", $_[0]); -} - -sub do_cmd_hyperbf{ - join('', "\\textbf ", $_[0]); -} - -&ignore_commands( <<_IGNORED_CMDS_ ); -makeglossary -makeglossaries -_IGNORED_CMDS_ - -1; diff --git a/Master/texmf-dist/doc/latex/glossaries/latex2html/styles/glossaries.perl b/Master/texmf-dist/doc/latex/glossaries/latex2html/styles/glossaries.perl new file mode 100644 index 00000000000..d6f1b0fd6e8 --- /dev/null +++ b/Master/texmf-dist/doc/latex/glossaries/latex2html/styles/glossaries.perl @@ -0,0 +1,1693 @@ +# File : glossaries.perl +# Author : Nicola Talbot +# Date : 14th June 2007 +# Version : 1.01 +# Description : LaTeX2HTML (limited!) implementation of glossaries +# package. Note that not all the glossaries.sty +# macros have been implemented. + +package main; + +# These are the only package options implemented. + +sub do_glossaries_style_altlist{ +} + +sub do_glossaries_toc{ +} + +sub do_glossaries_toc_true{ +} + +$GLSCURRENTFORMAT="textrm"; + +sub do_cmd_glossaryname{ + "Glossary$_[0]" +} + +$gls_mark{'main'} = ""; +$gls_file_mark{'main'} = ""; +$gls_title{'main'} = "\\glossaryname"; +$delimN{'main'} = ", "; +$glsnumformat{'main'} = $GLSCURRENTFORMAT; +@{$gls_entries{'main'}} = (); +$gls_displayfirst{'main'} = "glsdisplayfirst"; +$gls_display{'main'} = "glsdisplay"; + +%glsentry = (); + +$acronymtype = 'main'; + +sub do_glossaries_acronym{ + &do_glossaries_acronym_true +} + +sub do_glossaries_acronym_true{ + &make_newglossarytype("acronym", "\\acronymname"); + $acronymtype = 'acronym'; +} + +sub do_glossary_acronym_false{ + $acronymtype = 'main'; +} + +sub do_cmd_acronymname{ + join('', 'Acronyms', $_[0]); +} + +sub do_cmd_acronymtype{ + join('', $acronymtype, $_[0]); +} + +# modify set_depth_levels so that glossary is added + +sub replace_glossary_markers{ + foreach $type (keys %gls_mark) + { + if (defined &add_gls_hook) + {&add_gls_hook if (/$gls_mark{$type}/);} + else + {&add_gls($type) if (/$gls_mark{$type}/);} + + s/$gls_file_mark{$type}/$glsfile{$type}/g; + } +} + +# there must be a better way of doing this +# other than copying the orginal 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/); } + if (defined &add_idx_hook) {&add_idx_hook if (/$idx_mark/);} + else {&add_idx if (/$idx_mark/);} + &replace_glossary_markers; + + if ($segment_figure_captions) { +s/$lof_mark/$segment_figure_captions/o + } else { s/$lof_mark/$figure_captions/o } + if ($segment_table_captions) { +s/$lot_mark/$segment_table_captions/o + } else { s/$lot_mark/$table_captions/o } + &replace_morelinks(); + if (defined &replace_citations_hook) {&replace_citations_hook if /$bbl_mark/;} + else {&replace_bbl_marks if /$bbl_mark/;} + if (defined &add_toc_hook) {&add_toc_hook if (/$toc_mark/);} + else {&add_toc if (/$toc_mark/);} + if (defined &add_childs_hook) {&add_childs_hook if (/$childlinks_on_mark/);} + else {&add_childlinks if (/$childlinks_on_mark/);} + &remove_child_marks; + + if (defined &replace_cross_references_hook) {&replace_cross_references_hook;} + else {&replace_cross_ref_marks if /$cross_ref_mark||$cross_ref_visible_mark/;} + if (defined &replace_external_references_hook) {&replace_external_references_hook;} + else {&replace_external_ref_marks if /$external_ref_mark/;} + if (defined &replace_cite_references_hook) {&replace_cite_references_hook;} + else { &replace_cite_marks if /$cite_mark/; } + if (defined &replace_user_references) { + &replace_user_references if /$user_ref_mark/; } + +} + +sub add_gls{ + local($sidx_style, $eidx_style) =('',''); + if ($INDEX_STYLES) { +if ($INDEX_STYLES =~/,/) { +local(@styles) = split(/\s*,\s*/,$INDEX_STYLES); + $sidx_style = join('','<', join('><',@styles) ,'>'); + $eidx_style = join('',''); +} else { + $sidx_style = join('','<', $INDEX_STYLES,'>'); + $eidx_style = join('',''); +} + } + &add_real_gls +} + +sub gloskeysort{ + local($x, $y) = ($a, $b); + $x=~s/^(.*)###(\d+)$/\l\1/; + local($x_id) = $2; + $y=~s/^(.*)###(\d+)$/\l\1/; + local($y_id) = $2; + + local($n) = ($x cmp $y); + + if ($n == 0) + { + $n = ($x_id <=> $y_id); + } + + $n; +} + +sub add_real_gls{ + local($type) = @_; + print "\nDoing glossary '$type' ..."; + local($key, $str, @keys, $glossary, $level, $count, + @previous, @current, $id, $linktext, $delimN); + + @keys = keys %{$glossary{$type}}; + + @keys = sort gloskeysort @keys; + + $level = 0; + + $delimN = $delimN{$type}; + + 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); + + local($entry) = $glossary_entry{$type}{$key}; + + $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 + . "\n" + : "
" + . $name + . "
" + . $glsentry{$entry}{'description'} + . $symbol . '. ' + . $glossary{$type}{$key} + . $linktext. "\n"); + $previous = $current; + } + $glossary = '
'.$glossary unless ($glossary =~ /^\s*/); + + $glossary =~ s/(]*>)()/$2$1/g; + + $str = &translate_commands("\\glossarypostamble"); + s/$gls_mark{$type}/$preglossary\n
\n$glossary<\/DL>$str\n/s; +} + +sub set_depth_levels { + # Sets $outermost_level + local($level); + # scan the document body, not the preamble, for use of sectioning commands + my ($contents) = $_; + if ($contents =~ /\\begin\s*((?:$O|$OP)\d+(?:$C|$CP))document\1|\\startdocument/s) { +$contents = $'; + } + foreach $level ("part", "chapter", "section", "subsection", + "subsubsection", "paragraph") { +last if (($outermost_level) = $contents =~ /\\($level)$delimiter_rx/); +last if (($outermost_level) = $contents =~ /\\endsegment\s*\[\s*($level)\s*\]/s); +if ($contents =~ /\\segment\s*($O\d+$C)[^<]+\1\s*($O\d+$C)\s*($level)\s*\2/s) +{ $outermost_level = $3; last }; + } + $level = ($outermost_level ? $section_commands{$outermost_level} : + do {$outermost_level = 'section'; 3;}); + + if ($REL_DEPTH && $MAX_SPLIT_DEPTH) { +$MAX_SPLIT_DEPTH = $level + $MAX_SPLIT_DEPTH; + } elsif (!($MAX_SPLIT_DEPTH)) { $MAX_SPLIT_DEPTH = 1 }; + + %unnumbered_section_commands = ( + 'tableofcontents', $level +, 'listoffigures', $level +, 'listoftables', $level +, 'bibliography', $level +, 'textohtmlindex', $level +, 'textohtmlglossary', $level +, 'textohtmlglossaries', $level + , %unnumbered_section_commands + ); + + %section_commands = ( + %unnumbered_section_commands + , %section_commands + ); +} + +sub add_bbl_and_idx_dummy_commands { + local($id) = $global{'max_id'}; + + s/([\\]begin\s*$O\d+$C\s*thebibliography)/$bbl_cnt++; $1/eg; + ## if ($bbl_cnt == 1) { +s/([\\]begin\s*$O\d+$C\s*thebibliography)/$id++; "\\bibliography$O$id$C$O$id$C $1"/geo; + #} + $global{'max_id'} = $id; + s/([\\]begin\s*$O\d+$C\s*theindex)/\\textohtmlindex $1/o; + s/[\\]printindex/\\textohtmlindex /o; + &add_gls_dummy_commands; + &lib_add_bbl_and_idx_dummy_commands() if defined(&lib_add_bbl_and_idx_dummy_commands); +} + +sub add_gls_dummy_commands{ + s/[\\]printglossary/\\textohtmlglossary/sg; + s/[\\]printglossaries/\\textohtmlglossaries/sg; +} + +sub get_firstkeyval{ + local($key,$_) = @_; + local($value); + + s/\b$key\s*=$OP(\d+)$CP(.*)$OP\1$CP\s*(,|$)/$value=$2;','/es; + undef($value) if $`=~/\b$key\s*=/; + + unless (defined($value)) + { + s/(^|,)\s*$key\s*=\s*([^,]*)\s*(,|$)/,/s; + $value=$2; + } + + ($value,$_); +} + +# need to get the value of the last key of a given name +# in the event of multiple occurences. +sub get_keyval{ + local($key,$_) = @_; + local($value); + + while (/\b$key\s*=/) + { + ($value,$_) = &get_firstkeyval($key, $_); + last unless defined($value); + } + + ($value,$_); +} + +# This is modified from do_cmd_textohtmlindex + +sub do_cmd_textohtmlglossary{ + local($_) = @_; + + local($keyval,$pat) = &get_next_optional_argument; + + local($type,$title,$toctitle,$style); + + ($type,$keyval) = &get_keyval('type', $keyval); + ($title,$keyval) = &get_keyval('title', $keyval); + ($toctitle,$keyval) = &get_keyval('toctitle', $keyval); + ($style,$keyval) = &get_keyval('style', $keyval); + + &make_textohtmlglossary($type,$toctitle,$title,$style).$_; +} + +sub make_textohtmlglossary{ + local($type,$toctitle,$title,$style) = @_; + + unless (defined($type)) {$type = 'main';} + + unless (defined $gls_mark{$type}) + { + &write_warnings("glossary type '$type' not implemented"); + } + + unless (defined($title) and $title) {$title = $gls_title{$type};} + unless (defined($toctitle) and $toctitle) {$toctitle = $title;} + + $toc_sec_title = $toctitle; + $glsfile{$type} = $CURRENT_FILE; + + $TITLE=&translate_commands($toctitle); + + if (%glossary_labels) { &make_glossary_labels(); } + + if (($SHORT_INDEX) && (%glossary_segment)) + { + &make_preglossary(); + } + else + { + $preglossary = &translate_commands("\\glossarypreamble"); + } + + local $idx_head = $section_headings{'textohtmlindex'}; + local($heading) = join('' + , &make_section_heading($title, $idx_head) + , $gls_mark{$type} ); + local($pre,$post) = &minimize_open_tags($heading); + join('',"
\n" , $pre); +} + +sub do_cmd_textohtmlglossaries{ + local($_) = @_; + + foreach $type (keys %gls_mark) + { + $id = ++$global{'max_id'}; + $_ = &make_textohtmlglossary($type,$gls_title{'main'}).$_; + } + + $_; +} + +sub make_glossary_labels { + local($key, @keys); + @keys = keys %glossary_labels; + foreach $key (@keys) { + if (($ref_files{$key}) && !($ref_files{$key} eq "$glsfile{'main'}")) { + local($tmp) = $ref_files{$key}; + &write_warnings("\nmultiple label $key , target in $glsfile{'main'} masks $tmp "); + } + $ref_files{$key} .= $glsfile{'main'}; + } +} + +sub make_preglossary{ &make_real_preglossary } +sub make_real_preglossary{ + local($key, @keys, $head, $body); + $head = "
\n

Legend:

\n
"; + @keys = keys %glossary_segment; + foreach $key (@keys) { + local($tmp) = "segment$key"; + $tmp = $ref_files{$tmp}; + $body .= "\n
$key
".&make_named_href('',$tmp,$glossary_segment{$key}); + } + $preglossary = join('', $head, $body, "\n
") if ($body); +} + +sub do_cmd_glossary { &do_real_glossary(@_) } +sub do_real_glossary { + local($_) = @_; + local($type) = "main"; + local($anchor,$entry); + + local($type,$pat) = &get_next_optional_argument; + + $entry = &missing_braces unless + (s/$next_pair_pr_rx//o&&($entry=$2)); + + $anchor = &make_glossary_entry($entry,$anchor_invisible_mark,$type); + + join('', $anchor, $_); +} + +sub make_glossary_entry { &make_real_glossary_entry(@_) } +sub make_real_glossary_entry { + local($entry,$text,$type) = @_; + local($this_file) = $CURRENT_FILE; + $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($br_id) = ++$global{'max_id'}; + $glossary{$type}{$str} .= &make_half_href($this_file."#$br_id"); + $glossary_format{$type}{$str} = $GLSCURRENTFORMAT; + $glossary_entry{$type}{$str} = $entry; + $glossary_linktext{$type}{$str} = $TITLE; + "
$text<\/A>"; +} + +sub do_cmd_newglossary{ + local($_) = @_; + local($type,$out,$in,$opt,$pat,$title); + + ($opt,$pat) = &get_next_optional_argument; + + $type = &missing_braces unless + (s/$next_pair_pr_rx//o&&($type=$2)); + $in = &missing_braces unless + (s/$next_pair_pr_rx//o&&($in=$2)); + $out = &missing_braces unless + (s/$next_pair_pr_rx//o&&($out=$2)); + $title = &missing_braces unless + (s/$next_pair_pr_rx//o&&($title=$2)); + + ($opt,$pat) = &get_next_optional_argument; + + &make_newglossarytype($type, $title); + + $_; +} + +sub make_newglossarytype{ + local($type, $title) = @_; + + $gls_mark{$type} = ""; + $gls_file_mark{$type} = ""; + $gls_title{$type} = $title; + $delimN{$type} = ", "; + $glsnumformat{$type} = $GLSCURRENTFORMAT; + @{$gls_entries{$type}} = (); + $gls_displayfirst{$type} = "glsdisplayfirst"; + $gls_display{$type} = "glsdisplay"; +} + +sub do_cmd_glsdisplay{ + local($_) = @_; + local($text,$description,$symbol,$insert); + + $text = &missing_braces unless + (s/$next_pair_pr_rx/$text=$2;''/eo); + + $description = &missing_braces unless + (s/$next_pair_pr_rx/$description=$2;''/eo); + + $symbol = &missing_braces unless + (s/$next_pair_pr_rx/$symbol=$2;''/eo); + + $insert = &missing_braces unless + (s/$next_pair_pr_rx/$insert=$2;''/eo); + + "$text$insert" . $_; +} + +sub do_cmd_glsdisplayfirst{ + local($_) = @_; + local($text,$description,$symbol,$insert); + + $text = &missing_braces unless + (s/$next_pair_pr_rx/$text=$2;''/eo); + + $description = &missing_braces unless + (s/$next_pair_pr_rx/$description=$2;''/eo); + + $symbol = &missing_braces unless + (s/$next_pair_pr_rx/$symbol=$2;''/eo); + + $insert = &missing_braces unless + (s/$next_pair_pr_rx/$insert=$2;''/eo); + + "$text$insert" . $_; +} + +sub gls_get_displayfirst{ + local($type) = @_; + local($display)= $gls_displayfirst{$type}; + + if (not defined($display)) + { + &write_warnings("Glossary '$type' is not defined"); + $display=''; + } + elsif ($display eq '') + { + &write_warnings("glsdisplayfirst not set for glossary '$type'"); + } + else + { + $display = "\\$display "; + } + + $display; +} + +sub gls_get_display{ + local($type) = @_; + local($display)= $gls_display{$type}; + + if (not defined($display)) + { + &write_warnings("Glossary '$type' is not defined"); + $display = ''; + } + elsif ($display eq '') + { + &write_warnings("glsdisplay not set for glossary '$type'"); + } + else + { + $display = "\\$display "; + } + + $display; +} + +sub do_cmd_glsnamefont{ + local($_) = @_; + local($text); + + $text = &missing_braces unless + (s/$next_pair_pr_rx/$text=$2;''/eo); + + "$text$_"; +} + +sub do_cmd_newacronym{ + local($_) = @_; + local($label,$abbrev,$long,$opt); + + ($opt,$pat) = &get_next_optional_argument; + + $label = &missing_braces unless + (s/$next_pair_pr_rx/$label=$2;''/eo); + $abbrv = &missing_braces unless + (s/$next_pair_pr_rx/$abbrv=$2;''/eo); + $long = &missing_braces unless + (s/$next_pair_pr_rx/$long=$2;''/eo); + + local($cmd) = "\\newglossaryentry"; + local($id); + $id = ++$global{'max_id'}; + $cmd .= "$OP$id$CP$label$OP$id$CP"; + $id = ++$global{'max_id'}; + local($entry) = "type=$OP$id$CP\\acronymtype$OP$id$CP,"; + $id = ++$global{'max_id'}; + $entry .= "name=$OP$id$CP$abbrv$OP$id$CP,"; + $id = ++$global{'max_id'}; + $entry .= "description=$OP$id$CP$long$OP$id$CP,"; + $id = ++$global{'max_id'}; + $entry .= "text=$OP$id$CP$abbrv$OP$id$CP,"; + $id = ++$global{'max_id'}; + $entry .= "first=$OP$id$CP$long ($abbrv)$OP$id$CP,"; + $id = ++$global{'max_id'}; + $entry .= "plural=$OP$id$CP${abbrv}s$OP$id$CP,"; + $id = ++$global{'max_id'}; + $entry .= "firstplural=$OP$id$CP${long}s (${abbrv}s)$OP$id$CP"; + + $id = ++$global{'max_id'}; + $cmd .= "$OP$id$CP$entry,$opt$OP$id$CP"; + + &translate_commands($cmd).$_; +} + +sub gls_entry_init{ + local($label, $type, $name, $desc) = @_; + + %{$glsentry{$label}} = + ( type => $type, + name => $name, + 'sort' => $name, + description => $description, + text => $name, + first => $name, + plural => "${name}s", + firstplural => "${name}s", + symbol => '', + flag => 0 + ); +} + +sub gls_get_type{ + local($label) = @_; + local($type) = ''; + + if (&gls_entry_defined($label)) + { + $type = $glsentry{$label}{'type'}; + } + else + { + &write_warnings("gls_get_type: glossary entry '$label' has not been defined"); + } + + $type; +} + +sub gls_set_type{ + local($label, $type) = @_; + + if (&gls_entry_defined($label)) + { + $glsentry{$label}{'type'} = $type; + } + else + { + &write_warnings("gls_set_type: glossary entry '$label' has not been defined"); + } +} + +sub gls_get_name{ + local($label) = @_; + local($name) = ''; + + if (&gls_entry_defined($label)) + { + $name = $glsentry{$label}{'name'}; + } + else + { + &write_warnings("gls_get_name: glossary entry '$label' has not been defined"); + } + + $name; +} + +sub gls_set_name{ + local($label, $name) = @_; + + if (&gls_entry_defined($label)) + { + $glsentry{$label}{'name'} = $name; + } + else + { + &write_warnings("gls_set_name: glossary entry '$label' has not been defined"); + } +} + +sub gls_get_description{ + local($label) = @_; + local($description) = ''; + + if (&gls_entry_defined($label)) + { + $description = $glsentry{$label}{'description'}; + } + else + { + &write_warnings("gls_get_description: glossary entry '$label' has not been defined"); + } + + $description; +} + +sub gls_set_description{ + local($label, $description) = @_; + + if (&gls_entry_defined($label)) + { + $glsentry{$label}{'description'} = $description; + } + else + { + &write_warnings("gls_set_description: glossary entry '$label' has not been defined"); + } +} + +sub gls_get_symbol{ + local($label) = @_; + local($symbol) = ''; + + if (&gls_entry_defined($label)) + { + $symbol = $glsentry{$label}{'symbol'}; + } + else + { + &write_warnings("gls_get_symbol: glossary entry '$label' has not been defined"); + } + + $symbol; +} + +sub gls_set_symbol{ + local($label, $symbol) = @_; + + if (&gls_entry_defined($label)) + { + $glsentry{$label}{'symbol'} = $symbol; + } + else + { + &write_warnings("gls_set_symbol: glossary entry '$label' has not been defined"); + } +} + +sub gls_get_sort{ + local($label) = @_; + local($sort) = ''; + + if (&gls_entry_defined($label)) + { + $sort = $glsentry{$label}{'sort'}; + } + else + { + &write_warnings("gls_get_sort: glossary entry '$label' has not been defined"); + } + + $sort; +} + +sub gls_set_sort{ + local($label, $sort) = @_; + + if (&gls_entry_defined($label)) + { + $glsentry{$label}{'sort'} = $sort; + } + else + { + &write_warnings("gls_set_sort: glossary entry '$label' has not been defined"); + } +} + +sub gls_get_text{ + local($label) = @_; + local($text) = ''; + + if (&gls_entry_defined($label)) + { + $text = $glsentry{$label}{'text'}; + } + else + { + &write_warnings("gls_get_text: glossary entry '$label' has not been defined"); + } + + $text; +} + +sub gls_set_text{ + local($label, $text) = @_; + + if (&gls_entry_defined($label)) + { + $glsentry{$label}{'text'} = $text; + } + else + { + &write_warnings("gls_set_text: glossary entry '$label' has not been defined"); + } +} + +sub gls_get_plural{ + local($label) = @_; + local($plural) = ''; + + if (&gls_entry_defined($label)) + { + $plural = $glsentry{$label}{'plural'}; + } + else + { + &write_warnings("gls_get_plural: glossary entry '$label' has not been defined"); + } + + $plural; +} + +sub gls_set_plural{ + local($label, $plural) = @_; + + if (&gls_entry_defined($label)) + { + $glsentry{$label}{'plural'} = $plural; + } + else + { + &write_warnings("gls_set_plural: glossary entry '$label' has not been defined"); + } +} + +sub gls_get_firstplural{ + local($label) = @_; + local($firstplural) = ''; + + if (&gls_entry_defined($label)) + { + $firstplural = $glsentry{$label}{'firstplural'}; + } + else + { + &write_warnings("gls_get_firstplural: glossary entry '$label' has not been defined"); + } + + $firstplural; +} + +sub gls_set_firstplural{ + local($label, $firstplural) = @_; + + if (&gls_entry_defined($label)) + { + $glsentry{$label}{'firstplural'} = $firstplural; + } + else + { + &write_warnings("gls_set_firstplural: glossary entry '$label' has not been defined"); + } +} + +sub gls_get_first{ + local($label) = @_; + local($first) = ''; + + if (&gls_entry_defined($label)) + { + $first = $glsentry{$label}{'first'}; + } + else + { + &write_warnings("gls_get_first: glossary entry '$label' has not been defined"); + } + + $first; +} + +sub gls_set_first{ + local($label, $first) = @_; + + if (&gls_entry_defined($label)) + { + $glsentry{$label}{'first'} = $first; + } + else + { + &write_warnings("gls_set_first: glossary entry '$label' has not been defined"); + } +} + +sub gls_used{ + local($label) = @_; + local($flag) = 0; + + if (&gls_entry_defined($label)) + { + $flag = $glsentry{$label}{'flag'}; + } + else + { + &write_warnings("gls_used: glossary entry '$label' has not been defined"); + } + + $flag; +} + +sub gls_entry_defined{ + local($label) = @_; + + defined(%{$glsentry{$label}}); +} + +sub do_cmd_newglossaryentry{ + local($_) = @_; + local($label,$name,$description,$symbol,$sort,$text,$first, + $plural,$firstplural,$type,$keyval); + + $label = &missing_braces unless + s/$next_pair_pr_rx/$label=$2;''/eo; + + $keyval = &missing_braces unless + s/$next_pair_pr_rx/$keyval=$2;''/eo; + + ($name,$keyval) = &get_keyval('name', $keyval); + ($description,$keyval) = &get_keyval('description', $keyval); + ($symbol,$keyval) = &get_keyval('symbol', $keyval); + ($sort,$keyval) = &get_keyval('sort', $keyval); + ($text,$keyval) = &get_keyval('text', $keyval); + ($first,$keyval) = &get_keyval('first', $keyval); + ($firstplural,$keyval) = &get_keyval('firstplural', $keyval); + ($plural,$keyval) = &get_keyval('plural', $keyval); + ($type,$keyval) = &get_keyval('type', $keyval); + + if (defined($type)) + { + $type = &translate_commands($type); + } + else + { + $type = 'main'; + } + + &gls_entry_init($label, $type, $name, $description); + + &gls_set_symbol($label, defined($symbol)?$symbol:''); + + $sort = "$name $description" unless (defined($sort) and $sort); + + &gls_set_sort($label, $sort); + + $text = $name unless (defined($text) and $text); + + &gls_set_text($label, $text); + + $first = $text unless (defined($first) and $first); + + &gls_set_first($label, $first); + + $plural = "${text}s" unless (defined($plural) and $plural); + + &gls_set_plural($label, $plural); + + $firstplural = "${first}s" unless (defined($firstplural) and $firstplural); + + &gls_set_firstplural($label, $firstplural); + + push @{$gls_entries{$type}}, $label; + + $_; +} + +sub reset_entry{ + local($label) = @_; + + $glsentry{$label}{'flag'} = 0; +} + +sub unset_entry{ + local($label) = @_; + + $glsentry{$label}{'flag'} = 1; +} + +sub do_cmd_glsreset{ + local($_) = @_; + local($label); + + $label = &missing_braces unless + s/$next_pair_pr_rx/$label=$2;''/eo; + + &reset_entry($label); + + $_; +} + +sub do_cmd_glsunset{ + local($_) = @_; + local($label); + + $label = &missing_braces unless + s/$next_pair_pr_rx/$label=$2;''/eo; + + &unset_entry($label); + + $_; +} + +sub do_cmd_ifglsused{ + local($_) = @_; + local($label,$true,$false); + + $label = &missing_braces unless + s/$next_pair_pr_rx/$label=$2;''/eo; + + $true = &missing_braces unless + s/$next_pair_pr_rx/$true=$2;''/eo; + + $false = &missing_braces unless + s/$next_pair_pr_rx/$false=$2;''/eo; + + (&gls_used($label) ? $true : $false) . $_; +} + +sub do_cmd_ifglsentryexists{ + local($_) = @_; + local($label,$true,$false); + + $label = &missing_braces unless + s/$next_pair_pr_rx/$label=$2;''/eo; + + $true = &missing_braces unless + s/$next_pair_pr_rx/$true=$2;''/eo; + + $false = &missing_braces unless + s/$next_pair_pr_rx/$false=$2;''/eo; + + (&gls_entry_defined($label) ? $true : $false) . $_; +} + +sub gls_add_entry{ + local($type, $label, $format, $text) = @_; + + local($oldfmt) = $GLSCURRENTFORMAT; + + if (defined($format) and $format) + { + $GLSCURRENTFORMAT=$format; + } + + $id = ++$global{'max_id'}; + + local($str) = &make_real_glossary_entry($label,$text,$type); + $GLSCURRENTFORMAT = $oldfmt; + + $str; +} + +sub do_cmd_glsadd{ + local($_) = @_; + local($optarg,$pat,$label,$str,$id,$type,$format); + ($optarg,$pat) = &get_next_optional_argument; + + $label = &missing_braces unless + (s/$next_pair_pr_rx/$label=$2;''/eo); + + $type = &gls_get_type($label); + + if (defined $type) + { + ($format,$optarg) = &get_keyval('format', $optarg); + $format='' unless(defined($format)); + + &gls_add_entry($type,$label,$format,""); + } + else + { + &write_warnings("gls_add: glossary entry '$label' undefined"); + $str = ''; + } + + $str . $_; +} + +sub do_cmd_glsaddall{ + local($_) = @_; + local($optarg,$pat) = &get_next_optional_argument; + + local($format,$types); + + ($type,$optarg) = &get_keyval('types', $optarg); + + ($format,$optarg) = &get_keyval('format', $optarg); + $format='' unless(defined($format)); + + local(@types) = keys(%gls_mark); + + if (defined($types)) + { + @types = split /,/, $types; + } + + foreach $type (@types) + { + # strip leasing and trailing spaces + $type=~s/^\s*([^\s]+)\s*$/\1/; + + foreach $label (@{$gls_entries{$type}}) + { + &gls_add_entry($type,$label,$format,""); + } + } + + $_; +} + +sub do_cmd_glsresetall{ + local($_) = @_; + local($types,$pat) = &get_next_optional_argument; + + local(@types) = keys(%gls_mark); + + if (defined($types) and $types) + { + @types = split /,/, $types; + } + + foreach $type (@types) + { + # strip leasing and trailing spaces + $type=~s/^\s*([^\s]+)\s*$/\1/; + + foreach $label (@{$gls_entries{$type}}) + { + &reset_entry($label); + } + } + + $_; +} + +sub do_cmd_glsunsetall{ + local($_) = @_; + local($types,$pat) = &get_next_optional_argument; + + local(@types) = keys(%gls_mark); + + if (defined($types) and $types) + { + @types = split /,/, $types; + } + + foreach $type (@types) + { + # strip leasing and trailing spaces + $type=~s/^\s*([^\s]+)\s*$/\1/; + + foreach $label (@{$gls_entries{$type}}) + { + &reset_entry($label); + } + } + + $_; +} + +sub make_glslink{ + local($type,$label,$format,$text) = @_; + local($str) = ''; + + if (defined $type) + { + $str = &gls_add_entry($type,$label,$format,$text); + } + else + { + &write_warnings("glossary '$type' undefined"); + } + + $str; +} + +sub do_cmd_glslink{ + 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); + + # v1.01 removed following lines (\glslink doesn't have + # a final optional argument! + #local ($space) = ''; + #if (/^\s+[^\[]/ or /^\s*\[.*\]\s/) {$space = ' ';} + #($optarg,$pat) = &get_next_optional_argument; + + $type = &gls_get_type($label); + + #&make_glslink($type, $label, $format, $text).$space . $_; + &make_glslink($type, $label, $format, $text) . $_; +} + +sub do_cmd_glsentrydesc{ + local($_) = @_; + + $label = &missing_braces unless + (s/$next_pair_pr_rx/$label=$2;''/eo); + + &gls_get_description($label).$_; +} + +sub do_cmd_Glsentrydesc{ + local($_) = @_; + + $label = &missing_braces unless + (s/$next_pair_pr_rx/$label=$2;''/eo); + + ucfirst(&gls_get_description($label)).$_; +} + +sub do_cmd_glsentrytext{ + local($_) = @_; + + $label = &missing_braces unless + (s/$next_pair_pr_rx/$label=$2;''/eo); + + &gls_get_text($label).$_; +} + +sub do_cmd_Glsentrytext{ + local($_) = @_; + + $label = &missing_braces unless + (s/$next_pair_pr_rx/$label=$2;''/eo); + + ucfirst(&gls_get_text($label)).$_; +} + +sub do_cmd_glsentryname{ + local($_) = @_; + + $label = &missing_braces unless + (s/$next_pair_pr_rx/$label=$2;''/eo); + + &gls_get_name($label).$_; +} + +sub do_cmd_Glsentryname{ + local($_) = @_; + + $label = &missing_braces unless + (s/$next_pair_pr_rx/$label=$2;''/eo); + + ucfirst(&gls_get_name($label)).$_; +} + +sub do_cmd_glsentryfirst{ + local($_) = @_; + + $label = &missing_braces unless + (s/$next_pair_pr_rx/$label=$2;''/eo); + + &gls_get_first($label).$_; +} + +sub do_cmd_Glsentryfirst{ + local($_) = @_; + + $label = &missing_braces unless + (s/$next_pair_pr_rx/$label=$2;''/eo); + + ucfirst(&gls_get_first($label)).$_; +} + +sub do_cmd_glsentryplural{ + local($_) = @_; + + $label = &missing_braces unless + (s/$next_pair_pr_rx/$label=$2;''/eo); + + &gls_get_plural($label).$_; +} + +sub do_cmd_Glsentryplural{ + local($_) = @_; + + $label = &missing_braces unless + (s/$next_pair_pr_rx/$label=$2;''/eo); + + ucfirst(&gls_get_plural($label)).$_; +} + +sub do_cmd_glsentryfirstplural{ + local($_) = @_; + + $label = &missing_braces unless + (s/$next_pair_pr_rx/$label=$2;''/eo); + + local($text)=$glsentry{$label}{'firstplural'}; + + unless (defined($text)) + { + &write_warnings("glossary entry '$label' has not been defined"); + $text = ''; + } + + "$text$_"; + &gls_get_firstplural($label).$_; +} + +sub do_cmd_Glsentryfirstplural{ + local($_) = @_; + + $label = &missing_braces unless + (s/$next_pair_pr_rx/$label=$2;''/eo); + + ucfirst(&gls_get_firstplural($label)).$_; +} + +sub do_cmd_glsentrysymbol{ + local($_) = @_; + + $label = &missing_braces unless + (s/$next_pair_pr_rx/$label=$2;''/eo); + + &gls_get_symbol($label).$_; +} + +sub do_cmd_Glsentrysymbol{ + local($_) = @_; + + $label = &missing_braces unless + (s/$next_pair_pr_rx/$label=$2;''/eo); + + ucfirst(&gls_get_symbol($label)).$_; +} + +sub do_cmd_gls{ + 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); + + if (&gls_used($label)) + { + # entry has already been used + + $text = &gls_get_text($label); + $display = &gls_get_display($type); + } + else + { + # entry hasn't been used + + $text = &gls_get_first($label); + $display = &gls_get_displayfirst($type); + + &unset_entry($label); + } + + local($args) = ''; + + local($id) = ++$global{'max_id'}; + $args .= "$OP$id$CP$text$OP$id$CP"; + + $id = ++$global{'max_id'}; + $args .= "$OP$id$CP$glsentry{$label}{description}$OP$id$CP"; + + $id = ++$global{'max_id'}; + $args .= "$OP$id$CP$glsentry{$label}{symbol}$OP$id$CP"; + + $id = ++$global{'max_id'}; + $args .= "$OP$id$CP$insert$OP$id$CP"; + + local($link_text) = &translate_commands("$display$args"); + + &make_glslink($type, $label, $format, $link_text) .$space . $_; +} + +sub do_cmd_glspl{ + 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) = $glsentry{$label}{'type'}; + + if (&gls_used($label)) + { + # entry has already been used + + $text = &gls_get_plural($label); + $display = &gls_get_display($type);; + } + else + { + # entry hasn't been used + + $text = &gls_get_firstplural($label); + $display = &gls_get_displayfirst($type); + + &unset_entry($label); + } + + local($args) = ''; + + local($id) = ++$global{'max_id'}; + $args .= "$OP$id$CP$text$OP$id$CP"; + + $id = ++$global{'max_id'}; + $args .= "$OP$id$CP$glsentry{$label}{description}$OP$id$CP"; + + $id = ++$global{'max_id'}; + $args .= "$OP$id$CP$glsentry{$label}{symbol}$OP$id$CP"; + + $id = ++$global{'max_id'}; + $args .= "$OP$id$CP$insert$OP$id$CP"; + + local($link_text) = &translate_commands("$display$args"); + + &make_glslink($type, $label, $format, $link_text) . $space . $_; +} + +sub do_cmd_Gls{ + 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) = $glsentry{$label}{'type'}; + + if (&gls_used($label)) + { + # entry has already been used + + $text = &gls_get_text($label); + $display = &gls_get_display($type);; + } + else + { + # entry hasn't been used + + $text = &gls_get_first($label); + $display = &gls_get_displayfirst($type); + + &unset_entry($label); + } + + local($args) = ''; + + local($id) = ++$global{'max_id'}; + $args .= "$OP$id$CP$text$OP$id$CP"; + + $id = ++$global{'max_id'}; + $args .= "$OP$id$CP$glsentry{$label}{description}$OP$id$CP"; + + $id = ++$global{'max_id'}; + $args .= "$OP$id$CP$glsentry{$label}{symbol}$OP$id$CP"; + + $id = ++$global{'max_id'}; + $args .= "$OP$id$CP$insert$OP$id$CP"; + + local($link_text) = &translate_commands("$display$args"); + + &make_glslink($type, $label, $format, ucfirst($link_text)). $space . $_; +} + +sub do_cmd_Glspl{ + 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) = $glsentry{$label}{'type'}; + + if (&gls_used($label)) + { + # entry has already been used + + $text = &gls_get_plural($label); + $display = &gls_get_display($type);; + } + else + { + # entry hasn't been used + + $text = &gls_get_firstplural($label); + $display = &gls_get_displayfirst($type); + + &unset_entry($label); + } + + local($args) = ''; + + local($id) = ++$global{'max_id'}; + $args .= "$OP$id$CP$text$OP$id$CP"; + + $id = ++$global{'max_id'}; + $args .= "$OP$id$CP$glsentry{$label}{description}$OP$id$CP"; + + $id = ++$global{'max_id'}; + $args .= "$OP$id$CP$glsentry{$label}{symbol}$OP$id$CP"; + + $id = ++$global{'max_id'}; + $args .= "$OP$id$CP$insert$OP$id$CP"; + + local($link_text) = &translate_commands("$display$args"); + + &make_glslink($type, $label, $format, ucfirst($link_text)).$space . $_; +} + +sub do_cmd_GLS{ + 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) = $glsentry{$label}{'type'}; + + if (&gls_used($label)) + { + # entry has already been used + + $text = &gls_get_text($label); + $display = &gls_get_display($type);; + } + else + { + # entry hasn't been used + + $text = &gls_get_first($label); + $display = &gls_get_displayfirst($type); + + &unset_entry($label); + } + + local($args) = ''; + + local($id) = ++$global{'max_id'}; + $args .= "$OP$id$CP$text$OP$id$CP"; + + $id = ++$global{'max_id'}; + $args .= "$OP$id$CP$glsentry{$label}{description}$OP$id$CP"; + + $id = ++$global{'max_id'}; + $args .= "$OP$id$CP$glsentry{$label}{symbol}$OP$id$CP"; + + $id = ++$global{'max_id'}; + $args .= "$OP$id$CP$insert$OP$id$CP"; + + local($link_text) = &translate_commands("$display$args"); + + &make_glslink($type, $label, $format, uc($link_text)).$space . $_; +} + +sub do_cmd_GLSpl{ + 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) = $glsentry{$label}{'type'}; + + if (&gls_used($label)) + { + # entry has already been used + + $text = &gls_get_plural($label); + $display = &gls_get_display($type);; + } + else + { + # entry hasn't been used + + $text = &gls_get_firstplural($label); + $display = &gls_get_displayfirst($type); + + &unset_entry($label); + } + + local($args) = ''; + + local($id) = ++$global{'max_id'}; + $args .= "$OP$id$CP$text$OP$id$CP"; + + $id = ++$global{'max_id'}; + $args .= "$OP$id$CP$glsentry{$label}{description}$OP$id$CP"; + + $id = ++$global{'max_id'}; + $args .= "$OP$id$CP$glsentry{$label}{symbol}$OP$id$CP"; + + $id = ++$global{'max_id'}; + $args .= "$OP$id$CP$insert$OP$id$CP"; + + local($link_text) = &translate_commands("$display$args"); + + &make_glslink($type, $label, $format, uc($link_text)).$space . $_; +} + +sub do_cmd_glossarypreamble{ + local($_) = @_; + $_[0]; +} + +sub do_cmd_glossarypostamble{ + local($_) = @_; + $_[0]; +} + +sub do_cmd_glsnumformat{ + local($_) = @_; + + $_; +} + +sub do_cmd_hyperit{ + join('', "\\textit ", $_[0]); +} + +sub do_cmd_hyperrm{ + join('', "\\textrm ", $_[0]); +} + +sub do_cmd_hypertt{ + join('', "\\texttt ", $_[0]); +} + +sub do_cmd_hypersf{ + join('', "\\textsf ", $_[0]); +} + +sub do_cmd_hyperbf{ + join('', "\\textbf ", $_[0]); +} + +&ignore_commands( <<_IGNORED_CMDS_ ); +makeglossary +makeglossaries +_IGNORED_CMDS_ + +1; -- cgit v1.2.3