# Pastebin yN7My85e @@ -248,11 +279,27 @@ sub process-pod-source(:$kind, :$pod, :$ } } +my %tm = < + % percent + # hash + - dash + . dot + ? question + / slash + \ blackslash + " quote +>; +sub english-for-tokens { + $^a.comb.map({ %tm{$_} ?? "-%tm{$_}-" !! $_ }) + .join.subst(/'--'/, '-', :g) + .subst: /^\-|\-|\-|\-$/, '', :g +}; + # XXX: Generalize multi write-type-source($doc) { sub href_escape($ref) { # only valid for things preceded by a protocol, slash, or hash - return uri_escape($ref).subst('%3A%3A', '::', :g); + return uri_escape(english-for-tokens($ref)).subst('%3A%3A', '::', :g); } my $pod = $doc.pod; my $podname = $doc.name; @@ -641,7 +688,7 @@ sub write-search-file() { say 'Writing html/js/search.js ...'; my $template = slurp("template/search_template.js"); sub escape(Str $s) { - $s.trans([] => [<\\/ \\\\ \\">]); + english-for-tokens($s) } my @items = $*DR.get-kinds.map(-> $kind { $*DR.lookup($kind, :by).categorize({escape .name})\