From a68beced0ec2d3de58f58eea49b162680509b48d Mon Sep 17 00:00:00 2001 From: "Difrex(Denis Zheleztsov)" Date: Mon, 11 Aug 2014 11:41:16 +0400 Subject: [PATCH] Initial support for HTML::FromText --- II/T.pm | 29 ++++++++++++++++++++--------- 1 file changed, 20 insertions(+), 9 deletions(-) diff --git a/II/T.pm b/II/T.pm index 98735fc..3c60600 100644 --- a/II/T.pm +++ b/II/T.pm @@ -1,6 +1,8 @@ package II::T; use HTML::Template; +use HTML::FromText (); +use Encode; use Data::Dumper; sub new { @@ -162,11 +164,26 @@ sub in_pre { sub pre { my ( $self, $post ) = @_; - $post =~ s//>/g; + my $t2h = HTML::FromText->new( + { paras => 1, + bullets => 1, + lines => 1, + blockcode => 1, + tables => 0, + numbers => 0, + urls => 0, + email => 1, + bold => 1, + underline => 1, + } + ); + + $post = $t2h->parse( decode_utf8($post) ); $post =~ s/>(.+)/>$1<\/font>/g; $post =~ s/--/—/g; - $post =~ s/.?\*(.+)\*.?/ $1<\/b> /g; + + # Lists + $post =~ s/\*(.+)/
  • $1<\/li>/g; # Images $post @@ -175,12 +192,6 @@ sub pre { # ii uri $post =~ s/ii:\/\/(.{20})\s/$1<\/a>/g; - # $post =~ s/ii:\/\/(.+\.\d+)/$1<\/a>/g; - - $post =~ s/^$/
    \n/g; - $post =~ s/(.?)\n/$1
    \n/g; - $post =~ s/\*(.+)/
  • $1<\/li>\n/g; - # Not are regexp parsing my $pre = 0; my $txt;