Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
Module passes its first test already. :)
  • Loading branch information
Carl Masak committed Aug 31, 2009
0 parents commit 4c4499a
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 0 deletions.
13 changes: 13 additions & 0 deletions example
@@ -0,0 +1,13 @@
This is ordinary text. It will be turned into a comment by the literate
Perl 6 preprocessor. This paragraph is followed by a paragraph of code,
which begins with a '>' character. I have a space after the '>', because
I think it's nice. It's not a necessity, though.

> say "OH HAI";

There are empty lines before and after the lines of code starting with
'>'. If those empty lines were to be removed, the preprocessor will flag
an error and not produce any output. According to HaskellWiki, "the idea
behind this restriction is capturing the mistake of not inserting the >
mark at the beginning of the line. In general this is not only good
practice, but also a formatting that makes the code more readable."
5 changes: 5 additions & 0 deletions lib/Perl6/Literate.pm
@@ -0,0 +1,5 @@
module Perl6::Literate;

sub convert($text) {
return "=begin Comment\n" ~ $text ~ "\n=end Comment";
}
8 changes: 8 additions & 0 deletions t/01-comment-only.t
@@ -0,0 +1,8 @@
use v6;
use Test;

use Perl6::Literate;

is Perl6::Literate::convert("A\nB\n\nC"),
"=begin Comment\nA\nB\n\nC\n=end Comment",
'a program consisting only of a comment gets converted into Pod';

0 comments on commit 4c4499a

Please sign in to comment.