diff options
-rw-r--r-- | compose2html | 41 |
1 files changed, 39 insertions, 2 deletions
diff --git a/compose2html b/compose2html index 2d1533a..ea4c14b 100644 --- a/compose2html +++ b/compose2html @@ -4,7 +4,7 @@ use warnings; use 5.020; use utf8; use open ':std',':locale'; -use List::AllUtils qw(natatime); +use List::AllUtils qw(uniq natatime); use HTML::Tiny; use HTML::Entities; use Unicode::UCD qw(charinfo); @@ -50,6 +50,23 @@ sub sort_it { sort { $a->[0] cmp $b->[0] } @_ } +sub extract_collisions { + my %same_output; + my %same_input; + for my $mapping (@_) { + my ($input,$output) = @{$mapping}; + push @{$same_input{$input}},$output; + push @{$same_output{$output}},$input; + } + for my $h (\%same_input,\%same_output) { + for my $i (keys %$h) { + @{$h->{$i}} = uniq @{$h->{$i}}; + delete $h->{$i} if @{$h->{$i}} < 2; + } + } + return (\%same_input,\%same_output); +} + my %glyph = ( acute => '`', ampersand => '&', @@ -169,6 +186,23 @@ sub fill_table { ] ]; } +sub show_collisions { + my @kind = qw(input output); + my %same; @same{@kind} = @_; + map { + my $kind = $_; + [ \'div', [ + [ \'h2', "\u$kind collisions" ], + [ \'dl', [ + map { + [ \'dt', $_ ], + map { [ \'dd', $_ ] } sort @{$same{$kind}->{$_}} + } sort keys %{$same{$kind}} + ] ], + ] ]; + } @kind; +} + my $css = <<'CSS'; table { width: 100%; @@ -199,6 +233,8 @@ span.info { } CSS +my @data = to_presentation_form sort_it parse_compose_file; + print HTML::Tiny->new->html([ [\'head',[ [\'meta', {'http-equiv'=>'Content-Type',content=>'text/html;charset=utf-8'}], @@ -206,6 +242,7 @@ print HTML::Tiny->new->html([ [\'title','Compose mappings'] ] ], [ \'body', [ - fill_table to_presentation_form sort_it parse_compose_file, + (fill_table @data), + (show_collisions extract_collisions @data), ] ], ]); |