From 6447423a9844479cfa7332931d38ee7e1f20b479 Mon Sep 17 00:00:00 2001 From: Nicolas Boisselier Date: Mon, 4 Dec 2023 01:28:21 +0100 Subject: [PATCH] cgi_text new line --- lib/perl/NB/CGI.pm | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/lib/perl/NB/CGI.pm b/lib/perl/NB/CGI.pm index aec5d1b0..d332a0e2 100644 --- a/lib/perl/NB/CGI.pm +++ b/lib/perl/NB/CGI.pm @@ -21,6 +21,7 @@ $CGI::PARAM_UTF8 = 1; #&CGI::init; # NB 01.12.23 &CGI::charset('utf-8') if $CGI::PARAM_UTF8; my $NO_HEADERS = 0; +my $TEXT_OUTPUT = 0; sub new { my $cgi = &CGI::new(@_); @@ -31,13 +32,13 @@ sub new { return $cgi; } -my $isTextOutput = 0; sub textOutput {{ no warnings 'redefine'; no warnings 'once'; #return unless $Opt{html}; - $isTextOutput = 1; + $TEXT_OUTPUT = 1; + $CGI::CRLF = ''; *CGI::_tag_func = sub { my $tagname = shift; my ($q,$a,@rest) = CGI::self_or_default(@_); @@ -46,8 +47,10 @@ sub textOutput {{ #warn $tagname; return ''; my($attr) = ''; + my %attr; if (ref($a) && ref($a) eq 'HASH') { my(@attr) = CGI::make_attributes($a,$q->{'escape'}); + %attr = %$a; $attr = " @attr" if @attr; } else { unshift @rest,$a if defined $a; @@ -56,8 +59,10 @@ sub textOutput {{ $tagname = lc( $tagname ); my @result = (ref($rest[0]) eq 'ARRAY') ? @{$rest[0]} : "@rest"; - if (0) + #warn Dumper(\%attr) if $tagname eq 'a';; + if (exists $attr{cgi_text}) { + @result = ($attr{cgi_text},"\n") if $attr{cgi_text}; } # H. elsif ($tagname =~ /^h(\d+)$/) @@ -311,6 +316,6 @@ sub tag { } sub text { - return $isTextOutput; + return $TEXT_OUTPUT; } 1; -- 2.47.3