Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Module passes its first test already. :)
- Loading branch information
Carl Masak
committed
Aug 31, 2009
0 parents
commit 4c4499a
Showing
3 changed files
with
26 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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." |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
module Perl6::Literate; | ||
|
||
sub convert($text) { | ||
return "=begin Comment\n" ~ $text ~ "\n=end Comment"; | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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'; |