Last active
December 10, 2015 16:38
-
-
Save gerdr/4462564 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use v6; | |
# see http://catb.org/jargon/html/A/ASCII.html | |
# excludes _:. as these are allowed in HTML IDs | |
my %table = map &uc, qw{{ | |
! bang | |
" dquote | |
# sharp | |
$ dollar | |
% percent | |
& amper | |
' quote | |
( paren | |
) thesis | |
* star | |
+ plus | |
, comma | |
- dash | |
/ slash | |
; semi | |
< bra | |
> ket | |
= equals | |
? query | |
@ at | |
[ square | |
] unsquare | |
\ bslash | |
^ hat | |
` bquote | |
{ brace | |
} unbrace | |
| bar | |
~ tilde | |
}}; | |
%table{' '} = ''; | |
# FIXME: eval is evil | |
my $re = eval "/<[$_]> || <-[$_]>+/" given %table.keys.map('\\' ~ *).join; | |
# use trans? | |
sub mangle($_) { .comb($re).map({ %table{$_} // $_ }).join('-') } | |
say mangle $_ for @*ARGS; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment