package LaTeXML::Package::Pool; use strict; use LaTeXML::Package; use Cwd qw(cwd abs_path); DeclareOption('report',''); DeclareOption('book',''); DeclareOption('chapter',''); DeclareOption('part',''); DeclareOption('showignores',''); DeclareOption('extrefs',''); RequirePackage('sref'); RequirePackage('omtext'); DefEnvironment('{omgroup} OptionalKeyVals:omgroup {}', "\n" . "#2\n" . "#body\n" . ""); DefParameterType('IfBeginFollows', sub { my ($gullet) = @_; $gullet->skipSpaces; my $next = $gullet->readToken; $gullet->unread($next); $next = ToString($next); #Hm, falling back to regexp handling, the $gullet->ifNext approach didn't work properly return 1 unless ($next=~/^\\begin/); return; }, reversion=>'', optional=>1);#$ Let('\group@item@maybe@unwrap','\relax'); DefMacro('\group@item[] IfBeginFollows', sub { my($gullet,$tag,$needswrapper)=@_; ( T_CS('\group@item@maybe@unwrap'), ($needswrapper ? (Invocation(T_CS('\group@item@wrap'),$tag)->unlist) : ()) ); }); DefConstructor('\group@item@wrap {}', "" . "?#1(#1)()" . "", beforeDigest=>sub { Let('\group@item@maybe@unwrap','\group@item@unwrap'); #$_[0]->bgroup; useCMPItemizations(); return; }, properties=>sub{ RefStepItemCounter(); }); DefConstructor('\group@item@unwrap', "", beforeDigest=>sub { # $_[0]->egroup;#$ Let('\group@item@maybe@unwrap','\relax'); }, beforeConstruct=>sub { $_[0]->maybeCloseElement('omdoc:p'); $_[0]->maybeCloseElement('omdoc:CMP'); $_[0]->maybeCloseElement('omdoc:omtext'); }); Let('group@item@maybe@unwrap','\relax'); Let('\itemize@item'=>'\group@item'); Let('\enumerate@item'=>'\group@item'); Let('\description@item'=>'\group@item'); DefEnvironment('{itemize}', "" . "#body" ."", properties=>sub { beginItemize('itemize'); }, beforeDigestEnd=>sub { Digest(T_CS('\group@item@maybe@unwrap')); }); DefEnvironment('{enumerate}', "#body", properties=>sub { beginItemize('enumerate'); }, beforeDigestEnd=>sub { Digest(T_CS('\group@item@maybe@unwrap')); }); DefEnvironment('{description}', "" . "#body" ."", properties=>sub { beginItemize('description'); }, beforeDigestEnd=>sub { Digest(T_CS('\group@item@maybe@unwrap')); }); DefConstructor('\printindex',''); DefConstructor('\tableofcontents',""); DefConstructor('\bibliography{}',""); DefKeyVal('ignore','type','Semiverbatim'); DefKeyVal('ignore','comment','Semiverbatim'); DefEnvironment('{ignore} OptionalKeyVals:ignore', "#body"); DefConstructor('\STRlabel{}{}', sub { my($document,$label,$object)=@_; $document->absorb($object); $document->addAttribute('xml:id'=>ToString($label)) if $label; }); DefConstructor('\STRcopy{}',""); DefConstructor('\STRsemantics[]{}{}', sub { my($document,$label,$ignore,$object)=@_; $document->absorb($object); $document->addAttribute('xml:id'=>ToString($label)) if $label; }); DefMacro('\STRlabeldef{}{}', ""); sub omdocColorMacro { my ($color, @args) = @_; my $tok_color = TokenizeInternal($color); (T_BEGIN, T_CS('\@omdoc@color'), T_BEGIN, $tok_color->unlist, T_END, T_CS('\@omdoc@color@content'), T_OTHER('['), $tok_color->unlist, T_OTHER(']'), T_BEGIN, $args[1]->unlist, T_END, T_END); } DefMacro('\@omdoc@color{}', sub { MergeFont(color=>$_[1]->toString); return; });#$ DefConstructor('\@omdoc@color@content[]{}', "?#isMath(#2)(#2)"); foreach my $color(qw(black gray blue red green cyan magenta brown yellow orange)) { DefMacro("\\".$color.'{}', sub { omdocColorMacro($color, @_); }); }#$ DefConstructor('\newpage',''); Tag('omdoc:ignore',afterOpen=>\&numberIt,afterClose=>\&locateIt); Tag('omdoc:ref',afterOpen=>\&numberIt,afterClose=>\&locateIt); DefMacro('\baseURI []Semiverbatim', sub { AssignValue('baselocal'=>abs_path(ToString(Expand($_[1])))); AssignValue('baseuri'=>ToString(Expand($_[2])));}); DefConstructor('\url Semiverbatim',"#1"); DefConstructor('\href Semiverbatim {}',"#2"); 1;