Skip to content

Commit

Permalink
one approach to implementing \power macro
Browse files Browse the repository at this point in the history
  • Loading branch information
dginev committed Jul 11, 2020
1 parent fbdc0b4 commit 0053eee
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/LaTeXML/MathParser.pm
Original file line number Diff line number Diff line change
Expand Up @@ -1529,7 +1529,8 @@ sub NewScript {
$l++; $bumped = 1 }
elsif (my $innerl = p_getAttribute($rbase, '_bumplevel')) {
$l = $innerl; }
my $app = Apply(New(undef, undef, role => $y . 'SCRIPTOP', scriptpos => "$x$l"),
my $meaning = p_getAttribute($rscript, 'meaning');
my $app = Apply(New(undef, undef, role => $y . 'SCRIPTOP', scriptpos => "$x$l", ($meaning ? (meaning => $meaning) : ())),
$base, Arg($script, 0));
# Record whether this script was a floating one
$$app[1]{_wasfloat} = 1 if $mode eq 'FLOAT';
Expand Down
16 changes: 16 additions & 0 deletions lib/LaTeXML/Package/a11ymark.sty.ltxml
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,21 @@ DefMath('\deriv[]{}{}',

DefMath('\integral{}{}', '\int #1 \diffd #2', meaning => 'integral');

DefConstructor('\meaning{}{}', '#2', afterConstruct => sub {
my ($doc, $whatsit) = @_;
my $apply = $doc->getNode->lastChild;
if ($apply->localName eq 'XMApp') { # should be an apply, if by design
$apply->setAttribute('meaning', ToString($whatsit->getArg(1))); } },
bounded => 1, requireMath => 1);

DefMacro('\power{}{}', '\meaning{power}{#1^#2}');

# These still need work, since currently we get
# annotations "transpose(#1,#2)" and "frobulator(#1,#2)"
# instead of the desired "transpose(#1)" and "frobulator"
# I guess this needs a different type of XMath structural pattern...
DefMacro('\transpose{}', '\meaning{transpose}{#1^T}');
DefMacro('\frobulator', '\meaning{frobulator}{x\'}');

########
1;

0 comments on commit 0053eee

Please sign in to comment.