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
|
package LaTeXML::Package::Pool;
use strict;
use LaTeXML::Package;
DeclareOption('extrefs','');
RequirePackage('metakeys');
sub withhash {'#';}
DefConstructor('\sref[]{}',
"<omdoc:oref href='&withhash()#2'/>");
DefConstructor('\srefs[]{}',
"<omdoc:oref href='&withhash()#2'/>");
DefConstructor('\srefl[]{}',
"<omdoc:oref href='&withhash()#2'/>");
DefConstructor('\spageref{}',
"<omdoc:oref href='&withhash()#1'/>");
DefConstructor('\makeextrefs{}','');
DefConstructor('\extref[]{}{}',
"<omdoc:oref href='#2@#3'/>");
DefConstructor('\theextref','');
DefConstructor('\extpageref[]{}{}',
"<omdoc:oref href='#2@#3'/>");
DefConstructor('\theextref','');
DefConstructor('\extrefstyle{}{}',"");
DefConstructor('\extrefstyle{}{}',"");
DefConstructor('\inputrefs{}{}','');
DefEnvironment('{sequation} OptionalKeyVals',
"<ltx:equation "
. "?&KeyVal(#1,'id')(xml:id='&KeyVal(#1,'id')' "
. "refnum='#refnum')(xml:id='#id')>"
. "<ltx:Math mode='display'>"
. "<ltx:XMath>#body</ltx:XMath>"
. "</ltx:Math>"
. "</ltx:equation>",
mode=>'display_math',
properties=> sub { RefStepCounter('equation') },
locked=>1);
DefMacro('\seqnarray OptionalKeyVals','\begin{eqnarray*}');
DefMacro('\endseqnarray','\end{eqnarray*}');
DefMacro('\withcite{}{}','\begin{withcitation}{#1}#2\citeit\end{withcitation}');
DefConstructor('\citeit',"<omdoc:citation/> ",
afterConstruct => sub {
my ($document,$whatsit) = @_;
# LibXML acrobatics, since we can't talk about the xml:id prior to construction's end
# (and please do correct me if this is inaccurate)
my $node = $document->getNode;
my ($citenode) = $document->findnodes('preceding-sibling::omdoc:citation',$node);
my ($phrase_parent) = $document->findnodes('ancestor::ltx:text[@xml:id]',$node);
return unless (defined $phrase_parent) && (defined $citenode);
my $id = $phrase_parent->getAttribute('xml:id');
my $refs = $phrase_parent->getAttribute('citeit-refs');
$phrase_parent->removeAttribute('citeit-refs');
$citenode->setAttribute('for',$id);
$citenode->setAttribute('refs',$refs);
});#$
DefEnvironment('{withcitation}{}',
"<ltx:text citeit-refs='#1'>#body</ltx:text>");
1;
|