diff --git a/conf/defaults.config b/conf/defaults.config index 9a3cb68a81..3832a18041 100644 --- a/conf/defaults.config +++ b/conf/defaults.config @@ -1111,26 +1111,16 @@ $pg{directories}{macrosPath} = [ ".", # search the problem file's directory $courseDirs{macros}, $pg{directories}{macros}, - "$courseDirs{templates}/Library/macros/Alfred", - "$courseDirs{templates}/Library/macros/BrockPhysics", - "$courseDirs{templates}/Library/macros/CollegeOfIdaho", - "$courseDirs{templates}/Library/macros/Dartmouth", - "$courseDirs{templates}/Library/macros/FortLewis", - "$courseDirs{templates}/Library/macros/Hope", - "$courseDirs{templates}/Library/macros/LaTech", - "$courseDirs{templates}/Library/macros/MC", - "$courseDirs{templates}/Library/macros/Michigan", - "$courseDirs{templates}/Library/macros/Mizzou", - "$courseDirs{templates}/Library/macros/NAU", - "$courseDirs{templates}/Library/macros/PCC", - "$courseDirs{templates}/Library/macros/TCNJ", - "$courseDirs{templates}/Library/macros/UBC", - "$courseDirs{templates}/Library/macros/UMass-Amherst", - "$courseDirs{templates}/Library/macros/UW-Stout", - "$courseDirs{templates}/Library/macros/UniSiegen", - "$courseDirs{templates}/Library/macros/Union", - "$courseDirs{templates}/Library/macros/WHFreeman", - "$courseDirs{templates}/Library/macros/Wiley", + "$pg{directories}{macros}/answers", + "$pg{directories}{macros}/capa", + "$pg{directories}{macros}/contexts", + "$pg{directories}{macros}/core", + "$pg{directories}{macros}/graph", + "$pg{directories}{macros}/math", + "$pg{directories}{macros}/misc", + "$pg{directories}{macros}/parsers", + "$pg{directories}{macros}/ui", + "$pg{directories}{macros}/deprecated", ]; $pg{directories}{htmlPath} = [ # paths to search for auxiliary html files (requires full url) diff --git a/doc/parser/macros/Differentiation.pl b/doc/parser/macros/Differentiation.pl deleted file mode 100644 index a052463b4a..0000000000 --- a/doc/parser/macros/Differentiation.pl +++ /dev/null @@ -1,20 +0,0 @@ -# -# Example of how to add new functionality to the Parser. -# -# Here we load new methods for the Parser object classes. Note, however, -# that these are PERSISTANT when used with webwork2 (mod_perl), and so we -# need to take care not to load them more than once. We look for the -# variable $Parser::Differentiation::loaded, which is defined in the -# differentiation package, in order to tell. -# -# DifferentiationDefs.pl is really just a copy of the -# Parser::Differentiation.pm file, and you really could just preload the -# latter instead by uncommenting the 'use Parser::Differentiation' line at -# the bottom of Parser.pm. (This file is really just a sample). The way -# it's done here will load it the first time it gets used, then will keep -# it around, so not much overhead even this way. -# - -loadMacros("DifferentiationDefs.pl") unless $Parser::Differentiation::loaded; - -1; diff --git a/doc/parser/macros/DifferentiationDefs.pl b/doc/parser/macros/DifferentiationDefs.pl deleted file mode 100644 index 38409648f1..0000000000 --- a/doc/parser/macros/DifferentiationDefs.pl +++ /dev/null @@ -1,737 +0,0 @@ -# -# Extend differentiation to multiple variables -# Check differentiation for complex functions -# Do derivatives for norm and unit. -# -# Make shortcuts for getting numbers 1, 2, and sqrt, etc. -# - -################################################## -# -# Differentiate the formula in terms of the given variable -# -sub Parser::D { - my $self = shift; - my $x = shift; - if (!defined($x)) { - my @vars = keys(%{ $self->{variables} }); - my $n = scalar(@vars); - if ($n == 0) { - return $self->new('0') if $self->{isNumber}; - $x = 'x'; - } else { - $self->Error("You must specify a variable to differentiate by") unless $n == 1; - $x = $vars[0]; - } - } else { - return $self->new('0') unless defined $self->{variables}{$x}; - } - return $self->new($self->{tree}->D($x)); -} - -sub Item::D { - my $self = shift; - my $type = ref($self); - $type =~ s/.*:://; - $self->Error("Differentiation for '$type' is not implemented", $self->{ref}); -} - -######################################################################### - -sub Parser::BOP::comma::D { Item::D(shift) } -sub Parser::BOP::union::D { Item::D(shift) } - -sub Parser::BOP::add::D { - my $self = shift; - my $x = shift; - $self = Parser::BOP->new($self->{equation}, $self->{bop}, $self->{lop}->D($x), $self->{rop}->D($x)); - return $self->reduce; -} - -sub Parser::BOP::subtract::D { - my $self = shift; - my $x = shift; - $self = Parser::BOP->new($self->{equation}, $self->{bop}, $self->{lop}->D($x), $self->{rop}->D($x)); - return $self->reduce; -} - -sub Parser::BOP::multiply::D { - my $self = shift; - my $x = shift; - my $equation = $self->{equation}; - $self = Parser::BOP->new( - $equation, '+', - Parser::BOP->new($equation, $self->{bop}, $self->{lop}->D($x), $self->{rop}->copy($equation)), - Parser::BOP->new($equation, $self->{bop}, $self->{lop}->copy($equation), $self->{rop}->D($x)) - ); - return $self->reduce; -} - -sub Parser::BOP::divide::D { - my $self = shift; - my $x = shift; - my $equation = $self->{equation}; - $self = Parser::BOP->new( - $equation, - $self->{bop}, - Parser::BOP->new( - $equation, '-', - Parser::BOP->new($equation, '*', $self->{lop}->D($x), $self->{rop}->copy($equation)), - Parser::BOP->new($equation, '*', $self->{lop}->copy($equation), $self->{rop}->D($x)) - ), - Parser::BOP->new($equation, '^', $self->{rop}, Parser::Number->new($equation, 2)) - ); - return $self->reduce; -} - -sub Parser::BOP::power::D { - my $self = shift; - my $x = shift; - my $equation = $self->{equation}; - my $vars = $self->{rop}->getVariables; - if (defined($vars->{$x})) { - $vars = $self->{lop}->getVariables; - if (defined($vars->{$x})) { - $self = Parser::Function->new( - $equation, - 'exp', - [ - Parser::BOP->new( - $equation, '*', - $self->{rop}->copy($equation), - Parser::Function->new($equation, 'log', [ $self->{lop}->copy($equation) ], 0) - ) - ] - ); - return $self->D($x); - } - $self = Parser::BOP->new( - $equation, '*', - Parser::Function->new($equation, 'log', [ $self->{lop}->copy($equation) ], 0), - Parser::BOP->new($equation, '*', $self->copy($equation), $self->{rop}->D($x)) - ); - } else { - $self = Parser::BOP->new( - $equation, - '*', - Parser::BOP->new( - $equation, - '*', - $self->{rop}->copy($equation), - Parser::BOP->new( - $equation, - $self->{bop}, - $self->{lop}->copy($equation), - Parser::BOP->new( - $equation, '-', - $self->{rop}->copy($equation), - Parser::Number->new($equation, 1) - ) - ) - ), - $self->{lop}->D($x) - ); - } - return $self->reduce; -} - -sub Parser::BOP::cross::D { Item::D(shift) } -sub Parser::BOP::dot::D { Item::D(shift) } -sub Parser::BOP::underscore::D { Item::D(shift) } - -######################################################################### - -sub Parser::UOP::plus::D { - my $self = shift; - my $x = shift; - return $self->{op}->D($x); -} - -sub Parser::UOP::minus::D { - my $self = shift; - my $x = shift; - $self = Parser::UOP->new($self->{equation}, 'u-', $self->{op}->D($x)); - return $self->reduce; -} - -sub Parser::UOP::factorial::D { Item::D(shift) } - -######################################################################### - -sub Parser::Function::D { - my $self = shift; - $self->Error("Differentiation of '$self->{name}' not implemented", $self->{ref}); -} - -sub Parser::Function::D_chain { - my $self = shift; - my $x = $self->{params}[0]; - my $name = "D_" . $self->{name}; - $self = Parser::BOP->new($self->{equation}, '*', $self->$name($x->copy), $x->D(shift)); - return $self->reduce; -} - -############################# - -sub Parser::Function::trig::D { Parser::Function::D_chain(@_) } - -sub Parser::Function::trig::D_sin { - my $self = shift; - my $x = shift; - return Parser::Function->new($self->{equation}, 'cos', [$x]); -} - -sub Parser::Function::trig::D_cos { - my $self = shift; - my $x = shift; - my $equation = $self->{equation}; - return Parser::UOP->new($equation, 'u-', Parser::Function->new($equation, 'sin', [$x])); -} - -sub Parser::Function::trig::D_tan { - my $self = shift; - my $x = shift; - my $equation = $self->{equation}; - return Parser::BOP->new( - $equation, '^', - Parser::Function->new($equation, 'sec', [$x]), - Parser::Number->new($equation, 2) - ); -} - -sub Parser::Function::trig::D_cot { - my $self = shift; - my $x = shift; - my $equation = $self->{equation}; - return Parser::UOP->new( - $equation, - 'u-', - Parser::BOP->new( - $equation, '^', - Parser::Function->new($equation, 'csc', [$x]), - Parser::Number->new($equation, 2) - ) - ); -} - -sub Parser::Function::trig::D_sec { - my $self = shift; - my $x = shift; - my $equation = $self->{equation}; - return Parser::BOP->new( - $equation, '*', - Parser::Function->new($equation, 'sec', [$x]), - Parser::Function->new($equation, 'tan', [$x]) - ); -} - -sub Parser::Function::trig::D_csc { - my $self = shift; - my $x = shift; - my $equation = $self->{equation}; - return Parser::UOP->new( - $equation, - 'u-', - Parser::BOP->new( - $equation, '*', - Parser::Function->new($equation, 'csc', [$x]), - Parser::Function->new($equation, 'cot', [$x]) - ) - ); -} - -sub Parser::Function::trig::D_asin { - my $self = shift; - my $x = shift; - my $equation = $self->{equation}; - return Parser::BOP->new( - $equation, - '/', - Parser::Number->new($equation, 1), - Parser::Function->new( - $equation, - 'sqrt', - [ - Parser::BOP->new( - $equation, '-', - Parser::Number->new($equation, 1), - Parser::BOP->new($equation, '^', $x, Parser::Number->new($equation, 2)) - ) - ] - ) - ); -} - -sub Parser::Function::trig::D_acos { - my $self = shift; - my $x = shift; - my $equation = $self->{equation}; - return Parser::UOP->new( - $equation, - 'u-', - Parser::BOP->new( - $equation, - '/', - Parser::Number->new($equation, 1), - Parser::Function->new( - $equation, - 'sqrt', - [ - Parser::BOP->new( - $equation, '-', - Parser::Number->new($equation, 1), - Parser::BOP->new($equation, '^', $x, Parser::Number->new($equation, 2)) - ) - ] - ) - ) - ); -} - -sub Parser::Function::trig::D_atan { - my $self = shift; - my $x = shift; - my $equation = $self->{equation}; - return Parser::BOP->new( - $equation, - '/', - Parser::Number->new($equation, 1), - Parser::BOP->new( - $equation, '+', - Parser::Number->new($equation, 1), - Parser::BOP->new($equation, '^', $x, Parser::Number->new($equation, 2)) - ) - ); -} - -sub Parser::Function::trig::D_acot { - my $self = shift; - my $x = shift; - my $equation = $self->{equation}; - return Parser::UOP->new( - $equation, - 'u-', - Parser::BOP->new( - $equation, - '/', - Parser::Number->new($equation, 1), - Parser::BOP->new( - $equation, '+', - Parser::Number->new($equation, 1), - Parser::BOP->new($equation, '^', $x, Parser::Number->new($equation, 2)) - ) - ) - ); -} - -sub Parser::Function::trig::D_asec { - my $self = shift; - my $x = shift; - my $equation = $self->{equation}; - return Parser::BOP->new( - $equation, - '/', - Parser::Number->new($equation, 1), - Parser::BOP->new( - $equation, - '*', - Parser::Function->new($equation, 'abs', [$x]), - Parser::Function->new( - $equation, - 'sqrt', - [ - Parser::BOP->new( - $equation, '-', - Parser::BOP->new($equation, '^', $x, Parser::Number->new($equation, 2)), - Parser::Number->new($equation, 1) - ) - ] - ) - ) - ); -} - -sub Parser::Function::trig::D_acsc { - my $self = shift; - my $x = shift; - my $equation = $self->{equation}; - return Parser::UOP->new( - $equation, - 'u-', - Parser::BOP->new( - $equation, - '/', - Parser::Number->new($equation, 1), - Parser::BOP->new( - $equation, - '*', - Parser::Function->new($equation, 'abs', [$x]), - Parser::Function->new( - $equation, - 'sqrt', - [ - Parser::BOP->new( - $equation, '-', - Parser::BOP->new($equation, '^', $x, Parser::Number->new($equation, 2)), - Parser::Number->new($equation, 1) - ) - ] - ) - ) - ) - ); -} - -############################# - -sub Parser::Function::hyperbolic::D { Parser::Function::D_chain(@_) } - -sub Parser::Function::hyperbolic::D_sinh { - my $self = shift; - my $x = shift; - return Parser::Function->new($self->{equation}, 'cosh', [$x]); -} - -sub Parser::Function::hyperbolic::D_cosh { - my $self = shift; - my $x = shift; - return Parser::Function->new($self->{equation}, 'sinh', [$x]); -} - -sub Parser::Function::hyperbolic::D_tanh { - my $self = shift; - my $x = shift; - my $equation = $self->{equation}; - return Parser::BOP->new( - $equation, '^', - Parser::Function->new($equation, 'sech', [$x]), - Parser::Number->new($equation, 2) - ); -} - -sub Parser::Function::hyperbolic::D_coth { - my $self = shift; - my $x = shift; - my $equation = $self->{equation}; - return Parser::UOP->new( - $equation, - 'u-', - Parser::BOP->new( - $equation, '^', - Parser::Function->new($equation, 'csch', [$x]), - Parser::Number->new($equation, 2) - ) - ); -} - -sub Parser::Function::hyperbolic::D_sech { - my $self = shift; - my $x = shift; - my $equation = $self->{equation}; - return Parser::UOP->new( - $equation, - 'u-', - Parser::BOP->new( - $equation, '*', - Parser::Function->new($equation, 'sech', [$x]), - Parser::Function->new($equation, 'tanh', [$x]) - ) - ); -} - -sub Parser::Function::hyperbolic::D_csch { - my $self = shift; - my $x = shift; - my $equation = $self->{equation}; - return Parser::UOP->new( - $equation, - 'u-', - Parser::BOP->new( - $equation, '*', - Parser::Function->new($equation, 'csch', [$x]), - Parser::Function->new($equation, 'coth', [$x]) - ) - ); -} - -sub Parser::Function::hyperbolic::D_asinh { - my $self = shift; - my $x = shift; - my $equation = $self->{equation}; - return Parser::BOP->new( - $equation, - '/', - Parser::Number->new($equation, 1), - Parser::Function->new( - $equation, - 'sqrt', - [ - Parser::BOP->new( - $equation, '+', - Parser::Number->new($equation, 1), - Parser::BOP->new($equation, '^', $x, Parser::Number->new($equation, 2)) - ) - ] - ) - ); -} - -sub Parser::Function::hyperbolic::D_acosh { - my $self = shift; - my $x = shift; - my $equation = $self->{equation}; - return Parser::BOP->new( - $equation, - '/', - Parser::Number->new($equation, 1), - Parser::Function->new( - $equation, - 'sqrt', - [ - Parser::BOP->new( - $equation, '-', - Parser::BOP->new($equation, '^', $x, Parser::Number->new($equation, 2)), - Parser::Number->new($equation, 1) - ) - ] - ) - ); -} - -sub Parser::Function::hyperbolic::D_atanh { - my $self = shift; - my $x = shift; - my $equation = $self->{equation}; - return Parser::BOP->new( - $equation, - '/', - Parser::Number->new($equation, 1), - Parser::BOP->new( - $equation, '-', - Parser::Number->new($equation, 1), - Parser::BOP->new($equation, '^', $x, Parser::Number->new($equation, 2)) - ) - ); -} - -sub Parser::Function::hyperbolic::D_acoth { - my $self = shift; - my $x = shift; - my $equation = $self->{equation}; - return Parser::BOP->new( - $equation, - '/', - Parser::Number->new($equation, 1), - Parser::BOP->new( - $equation, '-', - Parser::Number->new($equation, 1), - Parser::BOP->new($equation, '^', $x, Parser::Number->new($equation, 2)) - ) - ); -} - -sub Parser::Function::hyperbolic::D_asech { - my $self = shift; - my $x = shift; - my $equation = $self->{equation}; - return Parser::UOP->new( - $equation, - 'u-', - Parser::BOP->new( - $equation, - '/', - Parser::Number->new($equation, 1), - Parser::BOP->new( - $equation, - '*', $x, - Parser::Function->new( - $equation, - 'sqrt', - [ - Parser::BOP->new( - $equation, '-', - Parser::Number->new($equation, 1), - Parser::BOP->new($equation, '^', $x, Parser::Number->new($equation, 2)) - ) - ] - ) - ) - ) - ); -} - -sub Parser::Function::hyperbolic::D_acsch { - my $self = shift; - my $x = shift; - my $equation = $self->{equation}; - return Parser::UOP->new( - $equation, - 'u-', - Parser::BOP->new( - $equation, - '/', - Parser::Number->new($equation, 1), - Parser::BOP->new( - $equation, - '*', - Parser::Function->new($equation, 'abs', [$x]), - Parser::Function->new( - $equation, - 'sqrt', - [ - Parser::BOP->new( - $equation, '+', - Parser::Number->new($equation, 1), - Parser::BOP->new($equation, '^', $x, Parser::Number->new($equation, 2)) - ) - ] - ) - ) - ) - ); -} - -############################# - -sub Parser::Function::numeric::D { Parser::Function::D_chain(@_) } - -sub Parser::Function::numeric::D_log { - my $self = shift; - my $x = shift; - my $equation = $self->{equation}; - return Parser::BOP->new($equation, '/', Parser::Number->new($equation, 1), $x); -} - -sub Parser::Function::numeric::D_log10 { - my $self = shift; - my $x = shift; - my $equation = $self->{equation}; - return Parser::BOP->new( - $equation, '/', - Parser::Number->new($equation, 1), - Parser::BOP->new($equation, '*', Parser::Number->new($equation, CORE::log(10)), $x) - ); -} - -sub Parser::Function::numeric::D_exp { - my $self = shift; - my $x = shift; - return $self->copy(); -} - -sub Parser::Function::numeric::D_sqrt { - my $self = shift; - my $x = shift; - my $equation = $self->{equation}; - return Parser::BOP->new( - $equation, '/', - Parser::Number->new($equation, 1), - Parser::BOP->new($equation, '*', Parser::Number->new($equation, 2), $self->copy) - ); -} - -sub Parser::Function::numeric::D_abs { Parser::Function::D(@_) } -sub Parser::Function::numeric::D_int { Parser::Function::D(@_) } -sub Parser::Function::numeric::D_sgn { Parser::Function::D(@_) } - -######################################################################### - -sub Parser::List::D { - my $self = shift; - my $x = shift; - $self = $self->copy($self->{equation}); - foreach my $f (@{ $self->{coords} }) { $f = $f->D($x) } - return $self->reduce; -} - -sub Parser::List::Interval::D { - my $self = shift; - $self->Error("Can't differentiate intervals", $self->{ref}); -} - -sub Parser::List::AbsoluteValue::D { - my $self = shift; - $self->Error("Can't differentiate absolute values", $self->{ref}); -} - -######################################################################### - -sub Parser::Number::D { Parser::Number->new(shift->{equation}, 0) } - -######################################################################### - -sub Parser::Complex::D { Parser::Number->new(shift->{equation}, 0) } - -######################################################################### - -sub Parser::Constant::D { Parser::Number->new(shift->{equation}, 0) } - -######################################################################### - -sub Parser::Value::D { - my $self = shift; - my $x = shift; - my $equation = $self->{equation}; - return Parser::Value->new($equation, $self->{value}->D($x, $equation)); -} - -sub Value::D { - my $self = shift; - my $x = shift; - my $equation = shift; - return 0 if $self->isComplex; - my @coords = @{ $self->{data} }; - foreach my $n (@coords) { - if (ref($n) eq "") { $n = 0 } - else { $n = $n->D($x, $equation)->data } - } - return $self->new([@coords]); -} - -sub Value::List::D { - my $self = shift; - my $x = shift; - my $equation = shift; - my @coords = @{ $self->{data} }; - foreach my $n (@coords) { - if (ref($n) eq "") { $n = 0 } - else { $n = $n->D($x) } - } - return $self->new([@coords]); -} - -sub Value::Interval::D { - shift; - shift; - my $self = shift; - $self->Error("Can't differentiate intervals", $self->{ref}); -} - -sub Value::Union::D { - shift; - shift; - my $self = shift; - $self->Error("Can't differentiate unions", $self->{ref}); -} - -######################################################################### - -sub Parser::Variable::D { - my $self = shift; - my $x = shift; - my $d = ($self->{name} eq $x) ? 1 : 0; - return Parser::Number->new($self->{equation}, $d); -} - -######################################################################### - -sub Parser::String::D { Parser::Number->new(shift->{equation}, 0) } - -######################################################################### - -package Parser::Differentiation; -our $loaded = 1; - -######################################################################### - -1; diff --git a/doc/parser/macros/parserTables.pl b/doc/parser/macros/parserTables.pl deleted file mode 100644 index 22b9b05a6d..0000000000 --- a/doc/parser/macros/parserTables.pl +++ /dev/null @@ -1,90 +0,0 @@ -loadMacros("parserUtils.pl"); - -############################################# -# -# For Parser example tables: -# - -$BTT = MODES(TeX => '{\tt ', Latex2HTML => $bHTML . '' . $eHTML, HTML => ''); -$ETT = MODES(TeX => '}', Latex2HTML => $bHTML . '' . $eHTML, HTML => ''); - -$BC = MODES( - TeX => '{\small\it ', - Latex2HTML => $bHTML . '' . $eHTML, - HTML => '' -); -$EC = MODES( - TeX => '}', - Latex2HTML => $bHTML . '' . $eHTML, - HTML => '' -); - -$LT = MODES(TeX => "<", Latex2HTML => "<", HTML => '<'); -$GT = MODES(TeX => ">", Latex2HTML => ">", HTML => '>'); - -$TEX = MODES(TeX => '{\TeX}', HTML => 'TeX', HTML_dpng => '\(\bf\TeX\)'); - -@rowOptions = ( - indent => 0, - separation => 0, - align => 'LEFT" NOWRAP="1', # alignment hack to get NOWRAP -); - -sub ParserRow { - my $f = shift; - my $t = ''; - Context()->clearError; - my ($s, $err) = PG_restricted_eval($f); - if (defined $s) { - my $ss = $s; - if (ref($s) && \&{ $s->string }) { - $t = '\(' . $s->TeX . '\)'; - $s = $s->string; - } elsif ($s !~ m/^[a-z]+$/i) { - $t = '\(' . Formula($s)->TeX . '\)'; - $s = Formula($s)->string; - } - $s =~ s//$GT/g; - if (ref($ss) && \&{ $ss->class }) { - if ($ss->class eq 'Formula') { - $s .= ' ' . $BC . '(Formula returning ' . $ss->showType . ')' . $EC; - } else { - $s .= ' ' . $BC . '(' . $ss->class . ' object)' . $EC; - } - } - } else { - $s = $BC . (Context()->{error}{message} || $err) . $EC; - $t = ''; - } - $f =~ s//$GT/g; - if ($displayMode eq 'TeX') { - $f =~ s/\^/\\char`\\^/g; - $s =~ s/\^/\\char`\\^/g; - $f =~ s/#/\\#/g; - $s =~ s/#/\\#/g; - } - my $row = Row([ $BTT . $f . $ETT, $BTT . $s . $ETT, $t ], @rowOptions); - $row =~ s/\$/\${DOLLAR}/g; - return $row; -} - -sub ParserTable { - my $table = BeginTable(border => 1, padding => 20) - . Row([ $BBOLD . "Perl Code" . $EBOLD, $BBOLD . "Result" . $EBOLD, $BBOLD . $TEX . ' version' . $EBOLD ], - @rowOptions); - foreach my $f (@_) { $table .= ParserRow($f) } - $table .= EndTable(); - return $table; -} - -sub Title { - my $title = shift; - - MODES( - TeX => "\\par\\centerline{\\bf $title}\\par\\nobreak\n", - Latex2HTML => $bHTML . '

' . $title . '

' . $eHTML, - HTML => '

' . $title . '

' - ); -} diff --git a/doc/parser/macros/parserUtils.pl b/doc/parser/macros/parserUtils.pl deleted file mode 100644 index b47528bc21..0000000000 --- a/doc/parser/macros/parserUtils.pl +++ /dev/null @@ -1,58 +0,0 @@ -loadMacros("unionImage.pl", "unionTables.pl",); - -$bHTML = '\begin{rawhtml}'; -$eHTML = '\end{rawhtml}'; - -# HTML(htmlcode) -# HTML(htmlcode,texcode) -# -# Insert $html in HTML mode or \begin{rawhtml}$html\end{rawhtml} in -# Latex2HTML mode. In TeX mode, insert nothing for the first form, and -# $tex for the second form. -# -sub HTML { - my ($html, $tex) = @_; - return ('') unless (defined($html) && $html ne ''); - $tex = '' unless (defined($tex)); - MODES(TeX => $tex, Latex2HTML => $bHTML . $html . $eHTML, HTML => $html); -} - -# -# Begin and end mode -# -$BTT = HTML('', '\texttt{'); -$ETT = HTML('', '}'); - -# -# Begin and end mode -# -$BSMALL = HTML('', '{\small '); -$ESMALL = HTML('', '}'); - -# -# Block quotes -# -$BBLOCKQUOTE = HTML('
', '\hskip3em '); -$EBLOCKQUOTE = HTML('
'); - -# -# Smart-quotes in TeX mode, regular quotes in HTML mode -# -$LQ = MODES(TeX => '``', Latex2HTML => '"', HTML => '"'); -$RQ = MODES(TeX => "''", Latex2HTML => '"', HTML => '"'); - -# -# make sure all characters are displayed -# -sub protectHTML { - my $string = shift; - $string =~ s/&/\&/g; - $string =~ s//\>/g; - $string; -} - -sub _parserUtils_init { } - -1; - diff --git a/doc/parser/macros/unionImage.pl b/doc/parser/macros/unionImage.pl deleted file mode 100644 index c02b26fd30..0000000000 --- a/doc/parser/macros/unionImage.pl +++ /dev/null @@ -1,94 +0,0 @@ -###################################################################### -# -# A routine to make including images easier to control -# -# Usage: Image(name,options) -# -# where name is the name of an image file or a reference to a -# graphics object (or a reference to a pair of one of these), -# and options are taken from among the following: -# -# size => [w,h] the size of the image in the HTML page -# (default is [150,150]) -# -# tex_size => r the size to use in TeX mode (as a percentage -# of the line width times 10). E.g., 500 is -# half the width, etc. (default is 200.) -# -# link => 0 or 1 whether to include a link to the original -# image (default is 0, unless there are -# two images given) -# -# border => 0 or 1 size of image border in HTML mode -# (defaults to 2 or 1 depending on whether -# there is a link or not) -# -# align => placement vertical alignment for image in HTML mode -# (default is "BOTTOM") -# -# tex_center => 0 or 1 whether to center the image horizontally -# in TeX mode (default is 0) -# -# The image name can be one of a number of different things. It can be -# the name of an image file, or an alias to one produce by the alias() -# command. It can be a graphics object reference created by init_graph(). -# Or it can be a pair of these (in square brackets). The first is the -# image for the HTML file, and the second is the image that it will be -# linked to. -# -# Examples: Image("graph.gif", size => [200,200]); -# Image(["graph.gif","graph-large.gif"]); -# -# The alias() and insertGraph() functions will be called automatically -# when needed. -# -sub Image { - my $image = shift; - my $ilink; - my %options = ( - size => [ 150, 150 ], - tex_size => 200, - link => 0, - align => "BOTTOM", - tex_center => 0, - @_ - ); - my ($w, $h) = @{ $options{size} }; - my ($ratio, $link) = ($options{tex_size} * (.001), $options{link}); - my ($border, $align) = ($options{border}, $options{align}); - my ($tcenter) = $options{tex_center}; - my $HTML; - my $TeX; - ($image, $ilink) = @{$image} if (ref($image) eq "ARRAY"); - $image = alias(insertGraph($image)) if (ref($image) eq "WWPlot"); - $image = alias($image) unless ($image =~ m!^/!i); - - if ($ilink) { - $ilink = alias(insertGraph($ilink)) if (ref($ilink) eq "WWPlot"); - $ilink = alias($ilink) unless ($ilink =~ m!^/!i); - } else { - $ilink = $image; - } - $border = (($link || $ilink ne $image) ? 2 : 1) unless defined($border); - $HTML = - ''; - $HTML = '' . $HTML . '' if $link or $ilink ne $image; - $TeX = '\includegraphics[width=' . $ratio . '\linewidth]{' . $image . '}'; - $TeX = '\centerline{' . $TeX . '}' if $tcenter; - MODES( - TeX => $TeX . "\n", - Latex2HTML => $bHTML . $HTML . $eHTML, - HTML => $HTML - ); -} - -1; diff --git a/doc/parser/macros/unionTables.pl b/doc/parser/macros/unionTables.pl deleted file mode 100644 index 456964cdd5..0000000000 --- a/doc/parser/macros/unionTables.pl +++ /dev/null @@ -1,276 +0,0 @@ -###################################################################### -## -## Functions for creating tables of various kinds -## -## ColumnTable() Creates a two-column display in HTML, -## but only one column in TeX. -## -## ColumnMatchTable() Does a side-by-side match table -## -## BeginTable() Begin a borderless HTML table -## Row() Create a row in the table -## AlignedRow() Create a row with alignment in each column -## TableSpace() Insert extra vertical space in the table -## EndTable() End the table -## - -###################################################################### -# -# Make a two-column table in HTML and Latex2HTML modes -# -# Usage: ColumnTable(col1,col2,[options]) -# -# Options can be taken from: -# -# indent => n the width to indent the first column -# (default is 0) -# -# separation => n the width of the separating gutter -# (default is 50) -# -# valign => type set the vertical alignment -# (default is "MIDDLE") -# -sub ColumnTable { - my $col1 = shift; - my $col2 = shift; - my %options = (indent => 0, separation => 50, valign => "MIDDLE", @_); - my ($ind, $sep) = ($options{"indent"}, $options{"separation"}); - my $valign = $options{"valign"}; - - my ($bhtml, $ehtml) = ('\begin{rawhtml}', '\end{rawhtml}'); - ($bhtml, $ehtml) = ('', '') unless ($displayMode eq "Latex2HTML"); - - my $HTMLtable = qq { - $bhtml -
 $ehtml - $col1 - $bhtml $ehtml - $col2 - $bhtml
$ehtml - }; - - MODES( - TeX => '\par\medskip\hbox{\qquad\vtop{' - . '\advance\hsize by -3em ' - . $col1 . '}}' - . '\medskip\hbox{\qquad\vtop{' - . '\advance\hsize by -3em ' - . $col2 - . '}}\medskip', - Latex2HTML => $HTMLtable, - HTML => $HTMLtable - ); -} - -# -# Use columns for a match-list output -# -# Usage: ColumnMatchTable($ml,options) -# -# where $ml is a math list reference and options are those -# allowed for ColumnTable above. -# -sub ColumnMatchTable { - my $ml = shift; - - ColumnTable($ml->print_q, $ml->print_a, @_); -} - -# -# Command for tables with no borders. -# -# Usage: BeginTable(options); -# -# Options are taken from: -# -# border => n value for BORDER attribute (default 0) -# spacing => n value for CELLSPACING attribute (default 0) -# padding => n value for CELLPADDING attribute (default 0) -# tex_spacing => dimen value for spacing between columns in TeX -# (e.g, tex_spacing => 2em) (default 1em) -# tex_border => dimen value for left- and right border in TeX (0pt) -# center => 0 or 1 center table or not (default 1) -# -sub BeginTable { - my %options = ( - border => 0, - padding => 0, - spacing => 0, - center => 1, - tex_spacing => "1em", - tex_border => "0pt", - @_ - ); - my ($bd, $pd, $sp) = ($options{border}, $options{padding}, $options{spacing}); - my ($tsp, $tbd) = ($options{tex_spacing}, $options{tex_border}); - my ($center, $tcenter) = (' ALIGN="CENTER"', '\centerline'); - ($center, $tcenter) = ('', '') if (!$options{center}); - my $table = qq{}; - - MODES( - TeX => '\par\medskip' . $tcenter . '{\kern ' . $tbd . '\vbox{\halign{#\hfil&&\kern ' . $tsp . ' #\hfil', - Latex2HTML => $bHTML . $table . $eHTML . "\n", - HTML => $table . "\n" - ); -} - -# -# Usage: EndTable(options) -# -# where options are taken from: -# -# tex_border => dimen extra vertical space in TeX mode (default 0pt) -# -sub EndTable { - my %options = (tex_border => "0pt", @_); - my $tbd = $options{tex_border}; - MODES( - TeX => '\cr}}\kern ' . $tbd . '}\medskip' . "\n", - Latex2HTML => $bHTML . '
' . $eHTML . "\n", - HTML => '' . "\n" - ); -} - -# -# Creates a row in the table -# -# Usage: Row([item1,item2,...],options); -# -# Each item appears as a separate entry in the table. -# -# Options control how the row is displayed: -# -# indent => num Specifies size of blank column on the left -# (default: indent => 0) -# -# separation => num Specifies separation of columns -# (default: spearation => 30) -# -# align => "type" Specifies alignment of initial column -# (default: align => "LEFT") -# -# valign => "type" Specified vertical alignment of row -# (default: valign => "MIDDLE") -# -sub Row { - my $rowref = shift; - my @row = @{$rowref}; - my %options = ( - indent => 0, - separation => 30, - align => "LEFT", - valign => "MIDDLE", - @_ - ); - my ($cind, $csep) = ($options{indent}, $options{separation}); - my ($align, $valign) = ($options{align}, $options{valign}); - my $sep = ' '; - $sep = '' if ($csep < 1); - my $ind = ' '; - $ind = '' if ($cind < 1); - my $fill = ''; - $fill = '\hfil' if (uc($align) eq "CENTER"); - $fill = '\hfill' if (uc($align) eq "RIGHT"); - - MODES( - TeX => "\\cr\n" . $fill . join('& ', @row), - Latex2HTML => $bHTML - . "$ind" - . $eHTML - . join($bHTML . "$sep" . $eHTML, @row) - . $bHTML - . '' - . $eHTML . "\n", - HTML => "$ind" - . join("$sep", @row) - . '' . "\n" - ); -} - -# -# AlignedRow([item1,item2,...],options); -# -# Options control how the row is displayed: -# -# indent => num Specifies size of blank column on the left -# (default: indent => 0) -# -# separation => num Specifies separation of columns -# (default: spearation => 30) -# -# align => "type" Specifies alignment of all columns -# (default: align => "CENTER") -# -# valign => "type" Specified vertical alignment of row -# (default: valign => "MIDDLE") -# -sub AlignedRow { - my $rowref = shift; - my @row = @{$rowref}; - my %options = ( - indent => 0, - separation => 30, - align => "CENTER", - valign => "MIDDLE", - @_ - ); - my ($cind, $csep) = ($options{indent}, $options{separation}); - my ($align, $valign) = ($options{align}, $options{valign}); - my $sep = ' '; - $sep = '' if ($csep < 1); - my $ind = ' '; - $ind = '' if ($cind < 1); - my $fill = ''; - $fill = '\hfil ' if (uc($align) eq "CENTER"); - $fill = '\hfill ' if (uc($align) eq "RIGHT"); - - MODES( - TeX => "\\cr\n" . $fill . join('&' . $fill, @row), - Latex2HTML => $bHTML - . "$ind" - . $eHTML - . join($bHTML . "$sep" . $eHTML, @row) - . $bHTML - . '' - . $eHTML . "\n", - HTML => "$ind" - . join("$sep", @row) - . '' . "\n" - ); -} - -# -# Add extra space between rows of a table -# -# Usage: TableSpace(pixels,points) -# -# where pixels is the number of pixels of space in HTML mode and -# points is the number of points to use in TeX mode. -# -sub TableSpace { - my $rsep = shift; - my $tsep = shift; - $rsep = $tsep if (defined($tsep) && $main::displayMode eq "TeX"); - return "" if ($rsep < 1); - MODES( - TeX => '\vadjust{\kern ' . $rsep . 'pt}' . "\n", - Latex2HTML => $bHTML . '' . $eHTML . "\n", - HTML => '' . "\n", - ); -} - -# -# A horizontal rule within a table. (Could have been a variable, -# but all the other table commands are subroutines, so kept it -# one to be consistent.) -# -sub TableLine { - MODES( - TeX => '\vadjust{\kern2pt\hrule\kern2pt}', - Latex2HTML => $bHTML . '
' . $eHTML . "\n", - HTML => '
' . "\n" - ); -} - -1;