Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Add initial Pod::Htmlify
This currently only exports url-munge(); more to come.
Also added tests of url-munge().
  • Loading branch information
Paul Cochrane committed Feb 20, 2015
1 parent 1b44b51 commit 85e24fa
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 0 deletions.
16 changes: 16 additions & 0 deletions lib/Pod/Htmlify.pm6
@@ -0,0 +1,16 @@
module Pod::Htmlify;

use URI::Escape;

sub url-munge($_) is export {
return $_ if m{^ <[a..z]>+ '://'};
return "/type/{uri_escape $_}" if m/^<[A..Z]>/;
return "/routine/{uri_escape $_}" if m/^<[a..z]>|^<-alpha>*$/;
# poor man's <identifier>
if m/ ^ '&'( \w <[[\w'-]>* ) $/ {
return "/routine/{uri_escape $0}";
}
return $_;
}

# vim: expandtab shiftwidth=4 ft=perl6
25 changes: 25 additions & 0 deletions t/pod-htmlify.t
@@ -0,0 +1,25 @@
use v6;
use Test;
use lib 'lib';

plan 2;

use_ok('Pod::Htmlify');
use Pod::Htmlify;

subtest {
plan 7;

eval_dies_ok('use Pod::Htmlify; url-munge();', "requires an argument");
is(url-munge("http://www.example.com"), "http://www.example.com",
"plain url string with explicit protocol");
is(url-munge("Class::Something"), "/type/Class%3A%3ASomething",
"type name input");
is(url-munge("funky-routine"), "/routine/funky-routine",
"routine name input");
is(url-munge('&stuff'), "/routine/stuff", "identifier (sub) input");
is(url-munge("infix<+>"), "/routine/infix%3C%2B%3E", "operator input");
is(url-munge('$*VAR'), '$*VAR', "sigil/twigil input");
}, "url-munge";

# vim: expandtab shiftwidth=4 ft=perl6

0 comments on commit 85e24fa

Please sign in to comment.