diff --git a/.gitignore b/.gitignore index 34b82d4..b10fa10 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,2 @@ -.precomp/ - +*~ +.precomp diff --git a/README.pod6 b/README.pod6 index 12cb544..21dbf54 100644 --- a/README.pod6 +++ b/README.pod6 @@ -5,17 +5,17 @@ Render Pod6 as HTML =begin SYNOPSIS -=item +Use it integrated with Perl 6 documentation system + perl6 --doc=HTML lib/FancyModule.pm > FancyModule.html -=begin item - =begin code - =pod My I> embedded C - document! +Or as an external function to render your documentation + +=begin code +=pod My I> embedded C document! - say Pod::To::HTML.render($=pod[0]); - =end code -=end item +say Pod::To::HTML.render($=pod[0]); +=end code =end SYNOPSIS diff --git a/lib/Pod/To/HTML.pm b/lib/Pod/To/HTML.pm index eac19db..08a87af 100644 --- a/lib/Pod/To/HTML.pm +++ b/lib/Pod/To/HTML.pm @@ -171,7 +171,7 @@ sub pod2html( --> Str ) is export { my $template-file = %?RESOURCES; - with $templates { + with $templates { if "$templates/main.mustache".IO ~~ :f { $template-file = "$templates/main.mustache".IO } diff --git a/resources/examples/main.mustache b/resources/examples/main.mustache new file mode 100644 index 0000000..9fb5d58 --- /dev/null +++ b/resources/examples/main.mustache @@ -0,0 +1,26 @@ + + + + {{ title }} + + + + +
+ {{{ header }}} + {{# title }}

{{ title }}

{{/ title }} + {{# subtitle }}

{{ subtitle }}

{{/ subtitle }} +
+ {{# body }}{{{ . }}}{{/ body }} +
+ + diff --git a/resources/examples/render.p6 b/resources/examples/render.p6 new file mode 100644 index 0000000..ba9a434 --- /dev/null +++ b/resources/examples/render.p6 @@ -0,0 +1,17 @@ +#!/usr/bin/env perl6 + +use v6; +use MONKEY-SEE-NO-EVAL; +use Pod::To::HTML; + +sub MAIN( $file = "../../README.pod6" ) { + my $file-content = $file.IO.slurp; + die "No pod here" if not $file-content ~~ /\=begin \s+ pod/; + my $pod; + try { + $pod = EVAL($file-content ~ "\n\$=pod"); + }; + die "Pod fails: $!" if $!; + my $result = pod2html( $pod, templates => '.' ); + say $result; +}