# -*- CPERL -*-
package LaTeXML::Package::Pool;
use strict;
use LaTeXML::Package;
RequirePackage('omdoc');
RequirePackage('myindex');
DefCMPEnvironment('{assertion} OptionalKeyVals:stat',
""
. "?&KeyVal(#1,'title')(&KeyVal(#1,'title'))()"
. "#body"
."\n");
DefCMPEnvironment('{simpleDef} OptionalKeyVals:stat',
"?&KeyVal(#1,'for')()()"
. ""
. "?&KeyVal(#1,'title')(&KeyVal(#1,'title'))()"
. "#body"
. "\n");
DefCMPEnvironment('{PatternDef} OptionalKeyVals:stat',
"?&KeyVal(#1,'for')()()"
. ""
. "?&KeyVal(#1,'title')(&KeyVal(#1,'title'))()"
. "#body"
. "\n");
DefEnvironment('{PatternRule}{}',
"#1 #body");
DefEnvironment('{PatternCMP}{}',
"#body");
DefEnvironment('{RecDef} OptionalKeyVals:stat',
"?&KeyVal(#1,'for')()()"
. ""
. "?&KeyVal(#1,'title')(&KeyVal(#1,'title'))()"
. "#body"
. "\n");
DefCMPEnvironment('{example} OptionalKeyVals:stat',
""
. "#body"
. "\n");
DefCMPEnvironment('{axiom} OptionalKeyVals:stat',
""
. "?&KeyVal(#1,'title')(&KeyVal(#1,'title'))()"
. "#body"
. "\n");
DefEnvironment('{consymb} OptionalKeyVals:stat',
""
. ""
. ""
. "#body"
. ""
. ""
. "\n");
DefConstructor('\symtype{}{}',"#2");
DefCMPEnvironment('{definition} OptionalKeyVals:stat', sub {
my ($doc, $keyvals, %props) = @_;
my @symbols = @{$props{defs} || []};
foreach my $symb(@symbols) {
$doc->openElement('omdoc:symbol', name=>$symb);
$doc->closeElement('omdoc:symbol'); }
my %attrs = ();
my $id = $keyvals->getValue('id') if $keyvals;
$attrs{'xml:id'} = $id if $id;
my $ffor = $keyvals->getValue('for') if $keyvals;
my $for = $ffor . join(' ',@symbols) if $ffor;
$attrs{for} = $for if $for;
$doc->openElement('omdoc:definition', %attrs);
my $title = $keyvals->getValue('title') if $keyvals;
if ($title) {
$doc->openElement('omdoc:metadata');
$doc->openElement('dc:title');
$doc->absorb($title);
$doc->closeElement('dc:title');
$doc->closeElement('omdoc:metadata'); }
$doc->openElement('omdoc:CMP');
$doc->openElement('omdoc:p');
$doc->absorb($props{body}) if $props{body};
$doc->closeElement('omdoc:p');
$doc->closeElement('omdoc:CMP');
$doc->closeElement('omdoc:definition');
return; },
afterDigestBegin=>sub {
my ($stomach, $whatsit) = @_;
my @symbols = ();
$whatsit->setProperty(defs=>\@symbols);
AssignValue('defs', \@symbols, 'global');
return; },
afterDigest => sub {
AssignValue('defs', undef, 'global');
return; });
DefConstructor('\definiendum[]{}',
"#2",
afterDigest => sub {
my ($stomach, $whatsit) = @_;
my $addr = LookupValue('defs');
push(@$addr, $whatsit->getArg(1)->toString) if $addr;
$whatsit->setProperty(theory=>LookupValue('current_module'));
return; });
DefMacro('\defin{}', sub {
my @args = (T_BEGIN, $_[1]->unlist, T_END);
(T_CS('\definiendum'), T_OTHER('['), $_[1]->unlist, T_OTHER(']'), @args, T_CS('\defin@index'), @args); });
DefMacro('\twindef{}{}', sub {
my @args = (T_BEGIN, $_[1]->unlist, T_END, T_BEGIN, $_[2]->unlist, T_END);
(T_CS('\twindef@def'), @args, T_CS('\twindef@index'), @args); });
DefMacro('\atwindef{}{}{}', sub {
my @args = (T_BEGIN, $_[1]->unlist, T_END, T_BEGIN, $_[2]->unlist, T_END,
T_BEGIN, $_[3]->unlist, T_END);
(T_CS('\atwindef@def'), @args, T_CS('\atwindef@index'), @args); });
DefConstructor('\twindef@def{}{}',
"#1 #2",
afterDigest => sub {
my ($stomach, $whatsit) = @_;
my $addr = LookupValue('defs');
push(@$addr, $whatsit->getArg(1)->toString.'-'.$whatsit->getArg(2)->toString) if $addr;
$whatsit->setProperty(theory=>LookupValue('current_module'));
return; },
alias => '');
DefConstructor('\atwindef@def{}{}{}',
"#1 #2 #3",
afterDigest => sub {
my ($stomach, $whatsit) = @_;
my $addr = LookupValue('defs');
push(@$addr, $whatsit->getArg(1)->toString.'-'.$whatsit->getArg(2)->toString
.'-'.$whatsit->getArg(3)->toString) if $addr;
$whatsit->setProperty(theory=>LookupValue('current_module'));
return; },
alias => '');
DefCMPEnvironment('{notation} OptionalKeyVals:stat',
""
. "?&KeyVal(#1,'title')(&KeyVal(#1,'title'))()"
. "#body"
. "\n");
DefConstructor('\notatiendum OptionalKeyVals:notation {}',
"#1");
1;