this is based on slashcodes html-cleaning sub, any error big or small is my fault. use with caution, may produce "transitional" html ;), extracts links and uses the hostname as link-text, allows links in the form

[link-text=url]
needs URI.

sub bb2html { $introtext =~ s/<.*?>//gi; # no html allowed, no math either ;) $introtext =~ s/\n\s*\n/\n\n/gi; $introtext =~ s/\n\n\n/\n\n/gi; $introtext =~ s/&nbsp;/ /gi; $introtext =~ s/\n/<BR>/gi; $introtext =~ s/(?<=BR>)(http|https|ftp|gopher|telnet)/ $1/gi; $introtext =~ s/\s+$//gi; $introtext =~ s/^\s+//gi; $introtext .= " "; $introtext =~ s/\{/%7B/gi; $introtext =~ s/\}/%7D/gi; $introtext =~ s/\[([^A\]]{1,2})\s+.*?\]/\[$1\]/gi; $introtext =~ s/\[\/([^A\]]{1,2})\s+.*?\]/\[\/$1\]/gi; $introtext =~ s/\[([^A\]]{1,2})\]/<$1>/gi; $introtext =~ s/\[\/([^A\]]{1,2})\]/<\/$1>/gi; $introtext =~ s{\[([^=\]]+?)=(http|https|ftp|gopher|telnet)://([$ +URI::uric#]+?)\]}{ my($text, $proto, $url) = ($1, $2, $3); my $extra = ''; $extra = $1 if $url =~ s/([?!;:.,']+)$//; $extra = ')' . $extra if $url !~ /\(/ && $url =~ s/\)$//; qq[<A TARGET="_blank" HREF="$proto://$url">$text</A>$extra]; }ogie; $introtext =~ s{(?<!["=>])(http|https|ftp|gopher|telnet)://([$URI +::uric#]+)}{ my($proto, $url) = ($1, $2); my $extra = ''; my $host_capture = $url; $host_capture =~ s/([^\/]*).*/$1/i; #$host_capture = substr($host_capture,0,17) . "..." if length( +$host_capture)>20; $extra = $1 if $url =~ s/([?!;:.,']+)$//; $extra = ')' . $extra if $url !~ /\(/ && $url =~ s/\)$//; qq[<A TARGET="_blank" HREF="$proto://$url">$host_capture</A>$e +xtra]; }ogie; return $introtext; }

At least something to play with...

regards,
tomte


Hlade's Law:

If you have a difficult task, give it to a lazy person --
they will find an easier way to do it.


In reply to Re: Converting to html tags... by Tomte
in thread Converting to html tags... by kiat

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.