Skip to content

Commit

Permalink
Fix formatting of PGalias output -- particularly in TeX mode
Browse files Browse the repository at this point in the history
  • Loading branch information
mgage committed Aug 7, 2012
1 parent a8fabfb commit ce94724
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 7 deletions.
7 changes: 4 additions & 3 deletions lib/PGalias.pm
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ sub make_alias {
}
} elsif ($ext eq 'svg') {
if ($displayMode =~/HTML/) {
$self->warning_message("The image $aux_file_id of type $ext cannot yet be displayed in TeX mode");
$self->warning_message("The image $aux_file_id of type $ext cannot yet be displayed in HTML mode");
# svg images need an embed tag not an image tag -- need to modify image for this also
# an alternative (not desirable) is to convert svg to png
} elsif ($displayMode eq 'TeX') {
Expand All @@ -280,7 +280,7 @@ sub make_alias {

} elsif ($ext eq 'pdf') {
if ($displayMode =~/HTML/) {
$self->warning_message("The image $aux_file_id of type $ext cannot yet be displayed in HTML mode");
$self->warning_message("The image $aux_file_id of type pdf cannot yet be displayed in HTML mode");
} elsif ($displayMode eq 'TeX') {
$adr_output=$self->alias_for_image_in_tex_mode($aux_file_id, $ext);
} else {
Expand All @@ -292,7 +292,8 @@ sub make_alias {
# FILES with unrecognized file extensions in any display modes
################################################################################

warn "Error in the macro alias. Alias does not understand how to process files with extension $ext. (Path to problem file is $pgFileName) ";
warn "Error in the macro alias. Alias does not understand how to process files with extension $ext.
(Path to problem file is $pgFileName) ";
}

warn "The macro alias was unable to form a URL for some auxiliary file used in this problem." unless $adr_output;
Expand Down
8 changes: 5 additions & 3 deletions lib/PGcore.pm
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ sub pretty_print_html { # provides html output -- NOT a method
my $level = shift;
$level = 5 unless defined($level);
$level--;
return "PGalias" if ref($r_input) eq 'PGalias'; # PGalias just has too much information
return "PGalias has too much info. Try \$PG->{PG_alias}->{resource_list}" if ref($r_input) eq 'PGalias'; # PGalias just has too much information
return 'too deep' unless $level > 0; # only print four levels of hashes (safety feature)
my $out = '';
if ( not ref($r_input) ) {
Expand Down Expand Up @@ -131,7 +131,7 @@ sub pretty_print_tex {
my $level = shift;
$level = 5 unless defined($level);
$level--;
return "PGalias" if ref($r_input) eq 'PGalias'; # PGalias just has too much information
return "PGalias has too much info. Try \\\$PG->{PG\\_alias}->{resource\\_list}" if ref($r_input) eq 'PGalias'; # PGalias just has too much information
return 'too deep' unless $level>0; #only print four levels of hashes (safety feature)

my $protect_tex = sub {my $str = shift; $str=~s/_/\\\_/g; $str };
Expand All @@ -141,10 +141,11 @@ sub pretty_print_tex {
$out = $r_input if defined $r_input;
$out =~ s/_/\\\_/g; # protect tex
$out =~ s/&/\\\&/g;
$out =~ s/\$/\\\$/g;
} elsif ("$r_input" =~/hash/i) { # this will pick up objects whose '$self' is hash and so works better than ref($r_iput).
local($^W) = 0;

$out .= "\\begin{tabular}{| c | c |}\\hline\n\\multicolumn{2}{|c|}{$r_input}\\\\ \\hline\n";
$out .= "\\begin{tabular}{| l | l |}\\hline\n\\multicolumn{2}{|l|}{$r_input}\\\\ \\hline\n";


foreach my $key ( sort ( keys %$r_input )) {
Expand Down Expand Up @@ -239,6 +240,7 @@ sub initialize {
DEBUG_messages => $self->{DEBUG_messages},

);
#$self->debug_message("PG alias created", $self->{PG_alias} );
$self->{PG_loadMacros} = new PGloadfiles($self->{envir});
$self->{flags} = {
showpartialCorrectAnswers => 1,
Expand Down
2 changes: 1 addition & 1 deletion macros/PGbasicmacros.pl
Original file line number Diff line number Diff line change
Expand Up @@ -425,7 +425,7 @@ sub ANS_RULE { #deprecated
my $answer_value = '';
$answer_value = $inputs_ref->{$name} if defined( $inputs_ref->{$name} );
$name = RECORD_ANS_NAME($name, $answer_value);
# $answer_value =~ tr/\\$@`//d; #`## make sure student answers can not be interpolated by e.g. EV3
$answer_value =~ tr/\\$@`//d; #`## make sure student answers can not be interpolated by e.g. EV3
#INSERT_RESPONSE($name,$name,$answer_value); # no longer needed?
my $out = MODES(
TeX => qq!\\vskip $height in \\hrulefill\\quad !,
Expand Down

0 comments on commit ce94724

Please sign in to comment.