Skip to content

Commit

Permalink
Fix the ijk() method to honor the texStrings/normalStrings value, and…
Browse files Browse the repository at this point in the history
… also accept a 'string' or 'TeX' value as a parameter
  • Loading branch information
dpvc committed Oct 7, 2013
1 parent fe26f29 commit fd53923
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion lib/Parser.pm
Original file line number Diff line number Diff line change
Expand Up @@ -797,7 +797,7 @@ sub unsetValues {
#
sub ijk {
my $self = shift;
$self->{tree}->ijk;
$self->{tree}->ijk(@_);
}

#########################################################################
Expand Down
7 changes: 4 additions & 3 deletions lib/Parser/List/Vector.pm
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,17 @@ sub _check {
}

sub ijk {
my $self = shift; my $method = shift || 'string';
my $self = shift; my $context = $self->context;
my $method = shift || ($context->flag("StringifyAsTeX") ? 'TeX': 'string');
my @coords = @{$self->{coords}};
$self->Error("Method 'ijk' can only be used on vectors in three-space")
unless (scalar(@coords) <= 3);
my @ijk = (); my $constants = $self->context->{constants};
my @ijk = (); my $constants = $context->{constants};
foreach my $x ('i','j','k','_0') {
my $v = (split(//,$x))[-1];
push(@ijk,($constants->{$x}||{string=>$v,TeX=>"\\boldsymbol{$v}"})->{$method});
}
my $prec = $self->{equation}{context}->operators->get('*')->{precedence};
my $prec = $context->operators->get('*')->{precedence};
my $string = ''; my $n; my $term;
foreach $n (0..scalar(@coords)-1) {
$term = $coords[$n]->$method($prec);
Expand Down
2 changes: 1 addition & 1 deletion lib/Value/Vector.pm
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ sub TeX {
}

sub ijk {
my $self = shift; my $type = shift || "string";
my $self = shift; my $type = shift || ($self->context->flag("StringifyAsTeX") ? "TeX" : "string");
my @coords = @{$self->data};
Value::Error("Method 'ijk' can only be used on Vectors in 3-space")
unless (scalar(@coords) <= 3);
Expand Down

0 comments on commit fd53923

Please sign in to comment.