diff options
author | schnetter <schnetter@17b73243-c579-4c4c-a9d2-2d5706c11dac> | 2005-07-18 12:24:57 +0000 |
---|---|---|
committer | schnetter <schnetter@17b73243-c579-4c4c-a9d2-2d5706c11dac> | 2005-07-18 12:24:57 +0000 |
commit | 4273dbecd9b17efe04f9becbef010101b32d1c9e (patch) | |
tree | 5ba69ae1c251398d46465e136fade8fde04a1dcf | |
parent | ce414eac5afe1b1bf25de04b02c9672f5b1b8cf9 (diff) |
Properly quote the names and email address when creating the
documentation.tex file from the template, using the function
ClearForLatex.
Copy the function CleanForLatex from ThornUtils.pm file from the sbin
directory into the file new_thorn.pl.
git-svn-id: http://svn.cactuscode.org/flesh/trunk@4095 17b73243-c579-4c4c-a9d2-2d5706c11dac
-rwxr-xr-x | lib/make/new_thorn.pl | 70 |
1 files changed, 65 insertions, 5 deletions
diff --git a/lib/make/new_thorn.pl b/lib/make/new_thorn.pl index bc44fe1b..f56397c5 100755 --- a/lib/make/new_thorn.pl +++ b/lib/make/new_thorn.pl @@ -148,21 +148,24 @@ while (<IN>) { if ($i ne 0) { print OUT " \\\\ "; } - print OUT "$author_names[$i] \\textless $author_emails[$i]\\textgreater"; + print OUT &CleanForLatex($author_names[$i]) + . " \\textless " + . &CleanForLatex($author_emails[$i]) + . "\\textgreater"; } print OUT "\}\n"; } elsif (/^\\date\{\s*?\}/) { my $todays_date = `date "+%B %d %Y"`; chomp ($todays_date); if ($todays_date =~ /^\w+\s+\d+\s+\d+$/) { - print OUT "\\date\{$todays_date\}\n"; + print OUT "\\date\{" . &CleanForLatex($todays_date) . "\}\n"; } else { - print OUT $_; + print OUT &CleanForLatex($_); } } elsif (/^\\title\{\s*?\}/) { - print OUT "\\title\{$thorn_name\}\n"; + print OUT "\\title\{" . &CleanForLatex($thorn_name) . "\}\n"; } else { - print OUT $_; + print OUT $_; } } #system("cp $documentation_inputfile $documentation_outputfile"); @@ -308,3 +311,60 @@ sub TestName return $valid; } + +#/*@@ +# @routine CleanForLatex +# @date Sun Mar 3 19:05:41 CET 2002 +# @author Ian Kelley +# @desc +# Cleans up our values so that latex will not give us errors. +# $val = &CleanForLatex($val); +# Note: Do not call ToLower or ToUpper on the result; instead, +# transform before you clean for Latex. +# Note: This routine was copied from ThornUtils.pm. It should probably +# be required instead. Maybe this script should be moved into +# the sbin directory for that? +# @enddesc +# @calls +# @calledby +# @history +# +# @endhistory +# +#@@*/ +sub CleanForLatex +{ + my $val = shift; + + # escape special characters + $val =~ s,\\,\{\\textbackslash\},g; + $val =~ s,~,\{\\textasciitilde\},g; + $val =~ s,<,\{\\textless\},g; + $val =~ s,>,\{\\textgreater\},g; + + # at start of string, remove spaces before and after: " + $val =~ s,^\s*?\"\s*?,\",; + + # at end of string, remove spaces before and after: " + $val =~ s,\s*?\"\s*?$,\",; + + # escape _ + $val =~ s,\_,\\\_,g; + + # escape $ + $val =~ s,\$,\\\$,g; + + # escape ^ + $val =~ s,\^,\\\^,g; + + # escape * + $val =~ s,\*,\\\*,g; + + # escape & + $val =~ s,\&,\\\&,g; + + # escape % + $val =~ s,%,\\%,g; + + return $val; +} |