summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/stex/statements.sty.ltxml
blob: d938af971678fe0625e0eb49828d5086ee62f618 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
# -*- CPERL -*-
package LaTeXML::Package::Pool;
use strict;
use LaTeXML::Package;
RequirePackage('omdoc');
RequirePackage('myindex');
DefCMPEnvironment('{assertion} OptionalKeyVals:stat',
  "<omdoc:assertion ?&KeyVal(#1,'id')(xml:id='&KeyVal(#1,'id')')() type='&KeyVal(#1,'type')'>"
  .   "?&KeyVal(#1,'title')(<omdoc:metadata><dc:title>&KeyVal(#1,'title')</dc:title></omdoc:metadata>)()"
  .  "<omdoc:CMP><omdoc:p>#body</omdoc:p></omdoc:CMP>"
  ."</omdoc:assertion>\n");
DefCMPEnvironment('{simpleDef} OptionalKeyVals:stat',
  "?&KeyVal(#1,'for')(<omdoc:symbol name='&KeyVal(#1,'for')'/>)()"
  . "<omdoc:definition type='simple' "
  .   "?&KeyVal(#1,'id')(xml:id='&KeyVal(#1,'id').def')()"
  .   "?&KeyVal(#1,'for')(for='&KeyVal(#1,'for')')()>"
  .   "?&KeyVal(#1,'title')(<omdoc:metadata><dc:title>&KeyVal(#1,'title')</dc:title></omdoc:metadata>)()"
  .   "<omdoc:CMP><omdoc:p>#body</omdoc:p></omdoc:CMP>"
  . "</omdoc:definition>\n");
DefCMPEnvironment('{PatternDef} OptionalKeyVals:stat',
  "?&KeyVal(#1,'for')(<omdoc:symbol name='&KeyVal(#1,'for')'/>)()"
  . "<omdoc:definition type='pattern' "
    . "?&KeyVal(#1,'id')(xml:id='&KeyVal(#1,'id').def')()"
    . "?&KeyVal(#1,'for')(for='&KeyVal(#1,'for')')()>"
    . "?&KeyVal(#1,'title')(<omdoc:metadata><dc:title>&KeyVal(#1,'title')</dc:title></omdoc:metadata>)()"
    . "#body"
  . "</omdoc:definition>\n");
DefEnvironment('{PatternRule}{}',
       "<omdoc:requation>#1 #body</omdoc:requation>");
DefEnvironment('{PatternCMP}{}',
       "<omdoc:CMP>#body</omdoc:CMP>");
DefEnvironment('{RecDef} OptionalKeyVals:stat',
  "?&KeyVal(#1,'for')(<omdoc:symbol name='&KeyVal(#1,'for')'/>)()"
  . "<omdoc:definition type='inductive' "
    . "?&KeyVal(#1,'id')(xml:id='&KeyVal(#1,'id').def')()"
    . "?&KeyVal(#1,'for')(for='&KeyVal(#1,'for')')()>"
    . "?&KeyVal(#1,'title')(<omdoc:metadata><dc:title>&KeyVal(#1,'title')</dc:title></omdoc:metadata>)()"
    . "<omdoc:CMP><omdoc:p>#body</omdoc:p></omdoc:CMP>"
  . "</omdoc:definition>\n");
DefCMPEnvironment('{example} OptionalKeyVals:stat',
       "<omdoc:example "
       . "?&KeyVal(#1,'id')(xml:id='&KeyVal(#1,'id')')() "
       . "for='&KeyVal(#1,'for')'>"
       . "<omdoc:CMP><omdoc:p>#body</omdoc:p></omdoc:CMP>"
     . "</omdoc:example>\n");
DefCMPEnvironment('{axiom} OptionalKeyVals:stat',
  "<omdoc:axiom ?&KeyVal(#1,'id')(xml:id='&KeyVal(#1,'id')')()>"
  . "?&KeyVal(#1,'title')(<omdoc:metadata><dc:title>&KeyVal(#1,'title')</dc:title></omdoc:metadata>)()"
  . "<omdoc:CMP><omdoc:p>#body</omdoc:p></omdoc:CMP>"
  . "</omdoc:axiom>\n");
DefEnvironment('{consymb} OptionalKeyVals:stat',
       "<omdoc:symbol ?&KeyVal(#1,'id')(xml:id='&KeyVal(#1,'id')')()"
             .               "name='&KeyVal(#1,'name')'>"
             .   "<omdoc:metadata>"
             .      "<dc:description>"
     .        "#body"
             .      "</dc:description>"
             .   "</omdoc:metadata>"
     . "</omdoc:symbol>\n");
DefConstructor('\symtype{}{}',"<omdoc:type system='#1'>#2</omdoc:type>");
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[]{}',
       "<omdoc:term role='definiendum' name='#1' cd='#theory'>#2</omdoc:term>",
       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{}{}',
       "<omdoc:term role='definiendum' name='#1-#2' cd='#theory'>#1 #2</omdoc:term>",
       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{}{}{}',
       "<omdoc:term role='definiendum' name='#1-#2-#3' cd='#theory'>#1 #2 #3</omdoc:term>",
       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',
  "<omdoc:omtext type='notation' ?&KeyVal(#1,'id')(xml:id='&KeyVal(#1,'id').not')()>"
  . "?&KeyVal(#1,'title')(<omdoc:metadata><dc:title>&KeyVal(#1,'title')</dc:title></omdoc:metadata>)()"
  . "<omdoc:CMP><omdoc:p>#body</omdoc:p></omdoc:CMP>"
  . "</omdoc:omtext>\n");
DefConstructor('\notatiendum OptionalKeyVals:notation {}',
               "<omdoc:phrase type='notation'>#1</omdoc:phrase>");
1;