From 1084d82b1208ac5a0e6f64f67e61fe4163d13e59 Mon Sep 17 00:00:00 2001 From: Moritz Bunkus Date: Fri, 21 Oct 2005 14:40:23 +0000 Subject: [PATCH] HTML-Markup zulassen und in das entsprechende Ausgabeformat (HTML oder LaTeX) umsetzen. Unterstuetzt werden ... (fett), ... (kursiv), ... (unterstrichen) und nur fuer HTML ... (durchgestrichen). --- SL/Form.pm | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/SL/Form.pm b/SL/Form.pm index f2fe969bc..712f655c2 100644 --- a/SL/Form.pm +++ b/SL/Form.pm @@ -1070,6 +1070,32 @@ sub format_string { map { $self->{$_} =~ s/$key/$replace{$format}{$key}/g; } @fields; } + # Allow some HTML markup to be converted into the output format's + # corresponding markup code, e.g. bold or italic. + if ('html' eq $format) { + my @markup_replace = ('b', 'i', 's', 'u'); + + foreach my $key (@markup_replace) { + map({ $self->{$_} =~ s/\<(\/?)${key}\>/<$1${key}>/g } @fields); + } + + } elsif ('tex' eq $format) { + my %markup_replace = ('b' => 'textbf', + 'i' => 'textit', + 'u' => 'underline'); + + foreach my $field (@fields) { + if ($field =~ /descrip/) { + print(STDERR "QFT: ${field}: " . $self->{$field} . "\n"); + } + foreach my $key (keys(%markup_replace)) { + my $new = $markup_replace{$key}; + $self->{$field} =~ + s/\$\<\$${key}\$\>\$(.*?)\$<\$\/${key}\$>\$/\\${new}\{$1\}/gi; + } + } + } + $main::lxdebug->leave_sub(); } -- 2.20.1