From: b Date: Sun, 1 Oct 2023 22:10:12 +0000 (+0000) Subject: improve BB tree conversion X-Git-Tag: v1.1.0~36 X-Git-Url: http://bicyclesonthemoon.info/git-projects/?a=commitdiff_plain;h=52d12563435dec2d590c4ffe5331a48e83ec6379;p=ott%2Fbsta improve BB tree conversion --- 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;