aboutsummaryrefslogtreecommitdiff
path: root/compose2html
diff options
context:
space:
mode:
authordakkar <dakkar@thenautilus.net>2016-07-24 17:05:30 +0100
committerdakkar <dakkar@thenautilus.net>2016-07-24 17:05:30 +0100
commitf02f6434206aaac1bd2ef4aaf4d79b1c8ee7f8cf (patch)
treee6bab503466e470d288a25d94602ecd28eb33174 /compose2html
parentmap more weird X11 key names (diff)
downloaddotXCompose-f02f6434206aaac1bd2ef4aaf4d79b1c8ee7f8cf.tar.gz
dotXCompose-f02f6434206aaac1bd2ef4aaf4d79b1c8ee7f8cf.tar.bz2
dotXCompose-f02f6434206aaac1bd2ef4aaf4d79b1c8ee7f8cf.zip
show input/output collisions
Diffstat (limited to 'compose2html')
-rw-r--r--compose2html41
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),
] ],
]);