digraphs: mkdigraphlist: escape vim mnemonics
[sheet.git] / tools / mkdigraphs-vim
index a94812fe942f52a8eb4a513e3c28906e3ffa6fc5..a4bdfe803e8e636ac7d99da5d9c06464c32f3a86 100755 (executable)
@@ -1,13 +1,18 @@
 #!/bin/sh
 
-VERSION=1.00
+VERSION=1.01
 
 vim -e -c'echo version' -cdigraphs -cq | perl -CSD -nE '
        if ($. == 1) { # head
                say "# digraphs list from vim version ", s/\s*\z//r;
                say "+{";
        } else { # body
-               say "q{$1} => $3," while /\G(\S\S) (.[^ ]*) +([0-9]+)\s+/g;
+               while (/\G(\S\S) (.[^ ]*) +([0-9]+)\s+/g) {
+                       my ($mnem, $chr, $cp) = ($1, $2, $3);
+                       $mnem =~ s/(?=[\\}])/\\/g;  # escape string delimiter
+                       $chrstr = sprintf q("\x{%x}"), $cp;
+                       say "q{$mnem} => $chrstr,";
+               }
        } END { # foot
                say "}";
                exit warn "only $. lines of :digraphs output\n" if $. < 6;