Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
H
hbrs-latex-vorlage
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Anselm Eberhardt (Archived)
hbrs-latex-vorlage
Commits
3a2e323a
Commit
3a2e323a
authored
13 years ago
by
Manuel Hachtkemper
Browse files
Options
Downloads
Patches
Plain Diff
makeglossaries und glossary.perl entfernt, da beides nicht verwendet wird
parent
9403c9a3
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
glossary.perl
+0
-1055
0 additions, 1055 deletions
glossary.perl
makeglossaries
+0
-874
0 additions, 874 deletions
makeglossaries
with
0 additions
and
1929 deletions
glossary.perl
deleted
100644 → 0
+
0
−
1055
View file @
9403c9a3
# File : glossary.perl
# Author : Nicola Talbot
# Date : 5 December 2005
# Version : 1.03
# Description : LaTeX2HTML implementation of glossary package.
package main;
# These are the only package options implemented.
sub do_glossary_style_altlist{
}
sub do_glossary_style_hyper{
}
sub do_glossary_style_hyper_true{
}
sub do_glossary_style_hyperacronym{
}
sub do_glossary_style_hyperacronym_true{
}
sub do_glossary_toc{
}
sub do_glossary_toc_true{
}
$acronymtype = 'glossary';
sub do_glossary_acronym{
&do_glossary_acronym_true
}
sub do_glossary_acronym_true{
$gls_mark{'acronym'} = "<tex2html_acronym_mark>";
$gls_file_mark{'acronym'} = "<tex2html_acronym_file_mark>";
$gls_title{'acronym'} = "\\acronymname";
$delimN{'acronym'} = ", ";
$glodelim{'acronym'} = " ";
$glsnumformat{'acronym'} = "textrm";
$acronymtype = 'acronym';
}
sub do_glossary_acronym_false{
$acronymtype = 'glossary';
}
sub do_cmd_acronymname{
join('', 'List of Acronyms', $_[0]);
}
# modify set_depth_levels so that glossary is added
$gls_mark{'glossary'} = "<tex2html_gls_mark>";
$gls_file_mark{'glossary'} = "<tex2html_gls_file_mark>";
$gls_title{'glossary'} = "Glossary";
$delimN{'glossary'} = ", ";
$glodelim{'glossary'} = " ";
$glsnumformat{'glossary'} = "textrm";
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) =('<STRONG>','</STRONG>');
if ($INDEX_STYLES) {
if ($INDEX_STYLES =~/,/) {
local(@styles) = split(/\s*,\s*/,$INDEX_STYLES);
$sidx_style = join('','<', join('><',@styles) ,'>');
$eidx_style = join('','</', join('></',reverse(@styles)) ,'>');
} else {
$sidx_style = join('','<', $INDEX_STYLES,'>');
$eidx_style = join('','</', $INDEX_STYLES,'>');
}
}
&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 the $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);
$glossary .=
# If it's the same string don't start a new line
(&index_key_eq($current, $previous) ?
$delimN
. $glossary{$type}{$key}
. $linktext
. "</A>\n"
: "<DT>"
. $glossary_name{$type}{$key}
. "<DD>". $glossary_desc{$type}{$key}
. $glodelim{$type} . $glossary{$type}{$key}
. $linktext. "</A>\n");
$previous = $current;
}
$glossary = '<DD>'.$glossary unless ($glossary =~ /^\s*<D(T|D)>/);
$glossary =~ s/(<A [^>]*>)(<D(T|D)>)/$2$1/g;
$str = &translate_commands("\\glossarypostamble");
s/$gls_mark{$type}/$preglossary\n<DL COMPACT>\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
, %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);
}
# this gets called before do_cmd_newglossarytype
# so currently only substitutes \\printglossary and \\printacronym
sub add_gls_dummy_commands{
#foreach $type (keys %gls_mark)
#{
# #$id = ++$global{'max_id'};
# s/[\\]print$type/\\textohtmlglossary[$type]/sg;
#}
s/[\\]printglossary/\\textohtmlglossary/sg;
s/[\\]printacronym/\\textohtmlglossary[$acronymtype]/sg;
}
# This is modified from do_cmd_textohtmlindex
sub do_cmd_textohtmlglossary{
local($_) = @_;
local($type);
$_[0]=~s/^\s*\[([^]]*)\]//;
$type = $1;
if ($type eq '') {$type = 'glossary';}
unless (defined $gls_mark{$type})
{
&write_warnings("glossary type '$type' not implemented");
}
if (eval "(defined \&do_cmd_${type}name) ||\$new_command{\"${type}name\"}")
{
local($br_id)=++$global{'max_id'};
$TITLE = &translate_environments("$O$br_id$C\\${type}name$O$br_id$C");
}
else
{ $TITLE = $gls_title{$type} }
$toc_sec_title = $TITLE;
$glsfile{$type} = $CURRENT_FILE;
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('',"<BR>\n" , $pre, $_[0]);
}
sub make_glossary_labels {
local($key, @keys);
@keys = keys %glossary_labels;
foreach $key (@keys) {
if (($ref_files{$key}) && !($ref_files{$key} eq "$glsfile{'glossary'}")) {
local($tmp) = $ref_files{$key};
&write_warnings("\nmultiple label $key , target in $glsfile{'glossary'} masks $tmp ");
}
$ref_files{$key} .= $glsfile{'glossary'};
}
}
sub make_preglossary{ &make_real_preglossary }
sub make_real_preglossary{
local($key, @keys, $head, $body);
$head = "<HR>\n<H4>Legend:</H4>\n<DL COMPACT>";
@keys = keys %glossary_segment;
foreach $key (@keys) {
local($tmp) = "segment$key";
$tmp = $ref_files{$tmp};
$body .= "\n<DT>$key<DD>".&make_named_href('',$tmp,$glossary_segment{$key});
}
$preglossary = join('', $head, $body, "\n</DL>") if ($body);
}
sub do_cmd_glossary { &do_real_glossary(@_) }
sub do_real_glossary {
local($_) = @_;
local($br_id, $str);
local($type) = "glossary";
local($anchor);
if (s/^\S*$OP(\d+)${CP}type=(.+)$OP\1$CP//)
{
$type = $2;
}
local($idx_option,$pat) = &get_next_optional_argument;
$str = &missing_braces unless (
(s/$next_pair_pr_rx/($br_id, $str) = ($1, $2);''/eo)
||(s/$next_pair_rx/($br_id, $str) = ($1, $2);''/eo));
# the maths gets processed before being passed
# to do_cmd_glossary. How can I do this
# substitution before it gets converted to an image?
$str=~s/\"\"/\"/gs;
$str=~s/\"\|/\|/gs;
$str=~s/\"@/@/gs;
$str=~s/\"!/!/gs;
$str=~s/;SPMquot;;SPMquot;/;SPMquot;/gs;
$str=~s/;SPMquot;\|/\|/gs;
$str=~s/;SPMquot;\@/\@/gs;
$str=~s/;SPMquot;!/!/gs;
$anchor = &make_glossary_entry($br_id,$str,$anchor_invisible_mark,$type);
join('', $anchor, $_);
}
sub make_glossary_entry { &make_real_glossary_entry(@_) }
sub make_real_glossary_entry {
local($br_id,$str,$text,$type) = @_;
local($this_file) = $CURRENT_FILE;
$TITLE = $saved_title if (($saved_title)&&(!($TITLE)||($TITLE eq $default_title)));
#extract name, sort, description and format data from $str
local($name,$sort,$description,$format);
unless (($str=~/name\s*=\s*${OP}(\d+)${CP}(.+)${OP}\1${CP}\s*,?/s && ($name=$2)) ||
($str=~/name\s*=\s*([^,]+)\s*,?/s && ($name=$1)))
{
&write_warnings("can't determine name key from $str");
}
unless (($str=~/sort\s*=\s*${OP}(\d+)${CP}(.+)${OP}\1${CP}\s*,?/s && ($sort=$2)) ||
($str=~/sort\s*=\s*([^,]+)\s*,?/s && ($sort=$1)))
{
$sort = $name;
}
unless (($str=~/description\s*=\s*${OP}(\d+)${CP}(.+)${OP}\1${CP}\s*,?/s && ($description=$2)) ||
($str=~/description\s*=\s*([^,]+)\s*,?/s && ($description=$1)))
{
&write_warnings("can't determine description key from $str");
}
unless (($str=~/format\s*=\s*${OP}(\d+)${CP}(.+)${OP}\1${CP}\s*,?/s && ($format=$2)) ||
($str=~/format\s*=\s*([^,]+)\s*,?/s && ($format=$1)))
{
$format = "glsnumformat[$type]";
}
# Save the reference
$str = "$sort$description###" . ++$global{'max_id'}; # Make unique
# concatenate multiple spaces into a single space
# otherwise keys won't sort properly
$str=~s/\s+/ /gs;
$glossary{$type}{$str} .= &make_half_href($this_file."#$br_id");
$glossary_name{$type}{$str} = $name;
$glossary_format{$type}{$str} = $format;
$glossary_desc{$type}{$str} = $description;
$glossary_linktext{$type}{$str} = $TITLE;
"<A HREF=$gls_file_mark{$type}#tex2html$href_name NAME=\"$br_id\">$text<\/A>";
}
sub do_cmd_xglossary{
local($_) = @_;
local($entry,$text);
local($type) = "glossary";
if (s/^$OP(\d+)${CP}type=(.+)$OP\1$CP//)
{
$type = $2;
}
$entry = &missing_braces unless
s/$next_pair_pr_rx/$entry=$2;''/eo;
$text = &missing_braces unless
s/$next_pair_pr_rx/$text=$2;''/eo;
$entry=~s/\"\"/\"/gs;
$entry=~s/\"\|/\|/gs;
$entry=~s/\"\@/\@/gs;
$entry=~s/\"!/!/gs;
$entry=~s/;SPMquot;;SPMquot;/;SPMquot;/gs;
$entry=~s/;SPMquot;\|/\|/gs;
$entry=~s/;SPMquot;\@/\@/gs;
$entry=~s/;SPMquot;!/!/gs;
$br_id = ++$global{'max_id'};
join('', &make_glossary_entry($br_id,$entry,$text,$type),
$_);
}
sub do_cmd_newglossarytype{
local($type,$out,$in);
$type = &missing_braces unless
($_[0]=~s/$next_pair_pr_rx//o&&($type=$2));
$out = &missing_braces unless
($_[0]=~s/$next_pair_pr_rx//o&&($out=$2));
$in = &missing_braces unless
($_[0]=~s/$next_pair_pr_rx//o&&($in=$2));
&make_newglossarytype($type);
$_[0];
}
sub make_newglossarytype{
local($type) = @_;
eval ("sub do_cmd_make$type\{\}");
$gls_mark{$type} = "<tex2html_${type}_mark>";
$gls_file_mark{$type} = "<tex2html_${type}_file_mark>";
$gls_title{$type} = "\\glossaryname";
local($tmp) = 'sub do_cmd_' . $type. '{';
$tmp .= 'local($id) = ++$global{\'max_id\'};';
$tmp .= '"\\\\glossary$OP$id${CP}type=' . $type . '$OP$id$CP".$_[0];';
$tmp .= '}';
eval($tmp);
$tmp = 'sub do_cmd_x' . $type. '{';
$tmp .= 'local($id) = ++$global{\'max_id\'};';
$tmp .= '"\\\\xglossary$OP$id${CP}type=' . $type . '$OP$id$CP".$_[0];';
$tmp .= '}';
eval($tmp);
$tmp = 'sub do_cmd_print' . $type. '{';
#$tmp .= 'local($id)=++$global{\'max_id\'};';
$tmp .= '"\\\\textohtmlglossary[' . $type
. ']" . $_[0]';
$tmp .= '}';
eval($tmp);
$delimN{$type} = ", ";
$glodelim{$type} = "";
$glsnumformat{$type} = "";
}
sub do_cmd_gloshort{
local($_) = @_;
join('', "<tex2html_GLOSHORT_mark>", $_);
}
sub do_cmd_glolong{
local($_) = @_;
join('', "<tex2html_GLOLONG_mark>", $_);
}
$acronymnamefmt = "<tex2html_GLOLONG_mark> (<tex2html_GLOSHORT_mark>)";
sub do_cmd_setacronymnamefmt{
local($_) = @_;
$acronymnamefmt = &missing_braces unless
s/$next_pair_pr_rx/$acronymnamefmt=$2;''/eo;
$_;
}
sub do_cmd_acronymfont{
local($_) = @_;
local($text) = &missing_braces unless
s/$next_pair_pr_rx/$text=$2;''/eo;
$text . $_;
}
%acronym = ();
sub do_cmd_newacronym{
local($_) = @_;
local($cmdname,$pat,$abbrv,$long,$glsentry,$name);
($cmdname,$pat) = &get_next_optional_argument;
$abbrv = &missing_braces unless
(s/$next_pair_pr_rx/$abbrv=$2;''/eo);
$long = &missing_braces unless
(s/$next_pair_pr_rx/$long=$2;''/eo);
$glsentry = &missing_braces unless
(s/$next_pair_pr_rx/$glsentry=$2;''/eo);
if ($cmdname eq '')
{
$cmdname = $abbrv;
}
local($id);
$id = ++$global{'max_id'};
local($fmtedabbrv) = &translate_commands("\\acronymfont$OP$id$CP$abbrv$OP$id$CP");
unless ($glsentry=~/name=/)
{
$name = $acronymnamefmt;
$name=~s/<tex2html_GLOSHORT_mark>/$fmtedabbrv/egs;
$name=~s/<tex2html_GLOLONG_mark>/$long/egs;
$id = ++$global{'max_id'};
$glsentry .= ",name=$OP$id$CP$name$OP$id$CP";
}
$global{"${cmdname}first"} = 1;
$acronym{$cmdname}{'abbrv'} = $abbrv;
$acronym{$cmdname}{'long'} = $long;
$acronym{$cmdname}{'entry'} = $glsentry;
local($tmp);
unless ($cmdname=~/[^a-zA-Z]/)
{
$tmp = 'sub do_cmd_' . $cmdname . '{';
$tmp .= 'local($_)=@_;';
$tmp .= 'local($id)=++$global{\'max_id\'};';
$tmp .= 'local($str);';
$tmp .= '$str="${OP}$id${CP}'
. $cmdname
. '${OP}$id${CP}";';
$tmp .= '&do_cmd_useacronym($str . $_[0])';
$tmp .= '}';
eval($tmp);
$tmp = 'sub do_cmd_' . $cmdname . 'star{';
$tmp .= 'local($_)=@_;';
$tmp .= 'local($id)=++$global{\'max_id\'};';
$tmp .= 'local($str);';
$tmp .= '$str="${OP}$id${CP}'
. $cmdname
. '${OP}$id${CP}";';
$tmp .= '&do_cmd_useacronymstar($str . $_[0])';
$tmp .= '}';
eval($tmp);
$tmp = 'sub do_cmd_' . $cmdname . 'long{';
$tmp .= 'local($_)=@_;';
$tmp .= 'join("", \'' . $long . '\', $_[0])';
$tmp .= '}';
eval($tmp);
$tmp = 'sub do_cmd_' . $cmdname . 'short{';
$tmp .= 'local($_)=@_;';
$tmp .= 'join("", \'' . $fmtedabbrv . '\', $_[0])';
$tmp .= '}';
eval($tmp);
}
$_;
}
sub do_cmd_acrsh{
local($_) = @_;
local($cmdname,$text,$id);
$cmdname = &missing_braces unless
(s/$next_pair_pr_rx/$id=$1;$cmdname=$2;''/eo);
$text = &translate_commands("\\${cmdname}short");
$text . $_;
}
sub do_cmd_acrshstar{
local($_) = @_;
local($cmdname,$text,$id);
$cmdname = &missing_braces unless
(s/$next_pair_pr_rx/$id=$1;$cmdname=$2;''/eo);
$text = &translate_commands("\\${cmdname}short");
$text=~s/(<.*>)?(\w)/\1\u\2/;
$text . $_;
}
sub do_cmd_acrln{
local($_) = @_;
local($cmdname,$text,$id);
$cmdname = &missing_braces unless
(s/$next_pair_pr_rx/$id=$1;$cmdname=$2;''/eo);
$text = &translate_commands("\\${cmdname}long");
$text . $_;
}
sub do_cmd_acrlnstar{
local($_) = @_;
local($cmdname,$text,$id);
$cmdname = &missing_braces unless
(s/$next_pair_pr_rx/$id=$1;$cmdname=$2;''/eo);
$text = &translate_commands("\\${cmdname}long");
$text=~s/(\w)/\u\1/;
$text . $_;
}
sub do_cmd_useacronym{
local($_)=@_;
local($str,$abbrv,$long,$entry,$id);
local($optarg,$pat)=&get_next_optional_argument;
$cmdname = &missing_braces unless
(s/$next_pair_pr_rx/$cmdname=$2;''/eo);
if (defined %{$acronym{$cmdname}})
{
$abbrv = $acronym{$cmdname}{'abbrv'};
$long = $acronym{$cmdname}{'long'};
$entry = $acronym{$cmdname}{'entry'};
$id = ++$global{'max_id'};
$abbrv = "\\acronymfont$OP$id$CP$abbrv$OP$id$CP";
$id = ++$global{'max_id'};
$str = "\\xglossary${OP}$id${CP}type="
. $acronymtype. "${OP}$id${CP}";
$id = ++$global{'max_id'};
$str .= "${OP}$id${CP}"
. $entry . "${OP}$id${CP}";
$id = ++$global{'max_id'};
$str .= "${OP}$id${CP}";
$str .= ($global{"${cmdname}first"} ? "$long$optarg ($abbrv)" : "$abbrv$optarg");
$str .= "${OP}$id${CP}";
$global{"${cmdname}first"} = 0;
}
else
{
&write_warnings("acronym '$cmdname' not defined");
}
$str . $_
}
sub do_cmd_useacronymstar{
local($_)=@_;
local($str,$abbrv,$long,$entry,$id);
local($optarg,$pat)=&get_next_optional_argument;
$cmdname = &missing_braces unless
(s/$next_pair_pr_rx/$cmdname=$2;''/eo);
if (defined %{$acronym{$cmdname}})
{
$abbrv = $acronym{$cmdname}{'abbrv'};
$long = $acronym{$cmdname}{'long'};
$entry = $acronym{$cmdname}{'entry'};
if ($global{"${cmdname}first"})
{
$long=~s/^([^a-zA-Z]*)([a-zA-Z])/\1\u\2/;
}
else
{
$abbrv=~s/^([^a-zA-Z]*)([a-zA-Z])/\1\u\2/;
}
$id = ++$global{'max_id'};
$abbrv = "\\acronymfont$OP$id$CP$abbrv$OP$id$CP";
$name = ($global{"${cmdname}first"} ? "$long$optarg ($abbrv)" : "$abbrv$optarg");
$id = ++$global{'max_id'};
$str = "\\xglossary${OP}$id${CP}type="
. $acronymtype . "${OP}$id${CP}";
$id = ++$global{'max_id'};
$str .= "${OP}$id${CP}"
. $entry . "${OP}$id${CP}";
$id = ++$global{'max_id'};
$str .= "${OP}$id${CP}";
$str .= $name;
$str .= "${OP}$id${CP}";
$global{"${cmdname}first"} = 0;
}
else
{
&write_warnings("acronym '$cmdname' not defined");
}
$str . $_
}
sub do_cmd_ifacronymfirstuse{
local($_) = @_;
local($acronym,$truebit,$falsebit,$str);
$acronym = &missing_braces unless ($_[0]=~s/$next_pair_pr_rx//o&&($acronym=$2));
$truebit = &missing_braces unless ($_[0]=~s/$next_pair_pr_rx//o&&($truebit=$2));
$falsebit = &missing_braces unless ($_[0]=~s/$next_pair_pr_rx//o&&($falsebit=$2));
$str = ($global{"${acronym}true"} ? $truebit : $falsebit);
$str . $_[0];
}
sub do_cmd_resetacronym{
local($_) = @_;
local($cmdname);
$cmdname = &missing_braces unless
(s/$next_pair_pr_rx/$cmdname=$2;''/eo);
if (defined %{$acronym{$cmdname}})
{
$global{"${cmdname}first"} = 1;
}
else
{
&write_warnings("acronym '$cmdname' not defined");
}
$_;
}
sub do_cmd_resetallacronyms{
local($_) = @_;
foreach $key (keys %acronym)
{
$global{"${key}first"} = 1;
}
$_;
}
sub do_cmd_unsetacronym{
local($_) = @_;
local($cmdname);
$cmdname = &missing_braces unless
(s/$next_pair_pr_rx/$cmdname=$2;''/eo);
if (defined %{$acronym{$cmdname}})
{
$global{"${cmdname}first"} = 0;
}
else
{
&write_warnings("acronym '$cmdname' not defined");
}
$_;
}
sub do_cmd_unsetallacronyms{
local($_) = @_;
foreach $key (keys %acronym)
{
$global{"${key}first"} = 0;
}
$_;
}
%savedglosentry = ();
# This command is deprecated
sub do_cmd_saveglosentry{
local($_) = @_;
local($name,$desc,$type,$pat);
($type,$pat) = &get_next_optional_argument;
$name = &missing_braces unless
s/$next_pair_pr_rx/$name=$2;''/eo;
$desc = &missing_braces unless
s/$next_pair_pr_rx/$desc=$2;''/eo;
$savedglosentry{$name}{'entry'} = "name=$name,description=$desc";
$savedglosentry{$name}{'type'} = $type;
$_;
}
sub do_cmd_storeglosentry{
local($_) = @_;
local($type,$pat,$entry,$label);
($type,$pat) = &get_next_optional_argument;
if ($type eq '')
{
$type = 'glossary';
}
$label = &missing_braces unless
s/$next_pair_pr_rx/$label=$2;''/eo;
$entry = &missing_braces unless
s/$next_pair_pr_rx/$entry=$2;''/eo;
$savedglosentry{$label}{'entry'} = $entry;
$savedglosentry{$label}{'type'} = $type;
$_;
}
sub do_cmd_useglosentry{
local($_) = @_;
local($optarg,$pat,$name,$str,$id);
($optarg,$pat) = &get_next_optional_argument;
$name = &missing_braces unless
(s/$next_pair_pr_rx/$name=$2;''/eo);
if (defined $savedglosentry{$name}{type})
{
$id = ++$global{'max_id'};
$str = "\\$savedglosentry{$name}{type}${OP}$id${CP}$savedglosentry{$name}{entry}";
unless ($optarg eq "")
{
$str .= ",$optarg";
}
$str .= "${OP}$id${CP}";
}
else
{
&write_warnings("glossary entry '$name' undefined");
$str = '';
}
$str . $_;
}
sub do_cmd_useGlosentry{
local($_) = @_;
local($optarg,$pat,$name,$str,$id);
($optarg,$pat) = &get_next_optional_argument;
$name = &missing_braces unless
(s/$next_pair_pr_rx/$name=$2;''/eo);
if (defined $savedglosentry{$name}{type})
{
$id = ++$global{'max_id'};
$str = "\\x$savedglosentry{$name}{type}${OP}$id${CP}$savedglosentry{$name}{entry}";
unless ($optarg eq "")
{
$str .= ",$optarg";
}
$str .= "${OP}$id${CP}";
}
else
{
&write_warnings("glossary entry '$name' undefined");
$str = '';
}
$str . $_;
}
sub do_cmd_gls{
local($_) = @_;
local($optarg,$pat,$label,$str,$id,$name);
($optarg,$pat) = &get_next_optional_argument;
$label = &missing_braces unless
(s/$next_pair_pr_rx/$label=$2;''/eo);
if (defined $savedglosentry{$label}{type})
{
$str = $savedglosentry{$label}{'entry'};
if ($str=~/name=[ ]*${OP}(\d+)${CP}(.*)${OP}\1${CP}/s)
{
$name = $2;
}
elsif (($str=~/name=[ ]*([^,]+),/m)
|| ($str=~/name=[ ]*([^,]+)\Z(?!\n)/m))
{
$name = $1;
}
$id = ++$global{'max_id'};
$str = "\\x$savedglosentry{$label}{type}${OP}$id${CP}$savedglosentry{$label}{entry}";
unless ($optarg eq "")
{
$str .= ",$optarg";
}
$str .= "${OP}$id${CP}";
$id = ++$global{'max_id'};
$str .= "${OP}$id${CP}$name${OP}$id${CP}";
}
else
{
&write_warnings("glossary entry '$label' undefined");
$str = '';
}
$str . $_;
}
sub do_cmd_glossarypreamble{
local($_) = @_;
$_[0];
}
sub do_cmd_glossarypostamble{
local($_) = @_;
$_[0];
}
sub do_cmd_glsnumformat{
local($_) = @_;
local($type,$pat) = &get_next_optional_argument;
if ($type eq '')
{
$type = 'glossary';
}
local($cmd) = '';
unless ($glsnumformat{$type} eq '')
{
$cmd = "\\$glsnumformat{$type}";
}
$cmd . $_;
}
sub do_cmd_setglossary{
local($_) = @_;
local($str,$type,$format,$delimN,$glodelim);
$str = &missing_braces unless ($_[0]=~s/$next_pair_pr_rx//o&&($str=$2));
unless (($str=~/type=([^,]+),|$/&&($type=$1)) ||
($str=~/type=${OP}(\d+)${CP}(.*)${OP}\1${CP}/&&($type=$2)))
{
$type = 'glossary';
}
if ($str=~/glsnumformat=[ ]*${OP}(\d+)${CP}(.*)${OP}\1${CP}/s)
{
$format = $2;
}
elsif (($str=~/glsnumformat=[ ]*([^,]+),/m)
|| ($str=~/glsnumformat=[ ]*([^,]+)\Z(?!\n)/m))
{
$format = $1;
}
if ($format ne '')
{
$glsnumformat{$type} = $format;
if ($format eq 'ignore')
{
$delimN{$type} = '';
}
}
if (($str=~/delimN=([^,]+),|$/&&($delimN=$1)) ||
($str=~/delimN=${OP}(\d+)${CP}(.*)${OP}\1${CP}/&&($delimN=$2)))
{
$delimN{$type} = $delimN;
}
if (($str=~/glodelim=([^,]+),|$/&&($glodelim=$1)) ||
($str=~/glodelim=${OP}(\d+)${CP}(.*)${OP}\1${CP}/&&($glodelim=$2)))
{
$glodelim{$type} = $glodelim;
}
$_[0];
}
sub do_cmd_ignore{
local($_) = @_;
local($str);
$str = &missing_braces unless ($_[0]=~s/$next_pair_pr_rx//o&&($str=$2));
$_[0];
}
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
makeacronym
_IGNORED_CMDS_
1;
This diff is collapsed.
Click to expand it.
makeglossaries
deleted
100644 → 0
+
0
−
874
View file @
9403c9a3
#!/usr/bin/env perl
# File : makeglossaries
# Author : Nicola Talbot
# Version : 1.9 (2010/06/14)
# Description: simple Perl script that calls makeindex or xindy.
# Intended for use with "glossaries.sty" (saves having to remember
# all the various switches)
# This file is distributed as part of the glossaries LaTeX 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 or 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.
# This work consists of the files glossaries.dtx and glossaries.ins
# and the derived files glossaries.sty, mfirstuc.sty,
# glossary-hypernav.sty, glossary-list.sty, glossary-long.sty,
# glossary-super.sty, glossaries.perl.
# Also makeglossaries and makeglossaries.
my
$version
=
"
2.0 (2010-06-30)
";
# History:
# v2.0 (2010-06-30) :
# * Made file handle local in &scan_aux
# v1.9 (2010-06-14) :
# * Check for \@input
# v1.8 (2009-11-03) :
# * Create an empty output file if the input file is empty
# without calling xindy/makeindex
# v1.7 (2009-09-23) :
# * Issue warning rather than error when empty/non existant file
# checks fail
# v1.6 (2009-05-24) :
# * main glossary no longer automatically added
# (only added if information in aux file)
# * if file extension is specified, check added to ensure it
# corresponds to a known glossary extension.
# * added file existance test and file empty test
# v1.5 (2008-12-26) :
# * added support for xindy
# * picks up ordering information from aux file
# v1.4 (2008-05-10) :
# * added support for filenames with spaces.
# v1.3 (2008-03-08) :
# * changed first line from /usr/bin/perl -w to /usr/bin/env perl
# (Thanks to Karl Berry for suggesting this.)
# v1.2 (2008-03-02) :
# * added support for --help and --version
# * improved error handling
# v1.1 (2008-02-13) :
# * added -w and strict
# * added check to ensure .tex file not passed to makeglossaries
#
# v1.0 (2007-05-10) : Initial release.
use
Getopt::
Std
;
use
strict
;
use
vars
qw($opt_q $opt_t $opt_o $opt_s $opt_p $opt_g $opt_c $opt_r
$opt_l $opt_i $opt_L $opt_n $opt_C)
;
$
Getopt::Std::
STANDARD_HELP_VERSION
=
1
;
# v1.5 added -L <lang> for xindy (but language can be specified in
# .tex file)
# v1.5 added -n (print the command that would be issued but
# don't actually run the command)
getopts
('
s:o:t:p:L:C:ilqrcgn
');
unless
(
$#ARGV
==
0
)
{
die
"
makeglossaries: Need exactly one file argument.
\n
Use `makeglossaries --help' for help.
\n
";
}
# define known extensions
# v1.6: removed adding main glossary here as there's no guarantee
# that it's been used. If it has been used, the information will
# be picked up later in the aux file
my
%exttype
=
(
# main => {in=>'glo', out=>'gls', 'log'=>'glg'},
);
# v1.5 define require languages for xindy
my
%language
=
();
my
%codepage
=
();
my
$ext
=
'';
my
$name
=
$ARGV
[
0
];
# modified this to make sure users don't try passing the
# tex file:
if
(
length
(
$ARGV
[
0
])
>
3
and
substr
(
$ARGV
[
0
],
-
4
,
1
)
eq
"
.
")
{
$name
=
substr
(
$ARGV
[
0
],
0
,
length
(
$ARGV
[
0
])
-
4
);
$ext
=
substr
(
$ARGV
[
0
],
-
3
,
3
);
if
(
lc
(
$ext
)
eq
'
tex
')
{
die
("
Don't pass the tex file to makeglossaries:
\n
"
.
"
either omit the extension to make all the glossaries,
"
.
"
or specify one of the glossary files, e.g.
$name
.glo, to
"
.
"
make just that glossary.
\n
")
}
}
my
$istfile
=
"";
# should letter ordering be used? (v1.5 added)
my
$letterordering
=
defined
(
$opt_l
);
# check aux file for other glossary types
# and for ist file name
&scan_aux
(
$name
);
# has the style file been specified?
unless
(
$istfile
)
{
die
"
No
\\\@
istfilename found in '
$name
.aux'.
\n
",
"
Did your LaTeX run fail?
\n
",
"
Did your LaTeX run produce any output?
\n
",
"
Did you remember to use
\\
makeglossaries?
\n
";
}
# v1.5 save the general xindy switches
my
$xdyopts
=
'';
unless
(
$opt_L
eq
"")
{
$xdyopts
.=
"
-L
$opt_L
";
}
# save all the general makeindex switches
my
$mkidxopts
=
'';
if
(
$opt_i
)
{
$mkidxopts
.=
"
-i
";
}
if
(
$letterordering
)
{
$mkidxopts
.=
"
-l
";
$xdyopts
.=
"
-M ord/letorder
";
}
if
(
$opt_q
)
{
$mkidxopts
.=
"
-q
";
$xdyopts
.=
"
-q
";
}
if
(
$opt_r
)
{
$mkidxopts
.=
"
-r
";
}
if
(
$opt_c
)
{
$mkidxopts
.=
"
-c
";
}
if
(
$opt_g
)
{
$mkidxopts
.=
"
-g
";
}
unless
(
$opt_p
eq
"")
{
$mkidxopts
.=
"
-p
$opt_p
";
}
unless
(
$opt_s
eq
"")
{
$istfile
=
$opt_s
;
}
# Use xindy if style file ends with .xdy otherwise use makeindex
my
$usexindy
=
$istfile
=~
m/\.xdy\Z/
;
if
(
$ext
ne
'')
{
# an extension has been specified, so only process
# the specified file
# v1.6 %thistype is no longer given a default value
my
%thistype
;
my
$thislang
=
"";
my
$thiscodepage
=
"";
foreach
my
$type
(
keys
%exttype
)
{
if
(
$exttype
{
$type
}{'
in
'}
eq
$ext
)
{
%thistype
=
%
{
$exttype
{
$type
}};
$thislang
=
$language
{
$type
};
$thiscodepage
=
$codepage
{
$type
};
last
;
}
}
# v1.6 If %thistype hasn't been defined, then the given
# extension doesn't correspond to any known glossary type
unless
(
defined
%thistype
)
{
die
"
The file extension '
$ext
' doesn't correspond to any
\n
",
"
known glossary extension. Try running makeglossaries
\n
",
"
without an extension, e.g. makeglossaries
\"
$name
\"
.
\n
";
}
my
$outfile
;
if
(
$opt_o
eq
"")
{
$outfile
=
"
$name
.
$thistype
{out}
";
}
else
{
$outfile
=
$opt_o
;
}
my
$transcript
;
if
(
$opt_t
eq
"")
{
$transcript
=
"
$name
.
$thistype
{'log'}
";
}
else
{
$transcript
=
$opt_t
;
}
if
(
$usexindy
)
{
&xindy
("
$name
.
$ext
",
$outfile
,
$transcript
,
$istfile
,
$thislang
,
$thiscodepage
,
$xdyopts
,
$opt_q
,
$opt_n
);
}
else
{
&makeindex
("
$name
.
$ext
",
$outfile
,
$transcript
,
$istfile
,
$mkidxopts
,
$opt_q
,
$opt_n
);
}
}
else
{
# no file extension specified so process all glossary types
foreach
my
$type
(
keys
%exttype
)
{
my
%thistype
=
%
{
$exttype
{
$type
}};
my
$inputfile
=
"
$name
.
$thistype
{in}
";
my
$outfile
;
if
(
$opt_o
eq
"")
{
$outfile
=
"
$name
.
$thistype
{out}
";
}
else
{
$outfile
=
$opt_o
;
}
# v1.7 print warnings to STDOUT instead of STDERR
# v1.6 added file existance test
unless
(
-
e
$inputfile
)
{
print
"
Warning: File '
$inputfile
' doesn't exist.
\n
",
"
*** Skipping glossary '
$type
'. ***
\n
";
next
;
}
unless
(
-
r
$inputfile
)
{
print
"
Warning: No read access for '
$inputfile
' $!
\n
",
"
*** Skipping glossary '
$type
'. ***
\n
";
next
;
}
# v1.6 added file empty test
if
(
-
z
$inputfile
)
{
print
"
Warning: File '
$inputfile
' is empty.
\n
",
"
Have you used any entries defined in glossary '
$type
'?
\n
";
# create an empty output file and move on to the next glossary
if
(
open
OFD
,
"
>
$outfile
")
{
print
OFD
"
\\
null
\n
";
close
OFD
;
}
else
{
print
STDERR
"
Unable to create '
$outfile
' $!
\n
";
}
next
;
}
my
$transcript
;
if
(
$opt_t
eq
"")
{
$transcript
=
"
$name
.
$thistype
{'log'}
";
}
else
{
$transcript
=
$opt_t
;
}
if
(
$usexindy
)
{
&xindy
(
$inputfile
,
$outfile
,
$transcript
,
$istfile
,
$language
{
$type
},
$codepage
{
$type
},
$xdyopts
,
$opt_q
,
$opt_n
);
}
else
{
&makeindex
(
$inputfile
,
$outfile
,
$transcript
,
$istfile
,
$mkidxopts
,
$opt_q
,
$opt_n
);
}
}
}
sub
scan_aux
{
my
$name
=
shift
;
# v2.0 added
local
(
*AUXFILE
);
if
(
open
AUXFILE
,
"
$name
.aux
")
{
while
(
<
AUXFILE
>
)
{
# v1.9 added
if
(
m/\\\@input{(.+)\.aux}/
)
{
&scan_aux
(
$
1
);
}
if
(
m/\\\@newglossary\s*\{(.*)\}{(.*)}{(.*)}{(.*)}/
)
{
$exttype
{
$
1
}{'
log
'}
=
$
2
;
$exttype
{
$
1
}{'
out
'}
=
$
3
;
$exttype
{
$
1
}{'
in
'}
=
$
4
;
unless
(
$opt_q
)
{
print
"
added glossary type '$1' ($2,$3,$4)
\n
";
}
}
if
(
m/\\\@istfilename\s*{([^}]*)}/
)
{
$istfile
=
$
1
;
# check if double quotes were added to \jobname
$istfile
=~
s/^"(.*)"\.ist$/$1.ist/
;
}
# v1.5 added
if
(
m/\\\@xdylanguage\s*{([^}]+)}{([^}]*)}/
)
{
$language
{
$
1
}
=
$
2
;
}
# v1.5 added
if
(
m/\\\@gls\@codepage\s*{([^}]+)}{([^}]*)}/
)
{
$codepage
{
$
1
}
=
$
2
;
}
# v1.5 added
# Allow -l switch to override specification in aux file
unless
(
defined
(
$opt_l
))
{
if
(
m/\\\@glsorder\s*{([^}]+)}/
)
{
my
$ordering
=
$
1
;
if
(
$ordering
eq
"
word
")
{
$letterordering
=
0
;
}
elsif
(
$ordering
eq
"
letter
")
{
$letterordering
=
1
;
}
else
{
print
STDERR
"
Unknown ordering '
$letterordering
'
\n
",
"
Assuming word ordering
\n
";
$letterordering
=
0
;
}
}
}
}
close
AUXFILE
;
}
else
{
print
STDERR
"
Unable to open
$name
.aux: $!
\n
";
}
}
sub
makeindex
{
my
(
$in
,
$out
,
$trans
,
$ist
,
$rest
,
$quiet
,
$dontexec
)
=
@_
;
my
(
$name
,
$cmdstr
,
$buffer
,
$n
,
$i
,
$j
);
my
(
@stuff
,
@item
);
$cmdstr
=
"
$rest
-s
\"
$ist
\"
-t
\"
$trans
\"
-o
\"
$out
\"
\"
$in
\"
";
unless
(
$quiet
)
{
print
"
makeindex
$cmdstr
\n
";
}
unless
(
$dontexec
)
{
open
STATUS
,
"
makeindex
$cmdstr
2>&1 |
"
or
die
"
Can't fork: $!
\n
";
my
$status
=
'';
while
(
<
STATUS
>
)
{
$status
.=
$_
;
}
close
STATUS
;
if
(
$?
)
{
my
$errno
=
$?
;
if
(
open
LOGFILE
,
"
>>
$trans
")
{
print
LOGFILE
"
\n
$status
";
close
LOGFILE
;
}
else
{
print
STDERR
"
Unable to open '
$trans
' $!
\n
";
}
die
"
Call to makeindex failed (errno=
$errno
):
\n
",
$status
;
}
print
$status
;
}
}
sub
xindy
{
my
(
$in
,
$out
,
$trans
,
$ist
,
$language
,
$codepage
,
$rest
,
$quiet
,
$dontexec
)
=
@_
;
my
(
$cmdstr
,
$langparam
,
$main
);
my
(
$module
);
$module
=
$ist
;
$module
=~
s/\.xdy\Z//
;
# map babel names to xindy names
if
(
$language
eq
"
frenchb
")
{
$language
=
"
french
";
}
elsif
(
$language
=~
/^n?germanb?$/
)
{
$language
=
"
german
";
}
elsif
(
$language
eq
"
magyar
")
{
$language
=
"
hungarian
";
}
elsif
(
$language
eq
"
lsorbian
")
{
$language
=
"
lower-sorbian
";
}
elsif
(
$language
eq
"
norsk
")
{
$language
=
"
norwegian
";
}
elsif
(
$language
eq
"
portuges
")
{
$language
=
"
portuguese
";
}
elsif
(
$language
eq
"
russianb
")
{
$language
=
"
russian
";
}
elsif
(
$language
eq
"
slovene
")
{
$language
=
"
slovenian
";
}
elsif
(
$language
eq
"
ukraineb
")
{
$language
=
"
ukrainian
";
}
elsif
(
$language
eq
"
usorbian
")
{
$language
=
"
upper-sorbian
";
}
if
(
$language
)
{
$langparam
=
"
-L
$language
";
}
else
{
$langparam
=
"";
}
# most languages work with xindy's default codepage, but
# some don't, so if the codepage isn't specific, check
# the known cases that will generate an error
# and supply a default. (For all other cases, it's up to the
# user to supply a codepage.)
if
(
$codepage
eq
'')
{
if
(
$language
eq
'
dutch
')
{
$codepage
=
"
ij-as-ij
";
}
elsif
(
$language
eq
'
german
')
{
$codepage
=
"
din
";
}
elsif
(
$language
eq
'
gypsy
')
{
$codepage
=
"
northrussian
";
}
elsif
(
$language
eq
'
hausa
')
{
$codepage
=
"
utf
";
}
elsif
(
$language
eq
'
klingon
')
{
$codepage
=
"
utf
";
}
elsif
(
$language
eq
'
latin
')
{
$codepage
=
"
utf
";
}
elsif
(
$language
eq
'
mongolian
')
{
$codepage
=
"
cyrillic
";
}
elsif
(
$language
eq
'
slovak
')
{
$codepage
=
"
small
";
}
elsif
(
$language
eq
'
spanish
')
{
$codepage
=
"
modern
";
}
elsif
(
$language
eq
'
vietnamese
')
{
$codepage
=
"
utf
";
}
}
my
$codepageparam
=
"";
if
(
$codepage
)
{
$codepageparam
=
"
-C
$codepage
";
}
$main
=
join
('
',
"
-I xindy
",
"
-M
\"
$module
\"
",
"
-t
\"
$trans
\"
",
"
-o
\"
$out
\"
",
"
\"
$in
\"
");
$cmdstr
=
join
('
',
$rest
,
$langparam
,
$codepageparam
,
$main
);
unless
(
$quiet
)
{
print
"
xindy
$cmdstr
\n
";
}
unless
(
$dontexec
)
{
open
STATUS
,
"
xindy
$cmdstr
2>&1 |
"
or
die
"
Can't fork: $!
\n
";
my
$status
=
'';
my
$warnings
=
"";
my
$retry
=
"";
while
(
<
STATUS
>
)
{
$status
.=
$_
;
$warnings
.=
$_
if
/WARNING:/
;
}
close
STATUS
;
if
(
$status
=~
/Cannot locate xindy module for language ([^\s]+) in codepage ([^\s]+)/
)
{
$cmdstr
=
join
('
',
$rest
,
$langparam
,
$main
);
unless
(
$quiet
)
{
my
$message
=
"
$&
\n
Retrying using default codepage.
\n
";
print
STDERR
$message
;
$retry
.=
$message
;
print
"
xindy
$cmdstr
\n
";
}
open
STATUS
,
"
xindy
$cmdstr
2>&1 |
"
or
die
"
Can't fork: $!
\n
";
$status
=
'';
while
(
<
STATUS
>
)
{
$status
.=
$_
;
}
close
STATUS
;
}
if
(
$status
=~
/Cannot locate xindy module for language ([^\s]+)/
and
$
1
ne
'
general
')
{
$cmdstr
=
join
('
',
$rest
,
"
-L general
",
$main
);
unless
(
$quiet
)
{
my
$message
=
"
$&
\n
Retrying with -L general
\n
";
print
STDERR
$message
;
$retry
.=
$message
;
print
"
xindy
$cmdstr
\n
";
}
open
STATUS
,
"
xindy
$cmdstr
2>&1 |
"
or
die
"
Can't fork: $!
\n
";
$status
=
'';
while
(
<
STATUS
>
)
{
$status
.=
$_
;
}
close
STATUS
;
}
if
(
$?
)
{
my
$errno
=
$?
;
if
(
open
LOGFILE
,
"
>>
$trans
")
{
print
LOGFILE
"
\n
$status
";
close
LOGFILE
;
}
else
{
print
STDERR
"
Unable to open '
$trans
' $!
\n
";
}
if
(
$language
)
{
die
"
Call to xindy failed (errno=
$errno
):
\n
",
$status
;
}
else
{
# If the language hasn't been set, then it may be
# because the document doesn't contain
# \printglossaries/\printglossary or it may be
# because the user has a customized style file that
# contains the language settings.
die
"
Call to xindy failed (errno=
$errno
):
\n
",
$status
,
"
\n\n
No language detected.
",
"
\n
Have you remembered to use
\\
printglossary
\n
",
"
or
\\
printglossaries in your document?
\n\n
";
}
}
print
$status
;
if
(
open
LOGFILE
,
"
>>
$trans
")
{
print
LOGFILE
"
\n
$warnings
";
if
(
$retry
)
{
print
LOGFILE
"
\n
makeglossaries messages:
\n\n
",
$retry
;
}
close
LOGFILE
;
}
else
{
print
STDERR
"
Unable to open '
$trans
' $!
\n
";
}
}
}
sub
HELP_MESSAGE
{
print
"
\n
Syntax : makeglossaries [options] <filename>
\n\n
";
print
"
For use with the glossaries package to pass relevant
\n
";
print
"
files to makeindex or xindy
\n\n
";
print
"
<filename>
\t
Base name of glossary file(s). This should
\n
";
print
"
\t\t
be the name of your main LaTeX document without any
\n
";
print
"
\t\t
extension.
\n
";
print
"
\n
General Options:
\n
";
print
"
-o <gls>
\t
Use <gls> as the output file.
\n
";
print
"
-q
\t\t
Quiet mode
\n
";
print
"
-s <sty>
\t
Employ <sty> as the style file
\n
";
print
"
-t <log>
\t
Employ <log> as the transcript file
\n
";
print
"
\n
Xindy Options:
\n
";
print
"
-L <language>
\t
Use <language>.
\n
";
print
"
\n
Makeindex Options:
\n
";
print
"
-c
\t\t
Compress intermediate blanks
\n
";
print
"
-g
\t\t
Employ German word ordering
\n
";
print
"
-l
\t\t
Letter ordering
\n
";
print
"
-p <num>
\t
Set the starting page number to be <num>
\n
";
print
"
-r
\t\t
Disable implicit page range formation
\n
";
print
"
\n
See makeindex documentation for further details on these
";
print
"
options
\n
";
}
sub
VERSION_MESSAGE
{
print
"
Makeglossaries Version
$version
\n
";
print
"
Copyright (C) 2007 Nicola L C Talbot
\n
";
print
"
This material is subject to the LaTeX Project Public License.
\n
";
}
1
;
=head1 NAME
makeglossaries - Calls makeindex/xindy for LaTeX documents using glossaries package
=head1 SYNOPSIS
B<makeglossaries> [B<-o> I<file>] [B<-q>] [B<-s> I<file>]
[B<-t> I<file>] [B<-L> I<language>] [B<-c>] [B<-g>] [B<-l>]
[B<-p> I<num>] [B<-r>] [B<--version>] [B<--help>] I<filename>
=head1 DESCRIPTION
B<makeglossaries> is designed for use with LaTeX documents that
use the glossaries package. The mandatory argument I<filename> should
be the name of the LaTeX document without the .tex extension.
B<makeglossaries> will read the auxiliary file to determine whether
B<makeindex> or B<xindy> should be called. All the information
required to be passed to the relevant indexing application should
also be contained in the auxiliary file, but may be overridden by
the option arguments to B<makeglossaries>.
=head1 OPTIONS
=over 4
=item B<-q>
Quiet mode. Reduces chatter to standard output.
=item B<-o> I<file>
Use I<file> as the output file. (Only suitable for documents
containing a single glossary, otherwise each glossary will be
overridden.)
=item B<-s> I<file>
Use I<file> as the style file. Note that if you use this option,
you need to know whether B<makeindex> or B<xindy> will be called, as
they have different style files.
=item B<-t> I<file>
Use I<file> as the transcript file.
=item B<-L> I<language>
This option only has an effect if B<xindy> is called. Sets the
language. See B<xindy> documentation for further details.
=item B<-c>
Compress intermediate blanks (B<makeindex> only).
=item B<-g>
Employ German word ordering (B<makeindex> only).
=item B<-l>
Letter ordering (B<makeindex> only).
=item B<-p> I<num>
Sets the starting page number to be I<num> (B<makeindex> only).
=item B<-r>
Disable implicit page range formation (B<makeindex> only).
=item B<--version>
Prints version number and exits.
=item B<--help>
Prints help message and exits.
=back
=head1 REQUIRES
Perl, Getopt::Std, and makeindex or xindy (depending on glossaries
package options).
=head1 LICENSE
This is free software distributed under the LaTeX Project Public
License. There is NO WARRANTY.
See L<http://www.latex-project.org/lppl.txt> for details.
=head1 AUTHOR
Nicola L. C. Talbot,
L<http://theoval.cmp.uea.ac.uk/~nlct/>
=head1 RECOMMENDED READING
The glossaries manual:
texdoc glossaries
=cut
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment