--- loncom/interface/lonprintout.pm 2006/10/20 17:37:20 1.488 +++ loncom/interface/lonprintout.pm 2006/10/23 10:40:09 1.489 @@ -2,7 +2,7 @@ # The LearningOnline Network # Printout # -# $Id: lonprintout.pm,v 1.488 2006/10/20 17:37:20 albertel Exp $ +# $Id: lonprintout.pm,v 1.489 2006/10/23 10:40:09 foxr Exp $ # # Copyright Michigan State University Board of Trustees # @@ -62,7 +62,7 @@ my $resources_printed; sub printf_style_subst { my ($item, $format_string, $repl) = @_; - while ($format_string =~m/\G[^%]*(%(\d*)\Q$item\E)/g) { + while ($format_string =~m/%\d*\Q$item\E/) { my $fmt = $1; my $size = $2; my $subst = $repl; @@ -70,7 +70,7 @@ sub printf_style_subst { $subst = substr($subst, 0, $size); } my $newpos = pos($format_string) + length($subst) - length($fmt); - $format_string =~ s/\Q$fmt\E\G/$subst/; + $format_string =~ s/\Q$fmt\E/$subst/; pos($format_string)=$newpos; } return $format_string; @@ -128,6 +128,12 @@ sub format_page_header { $format = &printf_style_subst("a", $format, $assignment); $format = &printf_style_subst("c", $format, $course); $format = &printf_style_subst("n", $format, $student); + + # If the user put %'s in the format string, they must be escaped + # to \% else LaTeX will think they are comments and terminate + # the line.. which is bad!!! + + $format =~ s/%/\\%/g; }