[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: New version of DPNhtml2mail.pl [was: Possible bug when generating mail version]



Dear Ryuunosuke,

Le mardi 15 mai 2012 à 14:31:45 (+0200), Thomas Blein a écrit :
> Quoting "AYANOKOUZI, Ryuunosuke" <i38w7i3@yahoo.co.jp>:
> >Here is an another type of bug on DPNhtml2mail.pl when generating a
> >Japanese version of DPN. This comes out because of ad-hoc handling
> >of UTF-8 flagged data. I have attached a debugged DPNhtml2mail.pl to
> >this mail. please check it.

I made some small modification to the code mainly for the links. The
result is fine in Latin languages, could you please check that it is
still fine for Japanese.

Thanks again for your input.

Regards,

Thomas
--- /home/tblein/DPNhtml2mail.pl	2012-05-15 20:20:51.000000000 +0200
+++ DPNhtml2mail.pl	2012-05-15 20:33:23.000000000 +0200
@@ -177,11 +177,11 @@
 	}elsif ($token->is_start_tag('a')) {
 		if ($token->[1]{'href'} !~ /^#\w+.*$/) {				# Common link
 			$data->{stories}[$stories_index]{'paragraph'}[$paragraph_index]{'subparagraph'}[$subparagraph_index]{'text'} .= $p->get_text;
-                        if ($token->[1]{'href'}) {
-                            $current_link = URI->new_abs($token->[1]{'href'}, $base_uri);
-                        } else {
-                            $current_link = '-';
-                        }
+			if ($token->[1]{'href'}) {
+				$current_link = URI->new_abs($token->[1]{'href'}, $base_uri);
+			} else {
+				$current_link = '-';
+			}
 			$in_link = 1;
 		} else {								# First internal links
 			$data->{stories}[$stories_index]{'paragraph'}[$paragraph_index]{'subparagraph'}[$subparagraph_index]{'text'} .= $p->get_text;
@@ -191,7 +191,7 @@
 			if (!($last_paragraph and $current_link->scheme() eq 'mailto')){
 				if (!($data->{stories}[$stories_index]{'paragraph'}[$paragraph_index]{'subparagraph'}[$subparagraph_index]{'text'} =~ /$current_link/)){
 					push(@{$data->{stories}[$stories_index]{'paragraph'}[$paragraph_index]{'links'}}, { 'index' => ++$link_index, 'link' => $current_link});
-					$data->{stories}[$stories_index]{'paragraph'}[$paragraph_index]{'subparagraph'}[$subparagraph_index]{'text'} .= " [".$link_index."] ";
+					$data->{stories}[$stories_index]{'paragraph'}[$paragraph_index]{'subparagraph'}[$subparagraph_index]{'text'} .= " [".$link_index."]";
 				}
 			}
 			$in_link = 0;
@@ -263,7 +263,7 @@
 	if (defined($stories->{'title'})){
 		$stories->{'title'} = space_cleaning($stories->{'title'});
 		print $stories->{'title'}, "\n", '-'x(columns($stories->{'title'})), "\n\n";
-    }
+	}
 	my $previous_links = 0;
 	foreach my $paragraph (@{$stories->{paragraph}}) {
 		foreach my $subparagraph (@{$paragraph->{subparagraph}}) {
@@ -271,11 +271,13 @@
 				if ((length($subparagraph->{'text'}) > 3) and ($subparagraph->{'text'} =~ /^\s* >> /)){
 					$subparagraph->{'text'} =~ s/^\s+>>/    /g;
 					print $subparagraph->{'text'};
+					print "\n";
 				} else {
 					$subparagraph->{'text'} = space_cleaning($subparagraph->{'text'});
 					if ((length($subparagraph->{'text'}) > 3) and ((substr $subparagraph->{'text'}, 0, 3) eq "  *")){
 						$in_list = 1;
 						print $subparagraph->{'text'};
+						print "\n";
 					} else {
 						if ($previous_links){
 							print_links($previous_links);
@@ -286,7 +288,6 @@
 						print $utf8->decode( $lf->fold( $first_line_indent, '', $subparagraph->{'text'} ) );
 					}
 				}
-				print "\n";
 			} else {
 				if ($previous_links){
 					print_links($previous_links);

Reply to: