From 52d12563435dec2d590c4ffe5331a48e83ec6379 Mon Sep 17 00:00:00 2001 From: b Date: Sun, 1 Oct 2023 22:10:12 +0000 Subject: [PATCH] improve BB tree conversion --- bsta_lib.1.pm | 170 ++++++++++++++++++++++---------------------------- 1 file changed, 75 insertions(+), 95 deletions(-) diff --git a/bsta_lib.1.pm b/bsta_lib.1.pm index 0473e23..5697e6b 100644 --- a/bsta_lib.1.pm +++ b/bsta_lib.1.pm @@ -71,7 +71,7 @@ use constant TEXT_MODE => { 'info' => 2, }; -use constant tagsbb => { +use constant tags_bbcode => { 'ht' => '', '/ht' => '', 'fq' => '[quote]', @@ -99,7 +99,7 @@ use constant tagsbb => { '?' => '[unknown!]', '/?' => '[/unknown!]', }; -use constant tagsht => { +use constant tags_html => { 'ht' => '', '/ht' => '', 'fq' => '
', @@ -425,82 +425,60 @@ sub bbtree { #convert tag tree to final text sub convtree { - (my $printdebug, my $debug, my $lang, my %bbtree) = @_; - my $ht; + (my $printdebug, my $debug, my $lang, my $bbtree) = @_; + my $out; my $ind; my $indd; - my $level=0; - my $tagsr = ($lang eq 'html') ? tagsht : tagsbb; - my %tags = %$tagsr; + my $level = 0; + my $tags = ($lang eq 'html') ? tags_html : tags_bbcode; my $escape = ($lang eq 'html'); # $debug .= debug($printdebug, "\n****\n"); # foreach my $iiii (keys %tags) { - # $debug .= debug($printdebug, $iiii.'='.$tags{$iiii}."\n"); + # $debug .= debug($printdebug, $iiii.'='.$tags->{$iiii}."\n"); # } # $debug .= debug($printdebug, "****\n"); - $level=0; - $ind='_'; - $ht=''; + $level = 0; + $ind = '_'; + $out = ''; $debug .= debug($printdebug, "\n\n"); - return ($debug, $ht); + return ($debug, $out); } #bbcode to html, TBD @@ -596,7 +576,7 @@ sub bb_to_html { my %bbtree; my $debug; - ($debug, %bbtree) = bbtree($bb,$printdebug); + ($debug, %bbtree) = bbtree($bb, $printdebug); ($debug, $ht) = convtree ($printdebug, $debug, 'html', %bbtree); return $ht; @@ -609,7 +589,7 @@ sub bb_to_bbcode { my %bbtree; my $debug; - ($debug, %bbtree) = bbtree($bb,$printdebug); + ($debug, %bbtree) = bbtree($bb, $printdebug); ($debug, $ht) = convtree ($printdebug, $debug, 'bb', %bbtree); return $ht; -- 2.30.2