From: b Date: Sat, 30 Sep 2023 21:37:24 +0000 (+0000) Subject: bbcode converter more readable X-Git-Tag: v1.1.0~37 X-Git-Url: http://bicyclesonthemoon.info/git-projects/?a=commitdiff_plain;h=217138f6053aee240131646eec16b376a7796c9a;p=ott%2Fbsta bbcode converter more readable --- diff --git a/botm-common b/botm-common index bd6107e..c88ca49 160000 --- a/botm-common +++ b/botm-common @@ -1 +1 @@ -Subproject commit bd6107e790c6666a87a0e9f2bec9370868bf531b +Subproject commit c88ca49b964a50d81875ab64ccaf2f25c64b89f3 diff --git a/bsta_lib.1.pm b/bsta_lib.1.pm index 048c083..0473e23 100644 --- a/bsta_lib.1.pm +++ b/bsta_lib.1.pm @@ -308,96 +308,117 @@ sub urlencode { return url_encode($t, '', $all); } +# BB code stuff +# different & simpler implementation than in post library +# to consider: +# a BBcode library? + #analyse bbcode text to build tag tree #TODO make [/*] optional! sub bbtree { (my $bb, my $printdebug) = @_; my %bbtree; my $ind; my $tag; - my $tagname; - my $tagvalue; - my $tagend; + my $tag_name; + my $tag_value; + my $tag_end; my $level=0; - my $pretext; + my $pre_text; my $debug; $ind="_"; $level=0; - $bbtree{"_.n"}="ht"; - $bbtree{"_.v"}=''; - $bbtree{"_.t"}="tg"; - $bbtree{"_.e"}=0; - $bbtree{"_.c"}=''; - $debug .= debug($printdebug, "\n\n"); - $bbtree{'_.'.$bbtree{"_.e"}.'.t'}="tg"; - $bbtree{'_.'.$bbtree{"_.e"}.'.n'}='/ht'; - $bbtree{"_.e"}+=1; - $bbtree{"_.c"}=1; + my $final_ind = '_.'.$bbtree{"_.count"} + $debug .= debug($printdebug, "[$final_ind]automatic tag: [/ht]\n -->\n"); + $bbtree{$final_ind.'.type' } = "tag"; + $bbtree{$final_ind.'.name' } = '/ht'; + $bbtree{ '_.count' }+= 1; + $bbtree{ '_.closed'} = 1; return ($debug, %bbtree); } @@ -425,16 +446,16 @@ sub convtree { $debug .= debug($printdebug, "\n