]> git.nbdom.net Git - nb.git/commitdiff
cgi_text new line
authorNicolas Boisselier <nicolas.boisselier@gmail.com>
Mon, 4 Dec 2023 00:28:21 +0000 (01:28 +0100)
committerNicolas Boisselier <nicolas.boisselier@gmail.com>
Mon, 4 Dec 2023 00:28:21 +0000 (01:28 +0100)
lib/perl/NB/CGI.pm

index aec5d1b0f0f215fc64a7a56ebbd50f68d1726030..d332a0e2ca1e5db78c824314f5d70d557035b3b4 100644 (file)
@@ -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;