LaTeXML
view release on metacpan or search on metacpan
lib/LaTeXML/Post/MathML.pm view on Meta::CPAN
my $color = $_[0]->getAttribute('color') || $LaTeXML::MathML::COLOR;
return ['m:mroot', { ($color ? (mathcolor => $color) : ()) }, pmml($_[2]), pmml_scriptsize($_[1])]; },
sub { return ['m:apply', {}, ['m:root', {}], ['m:degree', {}, cmml($_[1])], cmml($_[2])]; });
# Note MML's distinction between quotient and divide: quotient yeilds an integer
DefMathML("Token:?:quotient", undef, sub { return ['m:quotient']; });
DefMathML("Token:?:factorial", undef, sub { return ['m:factorial']; });
DefMathML("Token:?:divide", undef, sub { return ['m:divide']; });
DefMathML("Token:?:maximum", undef, sub { return ['m:max']; });
DefMathML("Token:?:minimum", undef, sub { return ['m:min']; });
DefMathML("Token:?:minus", undef, sub { return ['m:minus']; });
DefMathML("Token:?:uminus", undef, sub { return ['m:uminus']; });
DefMathML("Token:?:plus", undef, sub { return ['m:plus']; });
DefMathML("Token:?:power", undef, sub { return ['m:power']; });
DefMathML("Token:?:remainder", undef, sub { return ['m:rem']; });
DefMathML("Token:?:times", undef, sub { return ['m:times']; });
DefMathML("Token:?:gcd", undef, sub { return ['m:gcd']; });
DefMathML("Token:?:and", undef, sub { return ['m:and']; });
DefMathML("Token:?:or", undef, sub { return ['m:or']; });
DefMathML("Token:?:xor", undef, sub { return ['m:xor']; });
DefMathML("Token:?:not", undef, sub { return ['m:not']; });
DefMathML("Token:?:implies", undef, sub { return ['m:implies']; });
DefMathML("Token:?:forall", undef, sub { return ['m:forall']; });
DefMathML("Token:?:exists", undef, sub { return ['m:exists']; });
DefMathML("Token:?:absolute-value", undef, sub { return ['m:abs']; });
DefMathML("Token:?:conjugate", undef, sub { return ['m:conjugate']; });
DefMathML("Token:?:argument", undef, sub { return ['m:arg']; });
DefMathML("Token:?:real-part", undef, sub { return ['m:real']; });
DefMathML("Token:?:imaginary-part", undef, sub { return ['m:imaginary']; });
DefMathML("Token:?:lcm", undef, sub { return ['m:lcm']; });
DefMathML("Token:?:floor", undef, sub { return ['m:floor']; });
DefMathML("Token:?:ceiling", undef, sub { return ['m:ceiling']; });
#======================================================================
# Relations:
# eq, neq, gt, lt, geq, leq, equivalent, approx, factorof
DefMathML("Token:RELOP:?", \&pmml_mo);
DefMathML("Token:?:equals", undef, sub { return ['m:eq']; });
DefMathML("Token:?:not-equals", undef, sub { return ['m:neq']; });
DefMathML("Token:?:greater-than", undef, sub { return ['m:gt']; });
DefMathML("Token:?:less-than", undef, sub { return ['m:lt']; });
DefMathML("Token:?:greater-than-or-equals", undef, sub { return ['m:geq']; });
DefMathML("Token:?:less-than-or-equals", undef, sub { return ['m:leq']; });
DefMathML("Token:?:equivalent-to", undef, sub { return ['m:equivalent']; });
DefMathML("Token:?:approximately-equals", undef, sub { return ['m:approx']; });
DefMathML("Apply:?:not-approximately-equals", undef, sub {
my ($op, @args) = @_;
return cmml_synth_not('m:approx', @args); });
DefMathML("Apply:?:less-than-or-approximately-equals", undef, sub {
my ($op, @args) = @_;
return cmml_or_compose(['m:lt', 'm:approx'], @args); });
DefMathML("Token:?:factor-of", undef, sub { return ['m:factorof']; });
DefMathML("Token:METARELOP:?", \&pmml_mo);
DefMathML('Apply:RELOP:?', \&pmml_infix);
DefMathML('Apply:METARELOP:?', \&pmml_infix);
# Top level relations
DefMathML('Apply:?:formulae', sub {
my ($op, @elements) = @_;
return pmml_row(map { pmml($_) } @elements); },
sub {
my ($op, @elements) = @_;
return ['m:apply', {},
['m:csymbol', { cd => 'ambiguous' }, 'formulae-sequence'],
map { cmml($_) } @elements];
});
DefMathML('Apply:?:multirelation',
sub {
my ($op, @elements) = @_;
# This presumes that the relational operators scattered through here
# will be recognized as such by pmml and turned into m:mo
return pmml_row(map { pmml($_) } @elements); },
sub {
my ($op, @elements) = @_;
my $lhs = cmml(shift(@elements));
return $lhs unless @elements;
my @relations = ();
while (@elements) {
my $rel = shift(@elements);
my $rhs = shift(@elements);
push(@relations, ['m:apply', {}, cmml($rel), $lhs, cmml_shared($rhs)]);
$lhs = cmml_share($rhs); }
return (scalar(@relations) > 1 ? ['m:apply', {}, ['m:and', {}], @relations] : $relations[0]); }
);
#======================================================================
# Calculus and Vector Calculus:
# int, diff, partialdiff, lowlimit, uplimit, bvar, degree,
# divergence, grad, curl, laplacian.
DefMathML("Token:INTOP:?", \&pmml_bigop);
DefMathML("Token:LIMITOP:?", \&pmml_mo);
DefMathML('Apply:ARROW:?', \&pmml_infix);
DefMathML("Token:?:integral", undef, sub { return ['m:int']; });
DefMathML("Token:?:differential", undef, sub { return ['m:diff']; });
DefMathML("Token:?:partial-differential", undef, sub { return ['m:partialdiff']; });
# lowlimit, uplimit, degree ?
DefMathML("Token:?:divergence", undef, sub { return ['m:divergence']; });
DefMathML("Token:?:gradient", undef, sub { return ['m:grad']; });
DefMathML("Token:?:curl", undef, sub { return ['m:curl']; });
DefMathML("Token:?:laplacian", undef, sub { return ['m:laplacian']; });
#======================================================================
# Theory of Sets,
# set, list, union, intersect, in, notin, subset, prsubset, notsubset, notprsubset,
# setdiff, card, cartesianproduct.
DefMathML("Apply:?:set", undef, sub {
my ($op, @args) = @_;
return ['m:set', {}, map { cmml($_) } @args]; });
DefMathML("Apply:?:list", undef, sub {
my ($op, @args) = @_;
return ['m:list', {}, map { cmml($_) } @args]; });
DefMathML("Token:?:union", undef, sub { return ['m:union']; });
DefMathML("Token:?:intersection", undef, sub { return ['m:intersect']; });
DefMathML("Token:?:element-of", undef, sub { return ['m:in']; });
DefMathML("Token:?:not-element-of", undef, sub { return ['m:notin']; });
DefMathML("Apply:?:contains", undef, sub {
my ($op, @args) = @_;
return cmml_synth_complement('m:in', @args); });
DefMathML("Apply:?:not-contains", undef, sub {
my ($op, @args) = @_;
( run in 1.336 second using v1.01-cache-2.11-cpan-437f7b0c052 )