Created
June 22, 2024 17:22
-
-
Save librasteve/fb00312d1ffc03a5a16598efd5d5bd59 to your computer and use it in GitHub Desktop.
Raku Markdown
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
#!/usr/bin/env raku | |
use MONKEY-SEE-NO-EVAL; | |
#| takes markdown file and evals all code lines delimited by '```perl6 xxx ```' | |
sub MAIN( | |
$filename!, #= '/pathto/example.md' | |
) { | |
my @lines = $filename.IO.lines or die 'no file found'; | |
my $toggle = False; | |
my $code; | |
for @lines -> $line { | |
when $line ~~ /^ '```perl6'/ { $toggle = True } | |
when $line ~~ /^ '```'/ { $toggle = False } | |
when $toggle { $code ~= "$line\n" } | |
} | |
EVAL $code // warn "no code found"; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment