]> bicyclesonthemoon.info Git - ott/post/commitdiff
core functionality of bbcode conversion now works
authorb <rowerynaksiezycu@gmail.com>
Tue, 22 Aug 2023 22:11:37 +0000 (22:11 +0000)
committerb <rowerynaksiezycu@gmail.com>
Tue, 22 Aug 2023 22:11:37 +0000 (22:11 +0000)
post_common.1.pm
preview.1.pl

index 7f529bfb80638535156fb19b16a98d1226cc77ae..e0c78dc038dbd003cc713008b3c13517c3b75c2e 100644 (file)
@@ -37,6 +37,7 @@ our @EXPORT_OK = (
 ###PERL_LIB: use lib '/botm/lib/post';
 use botm_common (
        'system_encoded',
+       'write_data_file',
        'write_postdata_file',
        'html_entity_encode_dec'
 );
@@ -192,7 +193,7 @@ use constant BBCODE_SMILEY_FILE => {
        ':shock:'  => 'icon_eek.gif',
        ':?'       => 'icon_confused.gif',
        '8-)'      => 'icon_cool.gif',
-       ':lol    => 'icon_lol.gif',
+       ':lol:'    => 'icon_lol.gif',
        ':x'       => 'icon_mad.gif',
        ':P'       => 'icon_razz.gif',
        ':oops:'   => 'icon_redface.gif',
@@ -218,7 +219,7 @@ use constant BBCODE_SMILEY_TITLE => {
        ':shock:'  => 'Shocked',
        ':?'       => 'Confused',
        '8-)'      => 'Cool',
-       ':lol    => 'Laughing',
+       ':lol:'    => 'Laughing',
        ':x'       => 'Mad',
        ':P'       => 'Razz',
        ':oops:'   => 'Embarassed',
@@ -328,7 +329,7 @@ sub bbtree_add_text {
        if ($count >= 0) {
                my $ind_last = $ind.'.'.($count-1);
                if ($bbtree->{$ind_last.'.type'} eq 'text') {
-                       $bbtree->{$ind_last.'.text'} += $text;
+                       $bbtree->{$ind_last.'.text'} .= $text;
                        $text = '';
                }
        }
@@ -355,9 +356,9 @@ sub bbtree_add_text {
 sub bbtree_close_tag {
        (my $bbtree, my $level, my $ind, my $text, my $print) = @_;
        
-       $bbtree->{$ind.'endtext'} = $text;
+       $bbtree->{$ind.'.endtext'} = $text;
        # mark CURRENT tag as closed
-       $bbtree->{$ind.'closed'} = 1;
+       $bbtree->{$ind.'.closed'} = 1;
        
        if ($print){
                print bbtree_debug($bbtree, $ind);
@@ -377,9 +378,9 @@ sub bbtree_close_tag {
 sub bbtree_drop_tag {
        (my $bbtree, my $level, my $ind, my $text, my $print) = @_;
        
-       $bbtree->{$ind.'endtext'} = $text;
+       $bbtree->{$ind.'.endtext'} = $text;
        # mark CURRENT tag as NOT closed
-       $bbtree->{$ind.'closed'} = 0;
+       $bbtree->{$ind.'.closed'} = 0;
        
        if ($print){
                print bbtree_debug($bbtree, $ind);
@@ -455,6 +456,7 @@ sub bbtree_start {
        my $level = 0;
        
        if ($print) {
+               # print 'GOTO ['.$ind."]\n";
                print bbtree_info($bbtree, $ind);
        }
        return ($level, $ind, $sub_ind);
@@ -483,13 +485,15 @@ sub bbtree_next {
        }
        
        my $full_ind = $ind.'.'.$sub_ind;
-       if ($print) {
-               print '['.$full_ind."]\n";
-       }
+       # if ($print) {
+               # print 'GOTO ['.$full_ind."]\n";
+       # }
+       
        # next element is a tag; enter it
-       if ($bbtree->{'.type'} eq 'tag') {
+       if ($bbtree->{$full_ind.'.type'} eq 'tag') {
                $ind = $full_ind;
                $sub_ind = '';
+               $level += 1;
        }
        
        if ($print) {
@@ -499,6 +503,16 @@ sub bbtree_next {
        return ($level, $ind, $sub_ind);
 }
 
+sub bbtree_finish {
+       (my $bbtree, my $print) = @_;
+       my $level;
+       my $ind;
+       my $sub_ind;
+       
+       ($level, $ind, $sub_ind) = bbtree_start($bbtree, 0);
+       ($level, $ind) = bbtree_close_tag($bbtree, $level, $ind, '', $print);
+}
+
 # full info about bbtree element
 sub bbtree_info {
        (my $bbtree, my $ind) = @_;
@@ -681,6 +695,21 @@ sub bbcode_to_html {
                                next;
                        }
                        
+                       # additional reasons for rejecting tag
+                       if (
+                               # no [/*] not in [list] or [*]
+                               (($tag_name eq '*') and ($bbtree{$ind.'.name'} !~ /^((list)|\*)$/)) or
+                               # no tags in [img]
+                               (($tag_name ne 'img') and ($bbtree{$ind.'.name'} eq 'img'))
+                       ) {
+                               if ($print) {
+                                       print "this tag forbidden here\n";
+                               }
+                               bbtree_add_text(\%bbtree, $level, $ind, $tag, $print);
+                               # skip
+                               next;
+                       }
+                       
                        # unclosed [*] before [/list]
                        # add implicit [/*]
                        if (($tag_name eq 'list' ) and ($bbtree{$ind.'.name'} eq '*')) {
@@ -709,27 +738,37 @@ sub bbcode_to_html {
                                }
                                # add bad tag to BB tree as text and close current tag
                                ($level, $ind) = bbtree_drop_tag(\%bbtree, $level, $ind, $tag, $print);
+                               #skip
+                               next;
                        }
                        
                        # close current tag
                        ($level, $ind) = bbtree_close_tag(\%bbtree, $level, $ind, $tag, $print);
                }
        }
+       bbtree_finish(\%bbtree, $print);
        
        $in_code = 0;
        
        if ($print) {
+               print "BBTREE:\n";
+               write_data_file(\*STDOUT, 'console_out', 0, \%bbtree);
                print "\nGenerate HTML from BBcode tree:\n";
        }
        ($level, $ind, $sub_ind) = bbtree_start(\%bbtree, $print);
        
        while ($level >= 0) {
+               # if ($print) {
+                       # print "[$level][$ind][$sub_ind]\n";
+               # }
+               
                $tag        = $bbtree{$ind.'.text'};
                $tag_end    = $bbtree{$ind.'.endtext'};
                $tag_name   = $bbtree{$ind.'.name'};
                $tag_value  = $bbtree{$ind.'.value'};
                $tag_count  = $bbtree{$ind.'.count'};
                $tag_closed = $bbtree{$ind.'.closed'};
+               my $add_html = '';
                
                # tag start
                if ($sub_ind eq '') {
@@ -738,13 +777,17 @@ sub bbcode_to_html {
                                if ($print) {
                                        print "unmatched tag\n";
                                }
-                               $html .= html_entity_encode_dec($tag);
+                               $add_html .= html_entity_encode_dec($tag);
+                       }
+                       
+                       elsif ($tag_name eq '_') {
+                               # post start here
                        }
                        
                        elsif ($tag_name eq 'quote') {
                                if ($tag_value eq '') {
-                                       $html .= '<blockquote class="uncited"><div>';
-                                       #$html .= '<blockquote class="pq"><div>';
+                                       $add_html .= '<blockquote class="uncited"><div>';
+                                       #$add_html .= '<blockquote class="pq"><div>';
                                }
                                else {
                                        if ($tag_value =~ m/^"(.*)"$/gs) {
@@ -753,29 +796,29 @@ sub bbcode_to_html {
                                        else {
                                                $tag_value = 'QUOTE MARKS MISSING; '.html_entity_encode_dec($tag_value)
                                        }
-                                       $html .= '<blockquote><div><cite>'.html_entity_encode_dec($tag_value).' wrote:</cite>';
-                                       # $html .= '<blockquote class="pq"><div><cite class="pq"><b class="br">'.tagvalue.'</b> wrote:</cite><br>';
+                                       $add_html .= '<blockquote><div><cite>'.$tag_value.' wrote:</cite>';
+                                       # $add_html .= '<blockquote class="pq"><div><cite class="pq"><b class="br">'.$tag_value.'</b> wrote:</cite><br>';
                                }
                        }
                        
                        elsif ($tag_name eq 'b') {
-                               $html .= '<span style="font-weight: bold">';
+                               $add_html .= '<span style="font-weight: bold">';
                                if ($tag_value ne '') {
-                                       $html .= 'INVALID VALUE; ';
+                                       $add_html .= 'INVALID VALUE; ';
                                }
                        }
                        
                        elsif ($tag_name eq 'i') {
-                               $html .= '<span style="font-style: italic">';
+                               $add_html .= '<span style="font-style: italic">';
                                if ($tag_value ne '') {
-                                       $html .= 'INVALID VALUE; ';
+                                       $add_html .= 'INVALID VALUE; ';
                                }
                        }
                        
                        elsif ($tag_name eq 'u') {
-                               $html .= '<span style="text-decoration: underline">';
+                               $add_html .= '<span style="text-decoration: underline">';
                                if ($tag_value ne '') {
-                                       $html .= 'INVALID VALUE; ';
+                                       $add_html .= 'INVALID VALUE; ';
                                }
                        }
                        
@@ -784,23 +827,20 @@ sub bbcode_to_html {
                                        if ($print) {
                                                print "not a tag, actually\n";
                                        }
-                                       $html .= html_entity_encode_dec($tag);
+                                       $add_html .= html_entity_encode_dec($tag);
                                }
                                else {
-                                       $html .= '<dl class="codebox"><dt>Code: <a href="#" onclick="selectCode(this); return false;">Select all</a></dt><dd><code>';
-                                       # $html .= '<dl class="pq"><dt class="pq">Code: <a href="#" onclick="selectCode(this); return false;">Select all</a></dt><dd><code class="pq">';
+                                       $add_html .= '<dl class="codebox"><dt>Code: <a href="#" onclick="selectCode(this); return false;">Select all</a></dt><dd><code>';
+                                       # $add_html .= '<dl class="pq"><dt class="pq">Code: <a href="#" onclick="selectCode(this); return false;">Select all</a></dt><dd><code class="pq">';
                                }
                                if ($tag_value ne '') {
-                                       $html .= 'INVALID VALUE; ';
+                                       $add_html .= 'INVALID VALUE; ';
                                }
                                $in_code += 1;
                        }
                        
                        elsif ($tag_name eq 'img') {
-                               if ($tag_value ne '') {
-                                       $html .= 'INVALID VALUE; ';
-                               }
-                               $html .= '<img src="';
+                               $add_html .= '<img src="';
                        }
                        
                        elsif ($tag_name eq 'url') {
@@ -810,73 +850,73 @@ sub bbcode_to_html {
                                                print 'Implied value: '.$tag_value."\n";
                                        }
                                }
-                               $html .= '<a href="'.html_entity_encode_dec($tag_value).'" class="postlink">';
+                               $add_html .= '<a href="'.html_entity_encode_dec($tag_value).'" class="postlink">';
                        }
                        
                        elsif ($tag_name eq 'size') {
                                if (($tag_value =~ m/^([0-9]+)$/gs) and (int($tag_value) <= 200)) {
-                                       $html .= '<span style="font-size: '.$1.'%; line-height: 116%;">';
+                                       $add_html .= '<span style="font-size: '.$1.'%; line-height: 116%;">';
                                }
                                else {
-                                       $html .=  '<span style="font-size: 130%; line-height: 116%;"> INVALID VALUE; ';
+                                       $add_html .=  '<span style="font-size: 130%; line-height: 116%;"> INVALID VALUE; ';
                                }
                        }
                        
                        elsif ($tag_name eq 'color') {
                                if ($tag_value =~ m/^(#[0-9A-F]{6})$/gs) {
-                                       $html .= '<span style="color: '.$1.'">';
+                                       $add_html .= '<span style="color: '.$1.'">';
                                }
                                else {
-                                       $html .= '<span style="color: #EE0000"> INVALID VALUE; ';
+                                       $add_html .= '<span style="color: #EE0000"> INVALID VALUE; ';
                                }
                        }
                        
                        elsif ($tag_name eq 'center') {
-                               $html .= '<div align="center">';
+                               $add_html .= '<div align="center">';
                                if ($tag_value ne '') {
-                                       $html .= 'INVALID VALUE; ';
+                                       $add_html .= 'INVALID VALUE; ';
                                }
                        }
                        
                        elsif ($tag_name eq 'right') {
-                               $html .= '<div align="right">';
+                               $add_html .= '<div align="right">';
                                if ($tag_value ne '') {
-                                       $html .= 'INVALID VALUE; ';
+                                       $add_html .= 'INVALID VALUE; ';
                                }
                        }
                        
                        elsif ($tag_name eq 's') {
-                               $html .= '<strike>';
+                               $add_html .= '<strike>';
                                if ($tag_value ne '') {
-                                       $html .= 'INVALID VALUE; ';
+                                       $add_html .= 'INVALID VALUE; ';
                                }
                        }
                        
                        elsif ($tag_name eq 'sub') {
-                               $html .= '<sub>';
+                               $add_html .= '<sub>';
                                if ($tag_value ne '') {
-                                       $html .= 'INVALID VALUE; ';
+                                       $add_html .= 'INVALID VALUE; ';
                                }
                        }
                        
                        elsif ($tag_name eq 'sup') {
-                               $html .= '<sup>';
+                               $add_html .= '<sup>';
                                if ($tag_value ne '') {
-                                       $html .= 'INVALID VALUE; ';
+                                       $add_html .= 'INVALID VALUE; ';
                                }
                        }
                        
                        elsif ($tag_name eq 'spoiler') {
-                               $html .= '<div style="margin:20px; margin-top:5px"><div class="quotetitle"><b>Spoiler:</b> <input type="button" value="Show" style="width:45px;font-size:10px;margin:0px;padding:0px;" onclick="if (this.parentNode.parentNode.getElementsByTagName(\'div\')[1].getElementsByTagName(\'div\')[0].style.display != \'\') { this.parentNode.parentNode.getElementsByTagName(\'div\')[1].getElementsByTagName(\'div\')[0].style.display = \'\';        this.innerText = \'\'; this.value = \'Hide\'; } else { this.parentNode.parentNode.getElementsByTagName(\'div\')[1].getElementsByTagName(\'div\')[0].style.display = \'none\'; this.innerText = \'\'; this.value = \'Show\'; }" /></div><div class="quotecontent"><div style="display: none;">';
-                               # $html .= '<div style="margin:20px; margin-top:5px"><div class="quotetitle"><b>Spoiler:</b> <input type="button" class="pk" value="Show" style="width:45px;font-size:10px;margin:0px;padding:0px;" onclick="if (this.parentNode.parentNode.getElementsByTagName(\'div\')[1].getElementsByTagName(\'div\')[0].style.display != \'\') { this.parentNode.parentNode.getElementsByTagName(\'div\')[1].getElementsByTagName(\'div\')[0].style.display = \'\';        this.innerText = \'\'; this.value = \'Hide\'; } else { this.parentNode.parentNode.getElementsByTagName(\'div\')[1].getElementsByTagName(\'div\')[0].style.display = \'none\'; this.innerText = \'\'; this.value = \'Show\'; }" /></div><div class="quotecontent"><div style="display: none;">';
+                               $add_html .= '<div style="margin:20px; margin-top:5px"><div class="quotetitle"><b>Spoiler:</b> <input type="button" value="Show" style="width:45px;font-size:10px;margin:0px;padding:0px;" onclick="if (this.parentNode.parentNode.getElementsByTagName(\'div\')[1].getElementsByTagName(\'div\')[0].style.display != \'\') { this.parentNode.parentNode.getElementsByTagName(\'div\')[1].getElementsByTagName(\'div\')[0].style.display = \'\';        this.innerText = \'\'; this.value = \'Hide\'; } else { this.parentNode.parentNode.getElementsByTagName(\'div\')[1].getElementsByTagName(\'div\')[0].style.display = \'none\'; this.innerText = \'\'; this.value = \'Show\'; }" /></div><div class="quotecontent"><div style="display: none;">';
+                               # $add_html .= '<div style="margin:20px; margin-top:5px"><div class="quotetitle"><b>Spoiler:</b> <input type="button" class="pk" value="Show" style="width:45px;font-size:10px;margin:0px;padding:0px;" onclick="if (this.parentNode.parentNode.getElementsByTagName(\'div\')[1].getElementsByTagName(\'div\')[0].style.display != \'\') { this.parentNode.parentNode.getElementsByTagName(\'div\')[1].getElementsByTagName(\'div\')[0].style.display = \'\';        this.innerText = \'\'; this.value = \'Hide\'; } else { this.parentNode.parentNode.getElementsByTagName(\'div\')[1].getElementsByTagName(\'div\')[0].style.display = \'none\'; this.innerText = \'\'; this.value = \'Show\'; }" /></div><div class="quotecontent"><div style="display: none;">';
                                if ($tag_value ne '') {
-                                       $html .= 'INVALID VALUE; ';
+                                       $add_html .= 'INVALID VALUE; ';
                                }
                        }
                        
                        elsif ($tag_name eq 'list') {
                                if ($tag_value eq '') {
-                                       $html .= '<ul>';
+                                       $add_html .= '<ul>';
                                }
                                else {
                                        if ($tag_value eq '1') {
@@ -895,17 +935,17 @@ sub bbcode_to_html {
                                                $tag_value = 'upper-alpha';
                                        }
                                        else {
-                                               $html .= 'INVALID VALUE; ';
+                                               $add_html .= 'INVALID VALUE; ';
                                                $tag_value = 'decimal';
                                        }
-                                       $html .= '<ol style="list-style-type: '.$tag_value.'">';
+                                       $add_html .= '<ol style="list-style-type: '.$tag_value.'">';
                                }
                        }
                        
                        elsif ($tag_name eq '*') {
-                               $html .= '<li>';
+                               $add_html .= '<li>';
                                if ($tag_value ne '') {
-                                       $html .= 'INVALID VALUE; ';
+                                       $add_html .= 'INVALID VALUE; ';
                                }
                        }
                        
@@ -913,7 +953,7 @@ sub bbcode_to_html {
                                if ($print) {
                                        print "unknown tag\n"
                                }
-                               $html .= html_entity_encode_dec($tag);
+                               $add_html .= html_entity_encode_dec($tag);
                        }
                }
                
@@ -924,15 +964,19 @@ sub bbcode_to_html {
                                if ($print) {
                                        print "unmatched tag\n";
                                }
-                               $html .= html_entity_encode_dec($tag_end);
+                               $add_html .= html_entity_encode_dec($tag_end);
+                       }
+                       
+                       elsif ($tag_name eq '_') {
+                               # post end here
                        }
                        
                        elsif ($tag_name eq 'quote') {
-                               $html .= '</div></blockquote>';
+                               $add_html .= '</div></blockquote>';
                        }
                        
                        elsif ($tag_name =~ m/^(b|i|u|(size)|(color))$/gs) {
-                               $html .= '</span>';
+                               $add_html .= '</span>';
                        }
                        
                        elsif ($tag_name eq 'code') {
@@ -941,55 +985,64 @@ sub bbcode_to_html {
                                        if ($print) {
                                                print "not a tag, actually\n";
                                        }
-                                       $html .= html_entity_encode_dec($tag_end);
+                                       $add_html .= html_entity_encode_dec($tag_end);
                                }
                                else {
-                                       $html .= '</code></dd></dl>';
+                                       $add_html .= '</code></dd></dl>';
                                }
                        }
                        
+                       elsif ($tag_name eq 'img') {
+                               $add_html .= '" alt="Image" />';
+                               # $add_html .= '" alt="Image">';
+                               if ($tag_value ne '') {
+                                       $add_html .= 'INVALID VALUE; ';
+                               }
+                               
+                       }
+                       
                        elsif ($tag_name eq 'url') {
-                               $html .= '</a>';
+                               $add_html .= '</a>';
                        }
                        
                        elsif ($tag_name =~ /^((center)|(right))$/) {
-                               $html .= '</div>';
+                               $add_html .= '</div>';
                        }
                        
                        elsif ($tag_name eq 's') {
-                               $html .= '</strike>';
+                               $add_html .= '</strike>';
                        }
                        
                        elsif ($tag_name eq 'sub') {
-                               $html .= '</sub>';
+                               $add_html .= '</sub>';
                        }
                        
                        elsif ($tag_name eq 'sup') {
-                               $html .= '</sup>';
+                               $add_html .= '</sup>';
                        }
                        
                        elsif ($tag_name eq 'spoiler') {
-                               $html .= '</div></div></div>';
+                               $add_html .= '</div></div></div>';
                        }
                        
                        elsif ($tag_name eq 'list') {
                                if ($tag_value eq '') {
-                                       $html .= '</ul>';
+                                       $add_html .= '</ul>';
                                }
                                else {
-                                       $html .= '</ol>';
+                                       $add_html .= '</ol>';
                                }
                        }
                        
                        elsif ($tag_name eq '*') {
-                               $html .= '</li>';
+                               $add_html .= '</li>';
                        }
                        
                        else {
                                if ($print) {
                                        print "unknown tag\n";
                                }
-                               $html .= html_entity_encode_dec($tag_end);
+                               $add_html .= html_entity_encode_dec($tag_end);
                        }
                }
                
@@ -1024,16 +1077,21 @@ sub bbcode_to_html {
                        
                        # convert smilies
                        if (($post->{'smilies'}) and ($tag_name !~ /^((code)|(img))$/)) {
-                               $text =~ s/(^|[ \t])((:([D\(\)o\?xP\|]|((shock)|(lol)|(oops)|(cry)|(evil)|(twisted)|(roll)|(wink)|(idea)|(arrow)|(mrgreen)|[!\?]:)))|(8-\))|(;\)))($|[ \t])/' <img title="'.BBCODE_SMILEY_TITLE->{$2}.'alt="'.$2.'" src="'.BBCODE_SMILEY_FILE->{$2}.'" \/> '/ge;
-                               # $text =~ s/(^|[ \t])((:([D\(\)o\?xP\|]|((shock)|(lol)|(oops)|(cry)|(evil)|(twisted)|(roll)|(wink)|(idea)|(arrow)|(mrgreen)|[!\?]:)))|(8-\))|(;\)))($|[ \t])/' <img title="'.BBCODE_SMILEY_TITLE->{$2}.'alt="'.$2.'" src="'.BBCODE_SMILEY_FILE->{$2}.'"> '/ge;
+                               $text =~ s/(^|[ \t])((:([D\(\)o\?xP\|]|(((shock)|(lol)|(oops)|(cry)|(evil)|(twisted)|(roll)|(wink)|(idea)|(arrow)|(mrgreen)|[!\?]):)))|(8-\))|(;\)))($|[ \t])/' <img title="'.BBCODE_SMILEY_TITLE->{$2}.'" alt="'.$2.'" src="'.BBCODE_SMILEY_FILE->{$2}.'" \/> '/gme;
+                               # $text =~ s/(^|[ \t])((:([D\(\)o\?xP\|]|(((shock)|(lol)|(oops)|(cry)|(evil)|(twisted)|(roll)|(wink)|(idea)|(arrow)|(mrgreen)|[!\?]):)))|(8-\))|(;\)))($|[ \t])/' <img title="'.BBCODE_SMILEY_TITLE->{$2}.'" alt="'.$2.'" src="'.BBCODE_SMILEY_FILE->{$2}.'"> '/gme;
                        }
                        
                        # convert NL
                        $text =~ s/\r?\n/<br\/>\n/gs;
                        # $text =~ s/\r?\n/<br>\n/gs;
                        
-                       $html .= $text;
+                       $add_html .= $text;
+               }
+               
+               if ($print) {
+                       print "HTML=$add_html\n";
                }
+               $html .= $add_html;
                
                ($level, $ind, $sub_ind) = bbtree_next(\%bbtree, $level, $ind, $sub_ind, $print);
        }
index 8a0b0bcedd92675a15b35635f8189230516fa372..e1489aa2c5817d4d75b154cff4fe915a1de062d0 100644 (file)
@@ -141,6 +141,20 @@ if ((scalar @ARGV) == 0) {
        @ARGV = (\*STDIN);
 }
 
+my $fh;
+if ($options{'output-file'} ne '') {
+       unless (open ($fh, '>:encoding(UTF-8)', encode('locale_fs', $options{'output-file'}))) {
+               unless ($options{'quiet'} ne '') {
+                       print 'FAIL open '.$options{'output-file'}."\n";
+               }
+               print STDERR 'Failed  to open/create file '.$options{'output-file'}.".\n";
+               return CODE->{'POST_FAILED'};
+       }
+}
+else {
+       $fh = \*STDOUT;
+}
+
 my $code = CODE->{'OK'};
 foreach my $arg (@ARGV) {
        my $r;
@@ -193,6 +207,10 @@ foreach my $arg (@ARGV) {
                print $html."\n";
                print "\n";
        }
+       
+       print $fh $html."\n";
 }
 
+close ($fh);
+
 exit $code;